r290337 - clang-format: Less eagerly try to keep label-value pairs on a line.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 22 04:37:06 PST 2016
Author: djasper
Date: Thu Dec 22 06:37:06 2016
New Revision: 290337
URL: http://llvm.org/viewvc/llvm-project?rev=290337&view=rev
Log:
clang-format: Less eagerly try to keep label-value pairs on a line.
Before:
string v =
StrCat("aaaaaaaaaaaaaaaaaaaaaaaaaaa: ", SomeFunction(aaaaaaaaaaaa,
aaaaaaaaaaaaaaa),
bbbbbbbbbbbbbbbbbbbbbbb);
After:
string v = StrCat("aaaaaaaaaaaaaaaaaaaaaaaaaaa: ",
SomeFunction(aaaaaaaaaaaa, aaaaaaaaaaaaaaa),
bbbbbbbbbbbbbbbbbbbbbbb);
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=290337&r1=290336&r2=290337&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Dec 22 06:37:06 2016
@@ -2001,7 +2001,7 @@ unsigned TokenAnnotator::splitPenalty(co
if (Left.isOneOf(tok::plus, tok::comma) && Left.Previous &&
Left.Previous->isLabelString() &&
(Left.NextOperator || Left.OperatorIndex != 0))
- return 100;
+ return 45;
if (Right.is(tok::plus) && Left.isLabelString() &&
(Right.NextOperator || Right.OperatorIndex != 0))
return 25;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=290337&r1=290336&r2=290337&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Dec 22 06:37:06 2016
@@ -5220,6 +5220,10 @@ TEST_F(FormatTest, KeepStringLabelValueP
verifyFormat("string v = StrCat(\"aaaaaaaaaaaa: \" +\n"
" (aaaaaaa + aaaaa));",
getLLVMStyleWithColumns(40));
+ verifyFormat(
+ "string v = StrCat(\"aaaaaaaaaaaaaaaaaaaaaaaaaaa: \",\n"
+ " SomeFunction(aaaaaaaaaaaa, aaaaaaaa.aaaaaaa),\n"
+ " bbbbbbbbbbbbbbbbbbbbbbb);");
}
TEST_F(FormatTest, UnderstandsEquals) {
More information about the cfe-commits
mailing list