diff options
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 7 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 6 |
2 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 5dcaf26..7f57306 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2000,11 +2000,14 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line, if (Left.isOneOf(tok::plus, tok::comma) && Left.Previous && Left.Previous->isLabelString() && - (Left.NextOperator || Left.OperatorIndex != 1)) + (Left.NextOperator || Left.OperatorIndex != 0)) return 100; + if (Right.is(tok::plus) && Left.isLabelString() && + (Right.NextOperator || Right.OperatorIndex != 0)) + return 25; if (Left.is(tok::comma)) return 1; - if (Right.isOneOf(tok::lessless, tok::plus) && Left.isLabelString() && + if (Right.is(tok::lessless) && Left.isLabelString() && (Right.NextOperator || Right.OperatorIndex != 1)) return 25; if (Right.is(tok::lessless)) { diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index af78419..27c946e 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -5214,6 +5214,12 @@ TEST_F(FormatTest, KeepStringLabelValuePairsOnALine) { verifyFormat("string v = StrCat(\"aaaaaaaaaaaaaaaa: \", aaaaaaaaaaaaaaaa,\n" " \"aaaaaaaaaaaaaaaa: \", aaaaaaaaaaaaaaaa,\n" " \"aaaaaaaaaaaaaaaa: \", aaaaaaaaaaaaaaaa);"); + verifyFormat("string v = \"aaaaaaaaaaaaaaaa: \" +\n" + " (aaaa + aaaa);", + getLLVMStyleWithColumns(40)); + verifyFormat("string v = StrCat(\"aaaaaaaaaaaa: \" +\n" + " (aaaaaaa + aaaaa));", + getLLVMStyleWithColumns(40)); } TEST_F(FormatTest, UnderstandsEquals) { |