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

llvm-svn: 290337
This commit is contained in:
Daniel Jasper 2016-12-22 12:37:06 +00:00
parent a6792a39c4
commit 2388861f09
2 changed files with 5 additions and 1 deletions

View File

@ -2001,7 +2001,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
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;

View File

@ -5220,6 +5220,10 @@ TEST_F(FormatTest, KeepStringLabelValuePairsOnALine) {
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) {