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
This commit is contained in:
Daniel Jasper 2015-06-18 16:05:17 +00:00
parent 2b2cdd7799
commit 1bf729cee1
2 changed files with 11 additions and 5 deletions

View File

@ -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))

View File

@ -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, L\"bbbb\"\n"
" L\"cccc\");",
verifyFormat("aaaa(qqq,\n"
" L\"bbbb\"\n"
" L\"cccc\");",
Break);
verifyFormat("aaaaa(aaaaaa, aaaaaaa(\"aaaa\"\n"
" \"bbbb\"));",
Break);
// As we break before unary operators, breaking right after them is bad.