Improve formatting of builder-type calls.

Before:
aaaaaaa->aaaaaaa->aaaaaaaaaaaaaaaa(
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)->aaaaaaaa(aaaaaaaaaaaaaaa);

After:
aaaaaaa->aaaaaaa
    ->aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
    ->aaaaaaaa(aaaaaaaaaaaaaaa);

llvm-svn: 175441
This commit is contained in:
Daniel Jasper 2013-02-18 13:24:21 +00:00
parent 55d7ba6b66
commit 9ed9ade0ef
2 changed files with 5 additions and 1 deletions

View File

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

View File

@ -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) {