diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 7cf1c8446785..c08c138e1b2e 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 615b46a1d4ee..436835b76ca6 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) {