From: Daniel Jasper Date: Thu, 18 Jun 2015 16:05:17 +0000 (+0000) Subject: clang-format: Row back on the AlwaysBreakBeforeMultilineStrings change. X-Git-Tag: llvmorg-3.7.0-rc1~2086 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1bf729cee136a5f4422dbed0417eab494960e9b6;p=platform%2Fupstream%2Fllvm.git 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")); llvm-svn: 240024 --- diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index c41da01..dea6227 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 122a1a6..418b7ac 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/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.