diff options
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 1b22e266007..bc8fef8bda9 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1662,17 +1662,15 @@ private: /// \brief Parse unary operator expressions and surround them with fake /// parentheses if appropriate. void parseUnaryOperator() { - if (!Current || Current->isNot(TT_UnaryOperator)) { - parse(PrecedenceArrowAndPeriod); - return; + llvm::SmallVector<FormatToken *, 2> Tokens; + while (Current && Current->is(TT_UnaryOperator)) { + Tokens.push_back(Current); + next(); } - - FormatToken *Start = Current; - next(); - parseUnaryOperator(); - - // The actual precedence doesn't matter. - addFakeParenthesis(Start, prec::Unknown); + parse(PrecedenceArrowAndPeriod); + for (FormatToken *Token : llvm::reverse(Tokens)) + // The actual precedence doesn't matter. + addFakeParenthesis(Token, prec::Unknown); } void parseConditionalExpr() { |