Author: djasper Date: Thu Jan 12 14:06:28 2017 New Revision: 291807 URL: http://llvm.org/viewvc/llvm-project?rev=291807&view=rev Log: clang-format: Fix regression introduced by r291801.
Uncovered by polly tests. Before: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaa, {}, aaaaaaaaaaaaaaaaaaaaaaa); After: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaa, {}, aaaaaaaaaaaaaaaaaaaaaaa); Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp cfe/trunk/unittests/Format/FormatTest.cpp Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=291807&r1=291806&r2=291807&view=diff ============================================================================== --- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original) +++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Thu Jan 12 14:06:28 2017 @@ -930,13 +930,6 @@ void ContinuationIndenter::moveStatePast return; } - const FormatToken *Previous = Current.getPreviousNonComment(); - if (Previous && Previous->is(tok::comma) && - !Previous->is(TT_OverloadedOperator)) { - if (!Newline) - State.Stack.back().NoLineBreak = true; - } - unsigned NewIndent; unsigned NewIndentLevel = State.Stack.back().IndentLevel; unsigned LastSpace = State.Stack.back().LastSpace; @@ -1010,12 +1003,15 @@ void ContinuationIndenter::moveStatePast // Generally inherit NoLineBreak from the current scope to nested scope. // However, don't do this for non-empty nested blocks, dict literals and // array literals as these follow different indentation rules. + const FormatToken *Previous = Current.getPreviousNonComment(); bool NoLineBreak = Current.Children.empty() && !Current.isOneOf(TT_DictLiteral, TT_ArrayInitializerLSquare) && (State.Stack.back().NoLineBreak || (Current.is(TT_TemplateOpener) && - State.Stack.back().ContainsUnwrappedBuilder)); + State.Stack.back().ContainsUnwrappedBuilder) || + (Current.is(tok::l_brace) && !Newline && Previous && + Previous->is(tok::comma))); State.Stack.push_back(ParenState(NewIndent, NewIndentLevel, LastSpace, AvoidBinPacking, NoLineBreak)); State.Stack.back().NestedBlockIndent = NestedBlockIndent; Modified: cfe/trunk/unittests/Format/FormatTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=291807&r1=291806&r2=291807&view=diff ============================================================================== --- cfe/trunk/unittests/Format/FormatTest.cpp (original) +++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Jan 12 14:06:28 2017 @@ -6822,6 +6822,8 @@ TEST_F(FormatTest, FormatsBracedListsInC " {List1, List2,\n" " List3});", getLLVMStyleWithColumns(35)); + verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaa, {},\n" + " aaaaaaaaaaaaaaaaaaaaaaa);"); } TEST_F(FormatTest, PullTrivialFunctionDefinitionsIntoSingleLine) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits