diff options
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 3 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 6 |
2 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index e74515eb3b3..2117a0ec93c 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -523,7 +523,8 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, Style.ContinuationIndentWidth; } - if ((Previous.isOneOf(tok::comma, tok::semi) && + if ((PreviousNonComment && + PreviousNonComment->isOneOf(tok::comma, tok::semi) && !State.Stack.back().AvoidBinPacking) || Previous.is(TT_BinaryOperator)) State.Stack.back().BreakBeforeParameter = false; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index e8e36abe681..a1614df6f38 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1137,6 +1137,12 @@ TEST_F(FormatTest, KeepsParameterWithTrailingCommentsOnTheirOwnLine) { format("SomeFunction(a, // comment\n" " b,\n" " c); // comment")); + EXPECT_EQ("aaaaaaaaaa(aaaa(aaaa,\n" + " aaaa), //\n" + " aaaa, bbbbb);", + format("aaaaaaaaaa(aaaa(aaaa,\n" + "aaaa), //\n" + "aaaa, bbbbb);")); } TEST_F(FormatTest, RemovesTrailingWhitespaceOfComments) { |