Author: djasper Date: Wed Feb 1 17:27:37 2017 New Revision: 293839 URL: http://llvm.org/viewvc/llvm-project?rev=293839&view=rev Log: clang-format: Fix incorrect line breaks after forced operator wraps.
Before: bool x = aaaaa // || bbbbb // || cccc; After: bool x = aaaaa // || bbbbb // || cccc; 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=293839&r1=293838&r2=293839&view=diff ============================================================================== --- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original) +++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Wed Feb 1 17:27:37 2017 @@ -420,7 +420,7 @@ void ContinuationIndenter::addTokenOnCur P->getPrecedence() != prec::Assignment && P->getPrecedence() != prec::Relational) { bool BreakBeforeOperator = - P->is(tok::lessless) || + P->MustBreakBefore || P->is(tok::lessless) || (P->is(TT_BinaryOperator) && Style.BreakBeforeBinaryOperators != FormatStyle::BOS_None) || (P->is(TT_ConditionalExpr) && Style.BreakBeforeTernaryOperators); Modified: cfe/trunk/unittests/Format/FormatTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=293839&r1=293838&r2=293839&view=diff ============================================================================== --- cfe/trunk/unittests/Format/FormatTest.cpp (original) +++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Feb 1 17:27:37 2017 @@ -4151,6 +4151,15 @@ TEST_F(FormatTest, ExpressionIndentation Style); } +TEST_F(FormatTest, EnforcedOperatorWraps) { + // Here we'd like to wrap after the || operators, but a comment is forcing an + // earlier wrap. + verifyFormat("bool x = aaaaa //\n" + " || bbbbb\n" + " //\n" + " || cccc;"); +} + TEST_F(FormatTest, NoOperandAlignment) { FormatStyle Style = getLLVMStyle(); Style.AlignOperands = false; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits