aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-02-18 13:24:21 +0000
committerDaniel Jasper <djasper@google.com>2013-02-18 13:24:21 +0000
commit515f65df40624a767bc8763a0b6b678146b8e3c9 (patch)
tree4bea66cd52e1b31d685dc6795c4a316ac9e782c2
parent29333160cfd863a451ddb6fd505c3619c3724c95 (diff)
Improve formatting of builder-type calls.
Before: aaaaaaa->aaaaaaa->aaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)->aaaaaaaa(aaaaaaaaaaaaaaa); After: aaaaaaa->aaaaaaa ->aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) ->aaaaaaaa(aaaaaaaaaaaaaaa); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175441 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Format/TokenAnnotator.cpp2
-rw-r--r--unittests/Format/FormatTest.cpp4
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index 19582f2ed2..92c3f1d41c 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -874,7 +874,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
return 5;
if (Right.is(tok::arrow) || Right.is(tok::period)) {
- if (Left.is(tok::r_paren) && Line.Type == LT_BuilderTypeCall)
+ if (Line.Type == LT_BuilderTypeCall)
return 5; // Should be smaller than breaking at a nested comma.
if ((Left.is(tok::r_paren) || Left.is(tok::r_square)) &&
Left.MatchingParen && Left.MatchingParen->ParameterCount > 0)
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 90196afa62..d69b95e766 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -1255,6 +1255,10 @@ TEST_F(FormatTest, FormatsBuilderPattern) {
verifyFormat("return aaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa() <\n"
" aaaaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa();");
+ verifyFormat(
+ "aaaaaaa->aaaaaaa\n"
+ " ->aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"
+ " ->aaaaaaaa(aaaaaaaaaaaaaaa);");
}
TEST_F(FormatTest, DoesNotBreakTrailingAnnotation) {