diff options
| author | Daniel Jasper <djasper@google.com> | 2015-06-19 10:32:28 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2015-06-19 10:32:28 +0000 |
| commit | 9fb676a2543434ed0df96649195a0529b23a8dea (patch) | |
| tree | 649e0f04abad94f4664dad05375b978b0215272a | |
| parent | c105a9a16e6b3c09ac4f0a589ca0b203aa5d3339 (diff) | |
| download | bcm5719-llvm-9fb676a2543434ed0df96649195a0529b23a8dea.tar.gz bcm5719-llvm-9fb676a2543434ed0df96649195a0529b23a8dea.zip | |
clang-format: Make exception to AlwaysBreakBeforeMultilineStrings more
conservative.
In particular, this fixes an unwanted corner case.
Before:
string s =
someFunction("aaaa"
"bbbb");
After:
string s = someFunction(
"aaaa"
"bbbb");
llvm-svn: 240129
| -rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 2 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index dea622706fe..2357abd7abd 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -170,7 +170,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { if (Style.AlwaysBreakBeforeMultilineStrings && (NewLineColumn == State.FirstIndent + Style.ContinuationIndentWidth || - Previous.is(tok::comma)) && + Previous.is(tok::comma) || Current.NestingLevel < 2) && !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 30bc5b2cd1d..ed2658b3c14 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -4662,6 +4662,10 @@ TEST_F(FormatTest, AlwaysBreakBeforeMultilineStrings) { verifyFormat("aaaaa(aaaaaa, aaaaaaa(\"aaaa\"\n" " \"bbbb\"));", Break); + verifyFormat("string s = someFunction(\n" + " \"abc\"\n" + " \"abc\");", + Break); // As we break before unary operators, breaking right after them is bad. verifyFormat("string foo = abc ? \"x\"\n" |

