https://github.com/sstwcw created
https://github.com/llvm/llvm-project/pull/172242
How the program figured out which lines to move along the aligned lines 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";
```
>From bb769b0843ced95b19c3071419c6a541f1869156 Mon Sep 17 00:00:00 2001
From: sstwcw <[email protected]>
Date: Mon, 15 Dec 2025 02:43:37 +0000
Subject: [PATCH] [clang-format] Align different categories together
How the program figured out which lines to move along the aligned lines
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";
```
---
clang/lib/Format/WhitespaceManager.cpp | 1 +
clang/unittests/Format/FormatTest.cpp | 8 ++++++++
2 files changed, 9 insertions(+)
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