From: Daniel Jasper Date: Thu, 18 Jun 2015 16:05:17 +0000 (+0000) Subject: clang-format: Row back on the AlwaysBreakBeforeMultilineStrings change. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=faa3c986ea1efdf9353d6d74fa4ef752cc91b5d2;p=clang clang-format: Row back on the AlwaysBreakBeforeMultilineStrings change. It was a bit too aggressive. With this patch, we keep on breaking here: aaaaaaaaaaaaa(aaaaaaa, "aaaaaaa" "bbbbbbb"); But don't break in: aaaaaaaaaaaaa(aaaaaaa, aaaaaaaa("aaaaaaa" "bbbbbbb")); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240024 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index c41da01256..dea622706f 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -169,7 +169,8 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { return false; if (Style.AlwaysBreakBeforeMultilineStrings && - NewLineColumn == State.FirstIndent + Style.ContinuationIndentWidth && + (NewLineColumn == State.FirstIndent + Style.ContinuationIndentWidth || + Previous.is(tok::comma)) && !Previous.isOneOf(tok::kw_return, tok::lessless, tok::at) && !Previous.isOneOf(TT_InlineASMColon, TT_ConditionalExpr) && nextIsMultilineString(State)) diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 122a1a6c5f..418b7aceea 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -4647,11 +4647,16 @@ TEST_F(FormatTest, AlwaysBreakBeforeMultilineStrings) { verifyFormat("aaaa(qqq, \"bbbb\"\n" " \"cccc\");", NoBreak); - verifyFormat("aaaa(qqq, \"bbbb\"\n" - " \"cccc\");", + verifyFormat("aaaa(qqq,\n" + " \"bbbb\"\n" + " \"cccc\");", + Break); + verifyFormat("aaaa(qqq,\n" + " L\"bbbb\"\n" + " L\"cccc\");", Break); - verifyFormat("aaaa(qqq, L\"bbbb\"\n" - " L\"cccc\");", + verifyFormat("aaaaa(aaaaaa, aaaaaaa(\"aaaa\"\n" + " \"bbbb\"));", Break); // As we break before unary operators, breaking right after them is bad.