r175441 - Improve formatting of builder-type calls.
Daniel Jasper
djasper at google.com
Mon Feb 18 05:24:22 PST 2013
Author: djasper
Date: Mon Feb 18 07:24:21 2013
New Revision: 175441
URL: http://llvm.org/viewvc/llvm-project?rev=175441&view=rev
Log:
Improve formatting of builder-type calls.
Before:
aaaaaaa->aaaaaaa->aaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)->aaaaaaaa(aaaaaaaaaaaaaaa);
After:
aaaaaaa->aaaaaaa
->aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
->aaaaaaaa(aaaaaaaaaaaaaaa);
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=175441&r1=175440&r2=175441&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Feb 18 07:24:21 2013
@@ -874,7 +874,7 @@ unsigned TokenAnnotator::splitPenalty(co
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)
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=175441&r1=175440&r2=175441&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Feb 18 07:24:21 2013
@@ -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) {
More information about the cfe-commits
mailing list