diff options
author | Daniel Jasper <djasper@google.com> | 2016-02-11 13:15:14 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2016-02-11 13:15:14 +0000 |
commit | 602a727adda6c96c89d4d68d8f76d0e724a3b56d (patch) | |
tree | df7633ca9f2b22c557283dcd0e10783ce5b450a2 /clang/lib/Format | |
parent | daed67fffe1e3d8f09f1a84a76059c74765a960c (diff) | |
download | bcm5719-llvm-602a727adda6c96c89d4d68d8f76d0e724a3b56d.tar.gz bcm5719-llvm-602a727adda6c96c89d4d68d8f76d0e724a3b56d.zip |
clang-format: Make indentation after "<<" more consistent.
Before:
Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa)
<< aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa)
<< aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
<< aaa;
After:
Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa)
<< aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa)
<< aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
<< aaa;
llvm-svn: 260517
Diffstat (limited to 'clang/lib/Format')
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 1c721ff6520..b9afe117bc1 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -402,9 +402,9 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, (Previous.isNot(tok::lessless) || Previous.OperatorIndex != 0 || Previous.NextOperator)) || Current.StartsBinaryExpression)) { - // Always indent relative to the RHS of the expression unless this is a - // simple assignment without binary expression on the RHS. Also indent - // relative to unary operators and the colons of constructor initializers. + // Indent relative to the RHS of the expression unless this is a simple + // assignment without binary expression on the RHS. Also indent relative to + // unary operators and the colons of constructor initializers. State.Stack.back().LastSpace = State.Column; } else if (Previous.is(TT_InheritanceColon)) { State.Stack.back().Indent = State.Column; @@ -531,6 +531,12 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, if (!Current.isTrailingComment()) State.Stack.back().LastSpace = State.Column; + if (Current.is(tok::lessless)) + // If we are breaking before a "<<", we always want to indent relative to + // RHS. This is necessary only for "<<", as we special-case it and don't + // always indent relative to the RHS. + State.Stack.back().LastSpace += 3; // 3 -> width of "<< ". + State.StartOfLineLevel = Current.NestingLevel; State.LowestLevelOnLine = Current.NestingLevel; |