-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[clang-format] Align different categories together #172242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
How the program figured out which lines to move along the aligned lines 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"; ```
|
@llvm/pr-subscribers-clang-format Author: None (sstwcw) ChangesHow the program figured out which lines to move along the aligned lines in 75c85ba. 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 const char *const MatHtoolCompressorTypes[] = {"sympartialACA", "fullACA",
"SVD"};
const char HtoolCitation[] = "@<!-- -->article{marchand2020two,\n"
" "
" "
" "
"}\n";old const char *const MatHtoolCompressorTypes[] = {"sympartialACA", "fullACA"};
const char HtoolCitation[] = "@<!-- -->article{marchand2020two,\n"
" "
" "
" "
"}\n";Full diff: https://github.com/llvm/llvm-project/pull/172242.diff 2 Files Affected:
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"
|
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/157/builds/43032 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/66/builds/23727 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/110/builds/6820 Here is the relevant piece of the build log for the reference |
How the program figured out which lines to move along the aligned lines in 75c85ba. 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
AlignConsecutiveAssignmentsandAlignConsecutiveDeclarationsenabledold