summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2016-12-22 12:37:06 +0000
committerDaniel Jasper <djasper@google.com>2016-12-22 12:37:06 +0000
commit2388861f093c4f3cde7fb86814c01d8046c6824d (patch)
tree77eefe1e93548a2501c81ca7698dfba83d651957 /clang
parenta6792a39c4ce9250eb75d42cf14616b6da56f7a0 (diff)
downloadbcm5719-llvm-2388861f093c4f3cde7fb86814c01d8046c6824d.tar.gz
bcm5719-llvm-2388861f093c4f3cde7fb86814c01d8046c6824d.zip
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
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp2
-rw-r--r--clang/unittests/Format/FormatTest.cpp4
2 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 7f573061594..cf6373f4565 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -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;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 09b85357d15..6f9df680eef 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -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) {
OpenPOWER on IntegriCloud