summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-01-20 12:59:20 +0000
committerDaniel Jasper <djasper@google.com>2015-01-20 12:59:20 +0000
commit6fd5d646cc08b5e1d4c8e41d47c790cad5564667 (patch)
tree73a3acde267a8aa34ac08521f85488435542f1de
parentfbeb7e65d9037973dc2caef9a1e831b80d421fc6 (diff)
downloadbcm5719-llvm-6fd5d646cc08b5e1d4c8e41d47c790cad5564667.tar.gz
bcm5719-llvm-6fd5d646cc08b5e1d4c8e41d47c790cad5564667.zip
clang-format: Fix AlwaysBreakBeforeMultilineStrings with ColumnLimit=0
Before: const char *x = "hello llvm"; After: const char *x = "hello llvm"; This fixes llvm.org/PR22245. Patch by Bill Meltsner, thank you! llvm-svn: 226564
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp5
-rw-r--r--clang/unittests/Format/FormatTest.cpp3
2 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 7cf1c844678..c08c138e1b2 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1081,8 +1081,9 @@ bool ContinuationIndenter::nextIsMultilineString(const LineState &State) {
if (Current.getNextNonComment() &&
Current.getNextNonComment()->isStringLiteral())
return true; // Implicit concatenation.
- if (State.Column + Current.ColumnWidth + Current.UnbreakableTailLength >
- Style.ColumnLimit)
+ if (Style.ColumnLimit != 0 &&
+ State.Column + Current.ColumnWidth + Current.UnbreakableTailLength >
+ Style.ColumnLimit)
return true; // String will be split.
return false;
}
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 615b46a1d4e..436835b76ca 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -4611,6 +4611,9 @@ TEST_F(FormatTest, AlwaysBreakBeforeMultilineStrings) {
format("NSString *const kString = @\"aaaa\"\n"
"\"bbbb\";",
Break));
+
+ Break.ColumnLimit = 0;
+ verifyFormat("const char *hello = \"hello llvm\";", Break);
}
TEST_F(FormatTest, AlignsPipes) {
OpenPOWER on IntegriCloud