[clang] 5e0fc93 - [clang-format] Fix a bug in `AlignAfterOpenBracket: DontAlign` (#94561)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 6 17:25:50 PDT 2024
Author: Owen Pan
Date: 2024-06-06T17:25:46-07:00
New Revision: 5e0fc93d01c216544c12b60c30fe8ac6c9931eb9
URL: https://github.com/llvm/llvm-project/commit/5e0fc93d01c216544c12b60c30fe8ac6c9931eb9
DIFF: https://github.com/llvm/llvm-project/commit/5e0fc93d01c216544c12b60c30fe8ac6c9931eb9.diff
LOG: [clang-format] Fix a bug in `AlignAfterOpenBracket: DontAlign` (#94561)
Fixes #94555.
Added:
Modified:
clang/lib/Format/ContinuationIndenter.cpp
clang/unittests/Format/FormatTest.cpp
Removed:
################################################################################
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 6b9fbfe0ebf53..be684ac71cd61 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1712,7 +1712,7 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
(!Previous || Previous->isNot(tok::kw_return) ||
(Style.Language != FormatStyle::LK_Java && PrecedenceLevel > 0)) &&
(Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign ||
- PrecedenceLevel != prec::Comma || Current.NestingLevel == 0) &&
+ PrecedenceLevel > prec::Comma || Current.NestingLevel == 0) &&
(!Style.isTableGen() ||
(Previous && Previous->isOneOf(TT_TableGenDAGArgListComma,
TT_TableGenDAGArgListCommaToBreak)))) {
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 4e427268fb82a..dbc1916825f33 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -9241,6 +9241,14 @@ TEST_F(FormatTest, AlignsAfterOpenBracket) {
" b));",
Style);
+ Style.ColumnLimit = 30;
+ verifyFormat("for (int foo = 0; foo < FOO;\n"
+ " ++foo) {\n"
+ " bar(foo);\n"
+ "}",
+ Style);
+ Style.ColumnLimit = 80;
+
Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
Style.BinPackArguments = false;
Style.BinPackParameters = false;
More information about the cfe-commits
mailing list