diff options
Diffstat (limited to 'lib/Format/TokenAnnotator.h')
-rw-r--r-- | lib/Format/TokenAnnotator.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/Format/TokenAnnotator.h b/lib/Format/TokenAnnotator.h index c41ee33c43..f5a8a9430c 100644 --- a/lib/Format/TokenAnnotator.h +++ b/lib/Format/TokenAnnotator.h @@ -75,7 +75,7 @@ public: CanBreakBefore(false), MustBreakBefore(false), ClosesTemplateDeclaration(false), MatchingParen(NULL), ParameterCount(0), BindingStrength(0), SplitPenalty(0), - LongestObjCSelectorName(0), Parent(NULL), FakeLParens(0), + LongestObjCSelectorName(0), Parent(NULL), FakeRParens(0), LastInChainOfCalls(false), PartOfMultiVariableDeclStmt(false) {} @@ -158,8 +158,12 @@ public: std::vector<AnnotatedToken> Children; AnnotatedToken *Parent; - /// \brief Insert this many fake ( before this token for correct indentation. - unsigned FakeLParens; + /// \brief Stores the number of required fake parentheses and the + /// corresponding operator precedence. + /// + /// If multiple fake parentheses start at a token, this vector stores them in + /// reverse order, i.e. inner fake parenthesis first. + SmallVector<prec::Level, 4> FakeLParens; /// \brief Insert this many fake ) after this token for correct indentation. unsigned FakeRParens; @@ -223,6 +227,11 @@ inline prec::Level getPrecedence(const AnnotatedToken &Tok) { return getBinOpPrecedence(Tok.FormatTok.Tok.getKind(), true, true); } +/// \brief Returns whether \p Tok is ([{ or a template opening <. +bool opensScope(const AnnotatedToken &Tok); +/// \brief Returns whether \p Tok is )]} or a template opening >. +bool closesScope(const AnnotatedToken &Tok); + /// \brief Determines extra information about the tokens comprising an /// \c UnwrappedLine. class TokenAnnotator { @@ -248,6 +257,8 @@ private: bool canBreakBefore(const AnnotatedLine &Line, const AnnotatedToken &Right); + void printDebugInfo(const AnnotatedLine &Line); + const FormatStyle &Style; SourceManager &SourceMgr; Lexer &Lex; |