diff options
author | Daniel Jasper <djasper@google.com> | 2013-03-13 15:37:48 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-03-13 15:37:48 +0000 |
commit | 8d0d19aa33751d89390e6a2bb2c2b19def287abe (patch) | |
tree | 8a8b155a9358a998aea13d5a8fdf9dc7195b734e | |
parent | e74de28ec3692986f3467a7f160a0e293277fa7e (diff) |
Fix formatting issue with builder-type calls.
Before:
->aaaaaa()->aaaaaaaaaaa(aaaaaaaa()->aaaaaa()->aaaaa() - aaaaaaaaa()->aaaaaa()
->aaaaa());
After:
a->aaaaaa()->aaaaaaaaaaa(aaaaaaaa()->aaaaaa()->aaaaa() -
aaaaaaaaa()->aaaaaa()->aaaaa());
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176952 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Format/TokenAnnotator.cpp | 2 | ||||
-rw-r--r-- | unittests/Format/FormatTest.cpp | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index ac127160d1..67ad86b624 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -894,7 +894,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line, if (Right.isOneOf(tok::arrow, tok::period)) { if (Line.Type == LT_BuilderTypeCall) - return 5; + return 14; if (Left.isOneOf(tok::r_paren, tok::r_square) && Left.MatchingParen && Left.MatchingParen->ParameterCount > 0) return 20; // Should be smaller than breaking at a nested comma. diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index fed50f9681..79163a6818 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -1664,6 +1664,10 @@ TEST_F(FormatTest, WrapsAtFunctionCallsIfNecessary) { verifyFormat( "aaaaaaaaaaaaaaaaaaaaaaaaa(\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa().aaaaaaaaaaaaaaaaa());"); + verifyFormat("a->aaaaaa()->aaaaaaaaaaa(aaaaaaaa()->aaaaaa()->aaaaa() *\n" + " aaaaaaaaa()->aaaaaa()->aaaaa());"); + verifyFormat("a->aaaaaa()->aaaaaaaaaaa(aaaaaaaa()->aaaaaa()->aaaaa() ||\n" + " aaaaaaaaa()->aaaaaa()->aaaaa());"); FormatStyle NoBinPacking = getLLVMStyle(); NoBinPacking.BinPackParameters = false; |