From c39b56fe14683957bae2248dd0433ee4c893e054 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 16 Dec 2013 07:23:08 +0000 Subject: 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 --- clang/lib/Format/ContinuationIndenter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'clang/lib/Format/ContinuationIndenter.cpp') 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) -- cgit v1.2.3