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());

llvm-svn: 176952
This commit is contained in:
Daniel Jasper 2013-03-13 15:37:48 +00:00
parent 62b85b9610
commit 8f6ae19129
2 changed files with 5 additions and 1 deletions

View File

@ -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.

View File

@ -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;