aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-02-26 13:59:14 +0000
committerDaniel Jasper <djasper@google.com>2013-02-26 13:59:14 +0000
commit518ee34467c0722e253a58efea20456e96aa5802 (patch)
tree1d7ee2ec9d3370e219d3217a141e4e846cbf5955
parentd79f1f37b04703addb631ee11d266d3bfc3dd451 (diff)
Fix bad line break decision.
Before: if (Intervals[i].getRange().getFirst() < Intervals[i - 1] .getRange().getLast()) {} After: if (Intervals[i].getRange().getFirst() < Intervals[i - 1].getRange().getLast()) {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176092 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Format/TokenAnnotator.cpp6
-rw-r--r--unittests/Format/FormatTest.cpp2
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index 83e1facb21..67ad08a389 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -890,10 +890,10 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
if (Right.is(tok::arrow) || Right.is(tok::period)) {
if (Line.Type == LT_BuilderTypeCall)
- return 5; // Should be smaller than breaking at a nested comma.
+ return 5;
if ((Left.is(tok::r_paren) || Left.is(tok::r_square)) &&
Left.MatchingParen && Left.MatchingParen->ParameterCount > 0)
- return 10;
+ return 20; // Should be smaller than breaking at a nested comma.
return 150;
}
@@ -928,7 +928,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
return prec::Shift;
}
if (Left.Type == TT_ConditionalExpr)
- return prec::Assignment;
+ return prec::Conditional;
prec::Level Level = getPrecedence(Left);
if (Level != prec::Unknown)
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 9e777c66e9..4fe4595574 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -1185,6 +1185,8 @@ TEST_F(FormatTest, BreaksAsHighAsPossible) {
"if ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaaaaaaaa) ||\n"
" (bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && bbbbbbbbbbbbbbbbbbbbbbbbbb))\n"
" f();");
+ verifyFormat("if (Intervals[i].getRange().getFirst() <\n"
+ " Intervals[i - 1].getRange().getLast()) {\n}");
}
TEST_F(FormatTest, BreaksDesireably) {