diff options
author | Daniel Jasper <djasper@google.com> | 2013-12-16 07:23:08 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-12-16 07:23:08 +0000 |
commit | c39b56fe14683957bae2248dd0433ee4c893e054 (patch) | |
tree | d593b279ae1e28a7d7c05c77a18cb6119ff687e9 /clang/lib/Format/ContinuationIndenter.cpp | |
parent | 69b899a1279d20b028f50dbf83b412b42bf095e4 (diff) | |
download | bcm5719-llvm-c39b56fe14683957bae2248dd0433ee4c893e054.tar.gz bcm5719-llvm-c39b56fe14683957bae2248dd0433ee4c893e054.zip |
clang-format: Improve handling of raw string literals.
Especially try to keep existing line breaks before raw string literals,
as the code author might have aligned content to it.
Thereby, clang-format now keeps things like:
parseStyle(R"(
BasedOnStyle: Google,
ColumnLimit: 100)");
parseStyle(
R"(BasedOnStyle: Google,
ColumnLimit: 100)");
llvm-svn: 197368
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index c2122ffb7d3..e63f72d65e6 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -136,7 +136,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { if (Style.AlwaysBreakBeforeMultilineStrings && State.Column > State.Stack.back().Indent && // Breaking saves columns. !Previous.isOneOf(tok::kw_return, tok::lessless, tok::at) && - Previous.Type != TT_InlineASMColon && NextIsMultilineString(State)) + Previous.Type != TT_InlineASMColon && nextIsMultilineString(State)) return true; if (((Previous.Type == TT_DictLiteral && Previous.is(tok::l_brace)) || Previous.Type == TT_ArrayInitializerLSquare) && @@ -865,12 +865,13 @@ unsigned ContinuationIndenter::getColumnLimit(const LineState &State) const { return Style.ColumnLimit - (State.Line->InPPDirective ? 2 : 0); } -bool ContinuationIndenter::NextIsMultilineString(const LineState &State) { +bool ContinuationIndenter::nextIsMultilineString(const LineState &State) { const FormatToken &Current = *State.NextToken; if (!Current.is(tok::string_literal)) return false; // We never consider raw string literals "multiline" for the purpose of - // AlwaysBreakBeforeMultilineStrings implementation. + // AlwaysBreakBeforeMultilineStrings implementation as they are special-cased + // (see TokenAnnotator::mustBreakBefore(). if (Current.TokenText.startswith("R\"")) return false; if (Current.IsMultiline) |