summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2016-03-01 04:19:59 +0000
committerDaniel Jasper <djasper@google.com>2016-03-01 04:19:59 +0000
commit04b4e10873f6728f382ce2e2aa71aa10831c101f (patch)
tree092404937dd77521cf00b9850f3d7a1c75a615ab /clang
parentf9168de892634832f25c9dd91462ed8236782f81 (diff)
downloadbcm5719-llvm-04b4e10873f6728f382ce2e2aa71aa10831c101f.tar.gz
bcm5719-llvm-04b4e10873f6728f382ce2e2aa71aa10831c101f.zip
clang-format: Correctly apply wrap before multi-line RHS rule to
ternary expressions. Before: return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? aaaaa : bbbbbbbbbbbbbbb + cccccccccccccccc; After: return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? aaaaa : bbbbbbbbbbbbbbb + cccccccccccccccc; llvm-svn: 262293
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp2
-rw-r--r--clang/unittests/Format/FormatTest.cpp4
2 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index b9afe117bc1..4e5a29426a2 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -847,7 +847,7 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
// there is a line-break right after the operator.
// Exclude relational operators, as there, it is always more desirable to
// have the LHS 'left' of the RHS.
- if (Previous && Previous->getPrecedence() > prec::Assignment &&
+ if (Previous && Previous->getPrecedence() != prec::Assignment &&
Previous->isOneOf(TT_BinaryOperator, TT_ConditionalExpr) &&
Previous->getPrecedence() != prec::Relational) {
bool BreakBeforeOperator =
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index b00b895c5f8..164909f8688 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -4708,6 +4708,10 @@ TEST_F(FormatTest, BreaksConditionalExpressionsAfterOperator) {
" /*bbbbbbbbbbbbbbb=*/bbbbbbbbbbbbbbbbbbbbbbbbb :\n"
" ccccccccccccccccccccccccccc;",
Style);
+ verifyFormat("return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ?\n"
+ " aaaaa :\n"
+ " bbbbbbbbbbbbbbb + cccccccccccccccc;",
+ Style);
}
TEST_F(FormatTest, DeclarationsOfMultipleVariables) {
OpenPOWER on IntegriCloud