Skip to content

Commit 941809b

Browse files
authored
[clang-format] Align different categories together (llvm#172242)
How the program figured out which lines to move along the aligned lines changed in 75c85ba. Aligning the lines caused the information to be out of date for aligning different categories later on. It caused a regression. Fixes llvm#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"; ```
1 parent f19c83f commit 941809b

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

clang/lib/Format/WhitespaceManager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
372372
(ScopeStack.size() == 1u && CurrentChange.NewlinesBefore > 0 &&
373373
InsideNestedScope)) {
374374
LineShifted = true;
375+
CurrentChange.IndentedFromColumn += Shift;
375376
CurrentChange.Spaces += Shift;
376377
}
377378

clang/unittests/Format/FormatTest.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20879,6 +20879,14 @@ TEST_F(FormatTest, AlignWithLineBreaks) {
2087920879
" };",
2088020880
Style);
2088120881

20882+
verifyFormat("const char *const MatHtool[] = {};\n"
20883+
"const char Htool[] = \"@article{m,\\n\"\n"
20884+
" \" \"\n"
20885+
" \" \"\n"
20886+
" \" \"\n"
20887+
" \"}\\n\";",
20888+
Style);
20889+
2088220890
Style.ColumnLimit = 15;
2088320891
verifyFormat("int i1 = 1;\n"
2088420892
"k = bar(\n"

0 commit comments

Comments
 (0)