Improve line breaking before multi-line strings.
The AlwaysBreakBeforeMultilineStrings rule does not really make sense
if it does not a column gain.
Before (in Google style):
f(
"aaaa"
"bbbb");
After:
f("aaaa"
"bbbb");
llvm-svn: 186515
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 125283a..a4495ba 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1177,6 +1177,14 @@
!Current.isTrailingComment() &&
!Current.isOneOf(tok::r_paren, tok::r_brace))
return true;
+ if (Style.AlwaysBreakBeforeMultilineStrings &&
+ State.Column > State.Stack.back().Indent &&
+ Current.is(tok::string_literal) && Previous.isNot(tok::lessless) &&
+ Previous.Type != TT_InlineASMColon &&
+ ((Current.getNextNonComment() &&
+ Current.getNextNonComment()->is(tok::string_literal)) ||
+ (Current.TokenText.find("\\\n") != StringRef::npos)))
+ return true;
// If we need to break somewhere inside the LHS of a binary expression, we
// should also break after the operator. Otherwise, the formatting would