From be285ccf09bee2c343750cb3386b8e00751ccdad Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 20 Jan 2015 12:59:20 +0000 Subject: [PATCH] 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! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226564 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/ContinuationIndenter.cpp | 5 +++-- unittests/Format/FormatTest.cpp | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index 7cf1c84467..c08c138e1b 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/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/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 615b46a1d4..436835b76c 100644 --- a/unittests/Format/FormatTest.cpp +++ b/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) { -- 2.40.0