Author: sstwcw Date: 2025-12-16T02:00:24Z New Revision: 941809bccc30eff7e0dc2b467d3360b27f0a50d2
URL: https://github.com/llvm/llvm-project/commit/941809bccc30eff7e0dc2b467d3360b27f0a50d2 DIFF: https://github.com/llvm/llvm-project/commit/941809bccc30eff7e0dc2b467d3360b27f0a50d2.diff LOG: [clang-format] Align different categories together (#172242) How the program figured out which lines to move along the aligned lines changed in 75c85bafb830e5. Aligning the lines caused the information to be out of date for aligning different categories later on. It caused a regression. Fixes #171021. new, with the options `AlignConsecutiveAssignments` and `AlignConsecutiveDeclarations` enabled ```C++ const char *const MatHtoolCompressorTypes[] = {"sympartialACA", "fullACA", "SVD"}; const char HtoolCitation[] = "@article{marchand2020two,\n" " " " " " " "}\n"; ``` old ```C++ const char *const MatHtoolCompressorTypes[] = {"sympartialACA", "fullACA"}; const char HtoolCitation[] = "@article{marchand2020two,\n" " " " " " " "}\n"; ``` Added: Modified: clang/lib/Format/WhitespaceManager.cpp clang/unittests/Format/FormatTest.cpp Removed: ################################################################################ diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp index 805bb78f5c90e..6bfcebe73a165 100644 --- a/clang/lib/Format/WhitespaceManager.cpp +++ b/clang/lib/Format/WhitespaceManager.cpp @@ -372,6 +372,7 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End, (ScopeStack.size() == 1u && CurrentChange.NewlinesBefore > 0 && InsideNestedScope)) { LineShifted = true; + CurrentChange.IndentedFromColumn += Shift; CurrentChange.Spaces += Shift; } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 3ff784035dd44..bf69d0a56ebfc 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -20879,6 +20879,14 @@ TEST_F(FormatTest, AlignWithLineBreaks) { " };", Style); + verifyFormat("const char *const MatHtool[] = {};\n" + "const char Htool[] = \"@article{m,\\n\"\n" + " \" \"\n" + " \" \"\n" + " \" \"\n" + " \"}\\n\";", + Style); + Style.ColumnLimit = 15; verifyFormat("int i1 = 1;\n" "k = bar(\n" _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
