diff options
author | Daniel Jasper <djasper@google.com> | 2013-09-06 08:08:14 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-09-06 08:08:14 +0000 |
commit | 562ecd4444b94fbcf9c3e860991228b1fa85e273 (patch) | |
tree | 9f1ba3e42b3a342ba93cea289dd96796296465c8 /clang/lib/Format/ContinuationIndenter.cpp | |
parent | 1c5d9df8d1af0f266923edba8fcb367a51a03d26 (diff) | |
download | bcm5719-llvm-562ecd4444b94fbcf9c3e860991228b1fa85e273.tar.gz bcm5719-llvm-562ecd4444b94fbcf9c3e860991228b1fa85e273.zip |
clang-format: Fix regression introduced by r189337.
Before:
if (aaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) == 5) ...
After:
if (aaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
== 5) ...
Also precompute startsBinaryExpression() to improve performance.
llvm-svn: 190124
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index d48cb23da94..12cfd48f5b3 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -38,15 +38,6 @@ static unsigned getLengthToMatchingParen(const FormatToken &Tok) { return End->TotalLength - Tok.TotalLength + 1; } -// Returns \c true if \c Tok starts a binary expression. -static bool startsBinaryExpression(const FormatToken &Tok) { - for (unsigned i = 0, e = Tok.FakeLParens.size(); i != e; ++i) { - if (Tok.FakeLParens[i] > prec::Unknown) - return true; - } - return false; -} - // Returns \c true if \c Tok is the "." or "->" of a call and starts the next // segment of a builder type call. static bool startsSegmentOfBuilderTypeCall(const FormatToken &Tok) { @@ -156,7 +147,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { Previous.Previous && Previous.Previous->Type != TT_BinaryOperator; // For >>. bool LHSIsBinaryExpr = - Previous.Previous && Previous.Previous->FakeRParens > 0; + Previous.Previous && Previous.Previous->EndsBinaryExpression; if (Previous.Type == TT_BinaryOperator && (!IsComparison || LHSIsBinaryExpr) && Current.Type != TT_BinaryOperator && // For >>. @@ -394,7 +385,7 @@ unsigned ContinuationIndenter::addTokenToState(LineState &State, bool Newline, Previous.Type == TT_UnaryOperator || Previous.Type == TT_CtorInitializerColon) && (Previous.getPrecedence() != prec::Assignment || - startsBinaryExpression(Current))) + 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. @@ -455,7 +446,7 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State, } // If return returns a binary expression, align after it. - if (Current.is(tok::kw_return) && startsBinaryExpression(Current)) + if (Current.is(tok::kw_return) && Current.StartsBinaryExpression) State.Stack.back().LastSpace = State.Column + 7; // In ObjC method declaration we align on the ":" of parameters, but we need |