This revision was automatically updated to reflect the committed changes. Closed by commit rGa8b8bd0f8d55: [clang-format] Fix a bug causing BeforeLambdaBody to affect brace initialiser… (authored by MyDeveloperDay).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79022/new/ https://reviews.llvm.org/D79022 Files: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -8395,6 +8395,17 @@ format("vector<int> SomeVector = { // aaa\n" " 1, 2, };")); + // C++11 brace initializer list l-braces should not be treated any differently + // when breaking before lambda bodies is enabled + FormatStyle BreakBeforeLambdaBody = getLLVMStyle(); + BreakBeforeLambdaBody.BreakBeforeBraces = FormatStyle::BS_Custom; + BreakBeforeLambdaBody.BraceWrapping.BeforeLambdaBody = true; + BreakBeforeLambdaBody.AlwaysBreakBeforeMultilineStrings = true; + verifyFormat( + "std::runtime_error{\n" + " \"Long string which will force a break onto the next line...\"};", + BreakBeforeLambdaBody); + FormatStyle ExtraSpaces = getLLVMStyle(); ExtraSpaces.Cpp11BracedListStyle = false; ExtraSpaces.ColumnLimit = 75; Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -3938,7 +3938,7 @@ Right.isMemberAccess() || Right.isOneOf(TT_TrailingReturnArrow, TT_LambdaArrow, tok::lessless, tok::colon, tok::l_square, tok::at) || - (Style.BraceWrapping.BeforeLambdaBody && Right.is(tok::l_brace)) || + (Style.BraceWrapping.BeforeLambdaBody && Right.is(TT_LambdaLBrace)) || (Left.is(tok::r_paren) && Right.isOneOf(tok::identifier, tok::kw_const)) || (Left.is(tok::l_paren) && !Right.is(tok::r_paren)) ||
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -8395,6 +8395,17 @@ format("vector<int> SomeVector = { // aaa\n" " 1, 2, };")); + // C++11 brace initializer list l-braces should not be treated any differently + // when breaking before lambda bodies is enabled + FormatStyle BreakBeforeLambdaBody = getLLVMStyle(); + BreakBeforeLambdaBody.BreakBeforeBraces = FormatStyle::BS_Custom; + BreakBeforeLambdaBody.BraceWrapping.BeforeLambdaBody = true; + BreakBeforeLambdaBody.AlwaysBreakBeforeMultilineStrings = true; + verifyFormat( + "std::runtime_error{\n" + " \"Long string which will force a break onto the next line...\"};", + BreakBeforeLambdaBody); + FormatStyle ExtraSpaces = getLLVMStyle(); ExtraSpaces.Cpp11BracedListStyle = false; ExtraSpaces.ColumnLimit = 75; Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -3938,7 +3938,7 @@ Right.isMemberAccess() || Right.isOneOf(TT_TrailingReturnArrow, TT_LambdaArrow, tok::lessless, tok::colon, tok::l_square, tok::at) || - (Style.BraceWrapping.BeforeLambdaBody && Right.is(tok::l_brace)) || + (Style.BraceWrapping.BeforeLambdaBody && Right.is(TT_LambdaLBrace)) || (Left.is(tok::r_paren) && Right.isOneOf(tok::identifier, tok::kw_const)) || (Left.is(tok::l_paren) && !Right.is(tok::r_paren)) ||
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits