r256750 - clang-format: Fix corner case in builder-type call formatting.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 4 04:41:27 PST 2016
Author: djasper
Date: Mon Jan 4 06:41:11 2016
New Revision: 256750
URL: http://llvm.org/viewvc/llvm-project?rev=256750&view=rev
Log:
clang-format: Fix corner case in builder-type call formatting.
Before:
return aaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaa)
.aaaa(aaaaaaaaaaaaaa);
After:
return aaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa)
.aaaa(aaaaaaaaaaaaaa);
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=256750&r1=256749&r2=256750&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jan 4 06:41:11 2016
@@ -1769,7 +1769,7 @@ unsigned TokenAnnotator::splitPenalty(co
// which might otherwise be blown up onto many lines. Here, clang-format
// won't produce "hanging" indents anyway as there is no other trailing
// call.
- return Right.LastOperator ? 150 : 40;
+ return Right.LastOperator ? 150 : 35;
}
if (Right.is(TT_TrailingAnnotation) &&
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=256750&r1=256749&r2=256750&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jan 4 06:41:11 2016
@@ -4165,6 +4165,10 @@ TEST_F(FormatTest, FormatsBuilderPattern
" ->aaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"
" ->aaaaaaaa(aaaaaaaaaaaaaaa);");
verifyFormat(
+ "return aaaaaaaaaaaaaaaa\n"
+ " .aaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa)\n"
+ " .aaaa(aaaaaaaaaaaaaa);");
+ verifyFormat(
"aaaaaaaaaaaaaaaaaaa()->aaaaaa(bbbbb)->aaaaaaaaaaaaaaaaaaa( // break\n"
" aaaaaaaaaaaaaa);");
verifyFormat(
More information about the cfe-commits
mailing list