From faa3c986ea1efdf9353d6d74fa4ef752cc91b5d2 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Thu, 18 Jun 2015 16:05:17 +0000 Subject: [PATCH] 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 --- lib/Format/ContinuationIndenter.cpp | 3 ++- unittests/Format/FormatTest.cpp | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) 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. -- 2.40.0