curdeius created this revision. curdeius added reviewers: MyDeveloperDay, HazardyKnusperkeks, owenpan. curdeius requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Fixes https://github.com/llvm/llvm-project/issues/52772. This patch fixes the formatting of the code: auto aaaaaaaaaaaaaaaaaaaaa = {}; auto b = g([] { return; }); which should be left as is, but before this patch was formatted to: auto aaaaaaaaaaaaaaaaaaaaa = {}; auto b = g([] { return; }); Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D115972 Files: clang/lib/Format/WhitespaceManager.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -16110,6 +16110,13 @@ "int yy = 1; ///specificlennospace\n" "int zzz = 2;\n", Alignment)); + + Alignment.AllowShortLambdasOnASingleLine = FormatStyle::SLS_None; + verifyFormat("auto aaaaaaaaaaaaaaaaaaaaa = {};\n" + "auto b = g([] {\n" + " return;\n" + "});", + Alignment); } TEST_F(FormatTest, AlignConsecutiveBitFields) { Index: clang/lib/Format/WhitespaceManager.cpp =================================================================== --- clang/lib/Format/WhitespaceManager.cpp +++ clang/lib/Format/WhitespaceManager.cpp @@ -346,8 +346,12 @@ // Continued function call if (ScopeStart > Start + 1 && Changes[ScopeStart - 2].Tok->is(tok::identifier) && - Changes[ScopeStart - 1].Tok->is(tok::l_paren)) + Changes[ScopeStart - 1].Tok->is(tok::l_paren)) { + if (Changes[i].Tok->MatchingParen && + Changes[i].Tok->MatchingParen->is(TT_LambdaLBrace)) + return false; return Style.BinPackArguments; + } // Ternary operator if (Changes[i].Tok->is(TT_ConditionalExpr))
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -16110,6 +16110,13 @@ "int yy = 1; ///specificlennospace\n" "int zzz = 2;\n", Alignment)); + + Alignment.AllowShortLambdasOnASingleLine = FormatStyle::SLS_None; + verifyFormat("auto aaaaaaaaaaaaaaaaaaaaa = {};\n" + "auto b = g([] {\n" + " return;\n" + "});", + Alignment); } TEST_F(FormatTest, AlignConsecutiveBitFields) { Index: clang/lib/Format/WhitespaceManager.cpp =================================================================== --- clang/lib/Format/WhitespaceManager.cpp +++ clang/lib/Format/WhitespaceManager.cpp @@ -346,8 +346,12 @@ // Continued function call if (ScopeStart > Start + 1 && Changes[ScopeStart - 2].Tok->is(tok::identifier) && - Changes[ScopeStart - 1].Tok->is(tok::l_paren)) + Changes[ScopeStart - 1].Tok->is(tok::l_paren)) { + if (Changes[i].Tok->MatchingParen && + Changes[i].Tok->MatchingParen->is(TT_LambdaLBrace)) + return false; return Style.BinPackArguments; + } // Ternary operator if (Changes[i].Tok->is(TT_ConditionalExpr))
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits