r240024 - clang-format: Row back on the AlwaysBreakBeforeMultilineStrings change.
Daniel Jasper
djasper at google.com
Thu Jun 18 09:05:18 PDT 2015
Author: djasper
Date: Thu Jun 18 11:05:17 2015
New Revision: 240024
URL: http://llvm.org/viewvc/llvm-project?rev=240024&view=rev
Log:
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"));
Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=240024&r1=240023&r2=240024&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Thu Jun 18 11:05:17 2015
@@ -169,7 +169,8 @@ bool ContinuationIndenter::mustBreak(con
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))
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=240024&r1=240023&r2=240024&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Jun 18 11:05:17 2015
@@ -4647,11 +4647,16 @@ TEST_F(FormatTest, AlwaysBreakBeforeMult
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.
More information about the cfe-commits
mailing list