diff options
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index a7eb82ad56f..3a100651cab 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -429,7 +429,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, // does not help. bool HasTwoOperands = P->OperatorIndex == 0 && !P->NextOperator && !P->is(TT_ConditionalExpr); - if ((!BreakBeforeOperator && !HasTwoOperands) || + if ((!BreakBeforeOperator && !(HasTwoOperands && Style.AlignOperands)) || (!State.Stack.back().LastOperatorWrapped && BreakBeforeOperator)) State.Stack.back().NoLineBreakInOperand = true; } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index cb0d7b32972..1a11425be21 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -4163,6 +4163,10 @@ TEST_F(FormatTest, EnforcedOperatorWraps) { TEST_F(FormatTest, NoOperandAlignment) { FormatStyle Style = getLLVMStyle(); Style.AlignOperands = false; + verifyFormat("aaaaaaaaaaaaaa(aaaaaaaaaaaa,\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);", + Style); Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment; verifyFormat("bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" " + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" |