diff options
| author | Daniel Jasper <djasper@google.com> | 2017-02-02 08:30:21 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2017-02-02 08:30:21 +0000 |
| commit | c3aa05c01be2661cb3583f47aa7265ec366906e6 (patch) | |
| tree | 1311b4c0effc9e5d31fc9f60b20adec0df580f7d | |
| parent | 3b008536f3c8d398f4359f4c47e4a9721b11ad08 (diff) | |
| download | bcm5719-llvm-c3aa05c01be2661cb3583f47aa7265ec366906e6.tar.gz bcm5719-llvm-c3aa05c01be2661cb3583f47aa7265ec366906e6.zip | |
clang-format: Do not use two-argument/operand special case with no alignment
Without alignment, there is no clean separation between the arguments, even if
there are only two.
Before:
aaaaaaaaaaaaaa(
aaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
aaaaaaaaaaaaaa(aaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
llvm-svn: 293875
| -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" |

