Added AlwaysBreakBeforeMultilineStrings option.
Summary:
Always breaking before multiline strings can help format complex
expressions containing multiline strings more consistently, and avoid consuming
too much horizontal space.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D1097
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185622 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index 04f1c7f..806c805 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -936,6 +936,13 @@
} else if (Current->Previous->ClosesTemplateDeclaration &&
Style.AlwaysBreakTemplateDeclarations) {
Current->MustBreakBefore = true;
+ } else if (Style.AlwaysBreakBeforeMultilineStrings &&
+ Current->is(tok::string_literal) &&
+ Current->Previous->isNot(tok::lessless) &&
+ Current->Previous->Type != TT_InlineASMColon &&
+ Current->getNextNoneComment() &&
+ Current->getNextNoneComment()->is(tok::string_literal)) {
+ Current->MustBreakBefore = true;
} else {
Current->MustBreakBefore = false;
}