diff --git a/clang/include/clang/Tooling/Syntax/Nodes.h b/clang/include/clang/Tooling/Syntax/Nodes.h --- a/clang/include/clang/Tooling/Syntax/Nodes.h +++ b/clang/include/clang/Tooling/Syntax/Nodes.h @@ -190,7 +190,7 @@ public: TranslationUnit() : Tree(NodeKind::TranslationUnit) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::TranslationUnit; + return N->getKind() == NodeKind::TranslationUnit; } }; @@ -200,8 +200,8 @@ public: Expression(NodeKind K) : Tree(K) {} static bool classof(const Node *N) { - return NodeKind::UnknownExpression <= N->kind() && - N->kind() <= NodeKind::UnknownExpression; + return NodeKind::UnknownExpression <= N->getKind() && + N->getKind() <= NodeKind::UnknownExpression; } }; @@ -211,10 +211,10 @@ public: NameSpecifier(NodeKind K) : Tree(K) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::GlobalNameSpecifier || - N->kind() == NodeKind::DecltypeNameSpecifier || - N->kind() == NodeKind::IdentifierNameSpecifier || - N->kind() == NodeKind::SimpleTemplateNameSpecifier; + return N->getKind() == NodeKind::GlobalNameSpecifier || + N->getKind() == NodeKind::DecltypeNameSpecifier || + N->getKind() == NodeKind::IdentifierNameSpecifier || + N->getKind() == NodeKind::SimpleTemplateNameSpecifier; } }; @@ -226,7 +226,7 @@ public: GlobalNameSpecifier() : NameSpecifier(NodeKind::GlobalNameSpecifier) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::GlobalNameSpecifier; + return N->getKind() == NodeKind::GlobalNameSpecifier; } }; @@ -236,7 +236,7 @@ public: DecltypeNameSpecifier() : NameSpecifier(NodeKind::DecltypeNameSpecifier) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::DecltypeNameSpecifier; + return N->getKind() == NodeKind::DecltypeNameSpecifier; } }; @@ -247,7 +247,7 @@ IdentifierNameSpecifier() : NameSpecifier(NodeKind::IdentifierNameSpecifier) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::IdentifierNameSpecifier; + return N->getKind() == NodeKind::IdentifierNameSpecifier; } }; @@ -259,7 +259,7 @@ SimpleTemplateNameSpecifier() : NameSpecifier(NodeKind::SimpleTemplateNameSpecifier) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::SimpleTemplateNameSpecifier; + return N->getKind() == NodeKind::SimpleTemplateNameSpecifier; } }; @@ -269,7 +269,7 @@ public: NestedNameSpecifier() : List(NodeKind::NestedNameSpecifier) {} static bool classof(const Node *N) { - return N->kind() <= NodeKind::NestedNameSpecifier; + return N->getKind() <= NodeKind::NestedNameSpecifier; } std::vector getSpecifiers(); std::vector> @@ -282,7 +282,7 @@ public: UnqualifiedId() : Tree(NodeKind::UnqualifiedId) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::UnqualifiedId; + return N->getKind() == NodeKind::UnqualifiedId; } }; @@ -297,7 +297,7 @@ public: IdExpression() : Expression(NodeKind::IdExpression) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::IdExpression; + return N->getKind() == NodeKind::IdExpression; } NestedNameSpecifier *getQualifier(); Leaf *getTemplateKeyword(); @@ -310,7 +310,7 @@ public: UnknownExpression() : Expression(NodeKind::UnknownExpression) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::UnknownExpression; + return N->getKind() == NodeKind::UnknownExpression; } }; @@ -319,7 +319,7 @@ public: ThisExpression() : Expression(NodeKind::ThisExpression) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::ThisExpression; + return N->getKind() == NodeKind::ThisExpression; } Leaf *getThisKeyword(); }; @@ -333,7 +333,7 @@ public: CallArguments() : List(NodeKind::CallArguments) {} static bool classof(const Node *N) { - return N->kind() <= NodeKind::CallArguments; + return N->getKind() <= NodeKind::CallArguments; } std::vector getArguments(); std::vector> getArgumentsAndCommas(); @@ -347,7 +347,7 @@ public: CallExpression() : Expression(NodeKind::CallExpression) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::CallExpression; + return N->getKind() == NodeKind::CallExpression; } Expression *getCallee(); Leaf *getOpenParen(); @@ -361,7 +361,7 @@ public: ParenExpression() : Expression(NodeKind::ParenExpression) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::ParenExpression; + return N->getKind() == NodeKind::ParenExpression; } Leaf *getOpenParen(); Expression *getSubExpression(); @@ -380,7 +380,7 @@ public: MemberExpression() : Expression(NodeKind::MemberExpression) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::MemberExpression; + return N->getKind() == NodeKind::MemberExpression; } Expression *getObject(); Leaf *getAccessToken(); @@ -393,16 +393,16 @@ public: LiteralExpression(NodeKind K) : Expression(K) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::IntegerLiteralExpression || - N->kind() == NodeKind::CharacterLiteralExpression || - N->kind() == NodeKind::FloatingLiteralExpression || - N->kind() == NodeKind::StringLiteralExpression || - N->kind() == NodeKind::BoolLiteralExpression || - N->kind() == NodeKind::CxxNullPtrExpression || - N->kind() == NodeKind::IntegerUserDefinedLiteralExpression || - N->kind() == NodeKind::FloatUserDefinedLiteralExpression || - N->kind() == NodeKind::CharUserDefinedLiteralExpression || - N->kind() == NodeKind::StringUserDefinedLiteralExpression; + return N->getKind() == NodeKind::IntegerLiteralExpression || + N->getKind() == NodeKind::CharacterLiteralExpression || + N->getKind() == NodeKind::FloatingLiteralExpression || + N->getKind() == NodeKind::StringLiteralExpression || + N->getKind() == NodeKind::BoolLiteralExpression || + N->getKind() == NodeKind::CxxNullPtrExpression || + N->getKind() == NodeKind::IntegerUserDefinedLiteralExpression || + N->getKind() == NodeKind::FloatUserDefinedLiteralExpression || + N->getKind() == NodeKind::CharUserDefinedLiteralExpression || + N->getKind() == NodeKind::StringUserDefinedLiteralExpression; } Leaf *getLiteralToken(); }; @@ -413,7 +413,7 @@ IntegerLiteralExpression() : LiteralExpression(NodeKind::IntegerLiteralExpression) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::IntegerLiteralExpression; + return N->getKind() == NodeKind::IntegerLiteralExpression; } }; @@ -423,7 +423,7 @@ CharacterLiteralExpression() : LiteralExpression(NodeKind::CharacterLiteralExpression) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::CharacterLiteralExpression; + return N->getKind() == NodeKind::CharacterLiteralExpression; } }; @@ -433,7 +433,7 @@ FloatingLiteralExpression() : LiteralExpression(NodeKind::FloatingLiteralExpression) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::FloatingLiteralExpression; + return N->getKind() == NodeKind::FloatingLiteralExpression; } }; @@ -443,7 +443,7 @@ StringLiteralExpression() : LiteralExpression(NodeKind::StringLiteralExpression) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::StringLiteralExpression; + return N->getKind() == NodeKind::StringLiteralExpression; } }; @@ -453,7 +453,7 @@ BoolLiteralExpression() : LiteralExpression(NodeKind::BoolLiteralExpression) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::BoolLiteralExpression; + return N->getKind() == NodeKind::BoolLiteralExpression; } }; @@ -462,7 +462,7 @@ public: CxxNullPtrExpression() : LiteralExpression(NodeKind::CxxNullPtrExpression) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::CxxNullPtrExpression; + return N->getKind() == NodeKind::CxxNullPtrExpression; } }; @@ -476,10 +476,10 @@ public: UserDefinedLiteralExpression(NodeKind K) : LiteralExpression(K) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::IntegerUserDefinedLiteralExpression || - N->kind() == NodeKind::FloatUserDefinedLiteralExpression || - N->kind() == NodeKind::CharUserDefinedLiteralExpression || - N->kind() == NodeKind::StringUserDefinedLiteralExpression; + return N->getKind() == NodeKind::IntegerUserDefinedLiteralExpression || + N->getKind() == NodeKind::FloatUserDefinedLiteralExpression || + N->getKind() == NodeKind::CharUserDefinedLiteralExpression || + N->getKind() == NodeKind::StringUserDefinedLiteralExpression; } }; @@ -491,7 +491,7 @@ : UserDefinedLiteralExpression( NodeKind::IntegerUserDefinedLiteralExpression) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::IntegerUserDefinedLiteralExpression; + return N->getKind() == NodeKind::IntegerUserDefinedLiteralExpression; } }; @@ -503,7 +503,7 @@ : UserDefinedLiteralExpression( NodeKind::FloatUserDefinedLiteralExpression) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::FloatUserDefinedLiteralExpression; + return N->getKind() == NodeKind::FloatUserDefinedLiteralExpression; } }; @@ -515,7 +515,7 @@ : UserDefinedLiteralExpression( NodeKind::CharUserDefinedLiteralExpression) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::CharUserDefinedLiteralExpression; + return N->getKind() == NodeKind::CharUserDefinedLiteralExpression; } }; @@ -527,7 +527,7 @@ : UserDefinedLiteralExpression( NodeKind::StringUserDefinedLiteralExpression) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::StringUserDefinedLiteralExpression; + return N->getKind() == NodeKind::StringUserDefinedLiteralExpression; } }; @@ -536,8 +536,8 @@ public: UnaryOperatorExpression(NodeKind K) : Expression(K) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::PrefixUnaryOperatorExpression || - N->kind() == NodeKind::PostfixUnaryOperatorExpression; + return N->getKind() == NodeKind::PrefixUnaryOperatorExpression || + N->getKind() == NodeKind::PostfixUnaryOperatorExpression; } Leaf *getOperatorToken(); Expression *getOperand(); @@ -557,7 +557,7 @@ PrefixUnaryOperatorExpression() : UnaryOperatorExpression(NodeKind::PrefixUnaryOperatorExpression) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::PrefixUnaryOperatorExpression; + return N->getKind() == NodeKind::PrefixUnaryOperatorExpression; } }; @@ -571,7 +571,7 @@ PostfixUnaryOperatorExpression() : UnaryOperatorExpression(NodeKind::PostfixUnaryOperatorExpression) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::PostfixUnaryOperatorExpression; + return N->getKind() == NodeKind::PostfixUnaryOperatorExpression; } }; @@ -586,7 +586,7 @@ public: BinaryOperatorExpression() : Expression(NodeKind::BinaryOperatorExpression) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::BinaryOperatorExpression; + return N->getKind() == NodeKind::BinaryOperatorExpression; } Expression *getLhs(); Leaf *getOperatorToken(); @@ -599,8 +599,8 @@ public: Statement(NodeKind K) : Tree(K) {} static bool classof(const Node *N) { - return NodeKind::UnknownStatement <= N->kind() && - N->kind() <= NodeKind::CompoundStatement; + return NodeKind::UnknownStatement <= N->getKind() && + N->getKind() <= NodeKind::CompoundStatement; } }; @@ -610,7 +610,7 @@ public: UnknownStatement() : Statement(NodeKind::UnknownStatement) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::UnknownStatement; + return N->getKind() == NodeKind::UnknownStatement; } }; @@ -619,7 +619,7 @@ public: DeclarationStatement() : Statement(NodeKind::DeclarationStatement) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::DeclarationStatement; + return N->getKind() == NodeKind::DeclarationStatement; } }; @@ -628,7 +628,7 @@ public: EmptyStatement() : Statement(NodeKind::EmptyStatement) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::EmptyStatement; + return N->getKind() == NodeKind::EmptyStatement; } }; @@ -637,7 +637,7 @@ public: SwitchStatement() : Statement(NodeKind::SwitchStatement) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::SwitchStatement; + return N->getKind() == NodeKind::SwitchStatement; } Leaf *getSwitchKeyword(); Statement *getBody(); @@ -648,7 +648,7 @@ public: CaseStatement() : Statement(NodeKind::CaseStatement) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::CaseStatement; + return N->getKind() == NodeKind::CaseStatement; } Leaf *getCaseKeyword(); Expression *getCaseValue(); @@ -660,7 +660,7 @@ public: DefaultStatement() : Statement(NodeKind::DefaultStatement) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::DefaultStatement; + return N->getKind() == NodeKind::DefaultStatement; } Leaf *getDefaultKeyword(); Statement *getBody(); @@ -672,7 +672,7 @@ public: IfStatement() : Statement(NodeKind::IfStatement) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::IfStatement; + return N->getKind() == NodeKind::IfStatement; } Leaf *getIfKeyword(); Statement *getThenStatement(); @@ -685,7 +685,7 @@ public: ForStatement() : Statement(NodeKind::ForStatement) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::ForStatement; + return N->getKind() == NodeKind::ForStatement; } Leaf *getForKeyword(); Statement *getBody(); @@ -696,7 +696,7 @@ public: WhileStatement() : Statement(NodeKind::WhileStatement) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::WhileStatement; + return N->getKind() == NodeKind::WhileStatement; } Leaf *getWhileKeyword(); Statement *getBody(); @@ -707,7 +707,7 @@ public: ContinueStatement() : Statement(NodeKind::ContinueStatement) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::ContinueStatement; + return N->getKind() == NodeKind::ContinueStatement; } Leaf *getContinueKeyword(); }; @@ -717,7 +717,7 @@ public: BreakStatement() : Statement(NodeKind::BreakStatement) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::BreakStatement; + return N->getKind() == NodeKind::BreakStatement; } Leaf *getBreakKeyword(); }; @@ -728,7 +728,7 @@ public: ReturnStatement() : Statement(NodeKind::ReturnStatement) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::ReturnStatement; + return N->getKind() == NodeKind::ReturnStatement; } Leaf *getReturnKeyword(); Expression *getReturnValue(); @@ -739,7 +739,7 @@ public: RangeBasedForStatement() : Statement(NodeKind::RangeBasedForStatement) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::RangeBasedForStatement; + return N->getKind() == NodeKind::RangeBasedForStatement; } Leaf *getForKeyword(); Statement *getBody(); @@ -751,7 +751,7 @@ public: ExpressionStatement() : Statement(NodeKind::ExpressionStatement) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::ExpressionStatement; + return N->getKind() == NodeKind::ExpressionStatement; } Expression *getExpression(); }; @@ -761,7 +761,7 @@ public: CompoundStatement() : Statement(NodeKind::CompoundStatement) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::CompoundStatement; + return N->getKind() == NodeKind::CompoundStatement; } Leaf *getLbrace(); /// FIXME: use custom iterator instead of 'vector'. @@ -777,8 +777,8 @@ public: Declaration(NodeKind K) : Tree(K) {} static bool classof(const Node *N) { - return NodeKind::UnknownDeclaration <= N->kind() && - N->kind() <= NodeKind::TypeAliasDeclaration; + return NodeKind::UnknownDeclaration <= N->getKind() && + N->getKind() <= NodeKind::TypeAliasDeclaration; } }; @@ -787,7 +787,7 @@ public: UnknownDeclaration() : Declaration(NodeKind::UnknownDeclaration) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::UnknownDeclaration; + return N->getKind() == NodeKind::UnknownDeclaration; } }; @@ -796,7 +796,7 @@ public: EmptyDeclaration() : Declaration(NodeKind::EmptyDeclaration) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::EmptyDeclaration; + return N->getKind() == NodeKind::EmptyDeclaration; } }; @@ -806,7 +806,7 @@ public: StaticAssertDeclaration() : Declaration(NodeKind::StaticAssertDeclaration) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::StaticAssertDeclaration; + return N->getKind() == NodeKind::StaticAssertDeclaration; } Expression *getCondition(); Expression *getMessage(); @@ -819,7 +819,7 @@ LinkageSpecificationDeclaration() : Declaration(NodeKind::LinkageSpecificationDeclaration) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::LinkageSpecificationDeclaration; + return N->getKind() == NodeKind::LinkageSpecificationDeclaration; } }; @@ -830,7 +830,7 @@ public: SimpleDeclaration() : Declaration(NodeKind::SimpleDeclaration) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::SimpleDeclaration; + return N->getKind() == NodeKind::SimpleDeclaration; } /// FIXME: use custom iterator instead of 'vector'. std::vector getDeclarators(); @@ -841,7 +841,7 @@ public: TemplateDeclaration() : Declaration(NodeKind::TemplateDeclaration) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::TemplateDeclaration; + return N->getKind() == NodeKind::TemplateDeclaration; } Leaf *getTemplateKeyword(); Declaration *getDeclaration(); @@ -857,7 +857,7 @@ ExplicitTemplateInstantiation() : Declaration(NodeKind::ExplicitTemplateInstantiation) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::ExplicitTemplateInstantiation; + return N->getKind() == NodeKind::ExplicitTemplateInstantiation; } Leaf *getTemplateKeyword(); Leaf *getExternKeyword(); @@ -869,7 +869,7 @@ public: NamespaceDefinition() : Declaration(NodeKind::NamespaceDefinition) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::NamespaceDefinition; + return N->getKind() == NodeKind::NamespaceDefinition; } }; @@ -879,7 +879,7 @@ NamespaceAliasDefinition() : Declaration(NodeKind::NamespaceAliasDefinition) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::NamespaceAliasDefinition; + return N->getKind() == NodeKind::NamespaceAliasDefinition; } }; @@ -888,7 +888,7 @@ public: UsingNamespaceDirective() : Declaration(NodeKind::UsingNamespaceDirective) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::UsingNamespaceDirective; + return N->getKind() == NodeKind::UsingNamespaceDirective; } }; @@ -898,7 +898,7 @@ public: UsingDeclaration() : Declaration(NodeKind::UsingDeclaration) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::UsingDeclaration; + return N->getKind() == NodeKind::UsingDeclaration; } }; @@ -907,7 +907,7 @@ public: TypeAliasDeclaration() : Declaration(NodeKind::TypeAliasDeclaration) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::TypeAliasDeclaration; + return N->getKind() == NodeKind::TypeAliasDeclaration; } }; @@ -927,8 +927,8 @@ public: Declarator(NodeKind K) : Tree(K) {} static bool classof(const Node *N) { - return NodeKind::SimpleDeclarator <= N->kind() && - N->kind() <= NodeKind::ParenDeclarator; + return NodeKind::SimpleDeclarator <= N->getKind() && + N->getKind() <= NodeKind::ParenDeclarator; } }; @@ -938,7 +938,7 @@ public: SimpleDeclarator() : Declarator(NodeKind::SimpleDeclarator) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::SimpleDeclarator; + return N->getKind() == NodeKind::SimpleDeclarator; } }; @@ -949,7 +949,7 @@ public: ParenDeclarator() : Declarator(NodeKind::ParenDeclarator) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::ParenDeclarator; + return N->getKind() == NodeKind::ParenDeclarator; } Leaf *getLparen(); Leaf *getRparen(); @@ -963,7 +963,7 @@ public: ArraySubscript() : Tree(NodeKind::ArraySubscript) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::ArraySubscript; + return N->getKind() == NodeKind::ArraySubscript; } // TODO: add an accessor for the "static" keyword. Leaf *getLbracket(); @@ -977,7 +977,7 @@ public: TrailingReturnType() : Tree(NodeKind::TrailingReturnType) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::TrailingReturnType; + return N->getKind() == NodeKind::TrailingReturnType; } // TODO: add accessors for specifiers. Leaf *getArrowToken(); @@ -992,7 +992,7 @@ public: ParameterDeclarationList() : List(NodeKind::ParameterDeclarationList) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::ParameterDeclarationList; + return N->getKind() == NodeKind::ParameterDeclarationList; } std::vector getParameterDeclarations(); std::vector> @@ -1014,7 +1014,7 @@ public: ParametersAndQualifiers() : Tree(NodeKind::ParametersAndQualifiers) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::ParametersAndQualifiers; + return N->getKind() == NodeKind::ParametersAndQualifiers; } Leaf *getLparen(); ParameterDeclarationList *getParameters(); @@ -1028,7 +1028,7 @@ public: MemberPointer() : Tree(NodeKind::MemberPointer) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::MemberPointer; + return N->getKind() == NodeKind::MemberPointer; } }; diff --git a/clang/include/clang/Tooling/Syntax/Tree.h b/clang/include/clang/Tooling/Syntax/Tree.h --- a/clang/include/clang/Tooling/Syntax/Tree.h +++ b/clang/include/clang/Tooling/Syntax/Tree.h @@ -41,11 +41,11 @@ Arena(SourceManager &SourceMgr, const LangOptions &LangOpts, const TokenBuffer &Tokens); - const SourceManager &sourceManager() const { return SourceMgr; } - const LangOptions &langOptions() const { return LangOpts; } + const SourceManager &getSourceManager() const { return SourceMgr; } + const LangOptions &getLangOptions() const { return LangOpts; } - const TokenBuffer &tokenBuffer() const; - llvm::BumpPtrAllocator &allocator() { return Allocator; } + const TokenBuffer &getTokenBuffer() const; + llvm::BumpPtrAllocator &getAllocator() { return Allocator; } /// Add \p Buffer to the underlying source manager, tokenize it and store the /// resulting tokens. Useful when there is a need to materialize tokens that @@ -79,8 +79,8 @@ /// set when the node is added as a child to another one. Node(NodeKind Kind); - NodeKind kind() const { return static_cast(Kind); } - NodeRole role() const { return static_cast(Role); } + NodeKind getKind() const { return static_cast(Kind); } + NodeRole getRole() const { return static_cast(Role); } /// Whether the node is detached from a tree, i.e. does not have a parent. bool isDetached() const; @@ -99,11 +99,11 @@ /// modifiable. bool canModify() const { return CanModify; } - const Tree *parent() const { return Parent; } - Tree *parent() { return Parent; } + const Tree *getParent() const { return Parent; } + Tree *getParent() { return Parent; } - const Node *nextSibling() const { return NextSibling; } - Node *nextSibling() { return NextSibling; } + const Node *getNextSibling() const { return NextSibling; } + Node *getNextSibling() { return NextSibling; } /// Dumps the structure of a subtree. For debugging and testing purposes. std::string dump(const SourceManager &SM) const; @@ -142,7 +142,7 @@ Leaf(const Token *T); static bool classof(const Node *N); - const Token *token() const { return Tok; } + const Token *getToken() const { return Tok; } private: const Token *Tok; @@ -154,16 +154,18 @@ using Node::Node; static bool classof(const Node *N); - Node *firstChild() { return FirstChild; } - const Node *firstChild() const { return FirstChild; } + Node *getFirstChild() { return FirstChild; } + const Node *getFirstChild() const { return FirstChild; } - Leaf *firstLeaf(); - const Leaf *firstLeaf() const { - return const_cast(this)->firstLeaf(); + Leaf *findFirstLeaf(); + const Leaf *findFirstLeaf() const { + return const_cast(this)->findFirstLeaf(); } - Leaf *lastLeaf(); - const Leaf *lastLeaf() const { return const_cast(this)->lastLeaf(); } + Leaf *findLastLeaf(); + const Leaf *findLastLeaf() const { + return const_cast(this)->findLastLeaf(); + } protected: /// Find the first node with a corresponding role. diff --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp --- a/clang/lib/Tooling/Syntax/BuildTree.cpp +++ b/clang/lib/Tooling/Syntax/BuildTree.cpp @@ -366,12 +366,14 @@ class syntax::TreeBuilder { public: TreeBuilder(syntax::Arena &Arena) : Arena(Arena), Pending(Arena) { - for (const auto &T : Arena.tokenBuffer().expandedTokens()) + for (const auto &T : Arena.getTokenBuffer().expandedTokens()) LocationToToken.insert({T.location().getRawEncoding(), &T}); } - llvm::BumpPtrAllocator &allocator() { return Arena.allocator(); } - const SourceManager &sourceManager() const { return Arena.sourceManager(); } + llvm::BumpPtrAllocator &allocator() { return Arena.getAllocator(); } + const SourceManager &sourceManager() const { + return Arena.getSourceManager(); + } /// Populate children for \p New node, assuming it covers tokens from \p /// Range. @@ -421,13 +423,13 @@ /// Finish building the tree and consume the root node. syntax::TranslationUnit *finalize() && { - auto Tokens = Arena.tokenBuffer().expandedTokens(); + auto Tokens = Arena.getTokenBuffer().expandedTokens(); assert(!Tokens.empty()); assert(Tokens.back().kind() == tok::eof); // Build the root of the tree, consuming all the children. Pending.foldChildren(Arena, Tokens.drop_back(), - new (Arena.allocator()) syntax::TranslationUnit); + new (Arena.getAllocator()) syntax::TranslationUnit); auto *TU = cast(std::move(Pending).finalize()); TU->assertInvariantsRecursive(); @@ -451,7 +453,7 @@ assert(First.isValid()); assert(Last.isValid()); assert(First == Last || - Arena.sourceManager().isBeforeInTranslationUnit(First, Last)); + Arena.getSourceManager().isBeforeInTranslationUnit(First, Last)); return llvm::makeArrayRef(findToken(First), std::next(findToken(Last))); } @@ -540,7 +542,7 @@ } void setRole(syntax::Node *N, NodeRole R) { - assert(N->role() == NodeRole::Detached); + assert(N->getRole() == NodeRole::Detached); N->setRole(R); } @@ -552,14 +554,14 @@ /// Ensures that added nodes properly nest and cover the whole token stream. struct Forest { Forest(syntax::Arena &A) { - assert(!A.tokenBuffer().expandedTokens().empty()); - assert(A.tokenBuffer().expandedTokens().back().kind() == tok::eof); + assert(!A.getTokenBuffer().expandedTokens().empty()); + assert(A.getTokenBuffer().expandedTokens().back().kind() == tok::eof); // Create all leaf nodes. // Note that we do not have 'eof' in the tree. - for (auto &T : A.tokenBuffer().expandedTokens().drop_back()) { - auto *L = new (A.allocator()) syntax::Leaf(&T); + for (auto &T : A.getTokenBuffer().expandedTokens().drop_back()) { + auto *L = new (A.getAllocator()) syntax::Leaf(&T); L->Original = true; - L->CanModify = A.tokenBuffer().spelledForExpanded(T).hasValue(); + L->CanModify = A.getTokenBuffer().spelledForExpanded(T).hasValue(); Trees.insert(Trees.end(), {&T, L}); } } @@ -572,7 +574,7 @@ assert((std::next(It) == Trees.end() || std::next(It)->first == Range.end()) && "no child with the specified range"); - assert(It->second->role() == NodeRole::Detached && + assert(It->second->getRole() == NodeRole::Detached && "re-assigning role for a child"); It->second->setRole(Role); } @@ -581,7 +583,7 @@ void foldChildren(const syntax::Arena &A, ArrayRef Tokens, syntax::Tree *Node) { // Attach children to `Node`. - assert(Node->firstChild() == nullptr && "node already has children"); + assert(Node->getFirstChild() == nullptr && "node already has children"); auto *FirstToken = Tokens.begin(); auto BeginChildren = Trees.lower_bound(FirstToken); @@ -597,14 +599,15 @@ // We need to go in reverse order, because we can only prepend. for (auto It = EndChildren; It != BeginChildren; --It) { auto *C = std::prev(It)->second; - if (C->role() == NodeRole::Detached) + if (C->getRole() == NodeRole::Detached) C->setRole(NodeRole::Unknown); Node->prependChildLowLevel(C); } // Mark that this node came from the AST and is backed by the source code. Node->Original = true; - Node->CanModify = A.tokenBuffer().spelledForExpanded(Tokens).hasValue(); + Node->CanModify = + A.getTokenBuffer().spelledForExpanded(Tokens).hasValue(); Trees.erase(BeginChildren, EndChildren); Trees.insert({FirstToken, Node}); @@ -624,12 +627,12 @@ unsigned CoveredTokens = It != Trees.end() ? (std::next(It)->first - It->first) - : A.tokenBuffer().expandedTokens().end() - It->first; + : A.getTokenBuffer().expandedTokens().end() - It->first; R += std::string( - formatv("- '{0}' covers '{1}'+{2} tokens\n", It->second->kind(), - It->first->text(A.sourceManager()), CoveredTokens)); - R += It->second->dump(A.sourceManager()); + formatv("- '{0}' covers '{1}'+{2} tokens\n", It->second->getKind(), + It->first->text(A.getSourceManager()), CoveredTokens)); + R += It->second->dump(A.getSourceManager()); } return R; } diff --git a/clang/lib/Tooling/Syntax/ComputeReplacements.cpp b/clang/lib/Tooling/Syntax/ComputeReplacements.cpp --- a/clang/lib/Tooling/Syntax/ComputeReplacements.cpp +++ b/clang/lib/Tooling/Syntax/ComputeReplacements.cpp @@ -32,13 +32,14 @@ private: void process(const syntax::Node *N) { if (auto *T = dyn_cast(N)) { - for (auto *C = T->firstChild(); C != nullptr; C = C->nextSibling()) + for (auto *C = T->getFirstChild(); C != nullptr; + C = C->getNextSibling()) process(C); return; } auto *L = cast(N); - if (SpanEnd == L->token() && SpanIsOriginal == L->isOriginal()) { + if (SpanEnd == L->getToken() && SpanIsOriginal == L->isOriginal()) { // Extend the current span. ++SpanEnd; return; @@ -47,7 +48,7 @@ if (SpanBegin) Callback(llvm::makeArrayRef(SpanBegin, SpanEnd), SpanIsOriginal); // Start recording a new span. - SpanBegin = L->token(); + SpanBegin = L->getToken(); SpanEnd = SpanBegin + 1; SpanIsOriginal = L->isOriginal(); } @@ -63,8 +64,8 @@ syntax::FileRange rangeOfExpanded(const syntax::Arena &A, llvm::ArrayRef Expanded) { - auto &Buffer = A.tokenBuffer(); - auto &SM = A.sourceManager(); + auto &Buffer = A.getTokenBuffer(); + auto &SM = A.getSourceManager(); // Check that \p Expanded actually points into expanded tokens. assert(Buffer.expandedTokens().begin() <= Expanded.begin()); @@ -84,8 +85,8 @@ tooling::Replacements syntax::computeReplacements(const syntax::Arena &A, const syntax::TranslationUnit &TU) { - auto &Buffer = A.tokenBuffer(); - auto &SM = A.sourceManager(); + auto &Buffer = A.getTokenBuffer(); + auto &SM = A.getSourceManager(); tooling::Replacements Replacements; // Text inserted by the replacement we are building now. diff --git a/clang/lib/Tooling/Syntax/Mutations.cpp b/clang/lib/Tooling/Syntax/Mutations.cpp --- a/clang/lib/Tooling/Syntax/Mutations.cpp +++ b/clang/lib/Tooling/Syntax/Mutations.cpp @@ -36,7 +36,7 @@ assert(Role != NodeRole::Detached); New->setRole(Role); - auto *P = Anchor->parent(); + auto *P = Anchor->getParent(); P->replaceChildRangeLowLevel(Anchor, Anchor, New); P->assertInvariants(); @@ -52,16 +52,16 @@ assert(New->isDetached()); New->Role = Old->Role; - auto *P = Old->parent(); - P->replaceChildRangeLowLevel(findPrevious(Old), Old->nextSibling(), New); + auto *P = Old->getParent(); + P->replaceChildRangeLowLevel(findPrevious(Old), Old->getNextSibling(), New); P->assertInvariants(); } /// Completely remove the node from its parent. static void remove(syntax::Node *N) { - auto *P = N->parent(); - P->replaceChildRangeLowLevel(findPrevious(N), N->nextSibling(), + auto *P = N->getParent(); + P->replaceChildRangeLowLevel(findPrevious(N), N->getNextSibling(), /*New=*/nullptr); P->assertInvariants(); @@ -70,11 +70,11 @@ private: static syntax::Node *findPrevious(syntax::Node *N) { - if (N->parent()->firstChild() == N) + if (N->getParent()->getFirstChild() == N) return nullptr; - for (syntax::Node *C = N->parent()->firstChild(); C != nullptr; - C = C->nextSibling()) { - if (C->nextSibling() == N) + for (syntax::Node *C = N->getParent()->getFirstChild(); C != nullptr; + C = C->getNextSibling()) { + if (C->getNextSibling() == N) return C; } llvm_unreachable("could not find a child node"); @@ -85,7 +85,7 @@ assert(S); assert(S->canModify()); - if (isa(S->parent())) { + if (isa(S->getParent())) { // A child of CompoundStatement can just be safely removed. MutationsImpl::remove(S); return; diff --git a/clang/lib/Tooling/Syntax/Nodes.cpp b/clang/lib/Tooling/Syntax/Nodes.cpp --- a/clang/lib/Tooling/Syntax/Nodes.cpp +++ b/clang/lib/Tooling/Syntax/Nodes.cpp @@ -501,8 +501,8 @@ std::vector syntax::CompoundStatement::getStatements() { std::vector Children; - for (auto *C = firstChild(); C; C = C->nextSibling()) { - assert(C->role() == syntax::NodeRole::Statement); + for (auto *C = getFirstChild(); C; C = C->getNextSibling()) { + assert(C->getRole() == syntax::NodeRole::Statement); Children.push_back(cast(C)); } return Children; @@ -524,8 +524,8 @@ std::vector syntax::SimpleDeclaration::getDeclarators() { std::vector Children; - for (auto *C = firstChild(); C; C = C->nextSibling()) { - if (C->role() == syntax::NodeRole::Declarator) + for (auto *C = getFirstChild(); C; C = C->getNextSibling()) { + if (C->getRole() == syntax::NodeRole::Declarator) Children.push_back(cast(C)); } return Children; diff --git a/clang/lib/Tooling/Syntax/Synthesis.cpp b/clang/lib/Tooling/Syntax/Synthesis.cpp --- a/clang/lib/Tooling/Syntax/Synthesis.cpp +++ b/clang/lib/Tooling/Syntax/Synthesis.cpp @@ -28,7 +28,7 @@ .second; assert(Tokens.size() == 1); assert(Tokens.front().kind() == K); - auto *L = new (A.allocator()) clang::syntax::Leaf(Tokens.begin()); + auto *L = new (A.getAllocator()) clang::syntax::Leaf(Tokens.begin()); FactoryImpl::setCanModify(L); L->assertInvariants(); return L; @@ -36,7 +36,7 @@ clang::syntax::EmptyStatement * syntax::createEmptyStatement(clang::syntax::Arena &A) { - auto *S = new (A.allocator()) clang::syntax::EmptyStatement; + auto *S = new (A.getAllocator()) clang::syntax::EmptyStatement; FactoryImpl::setCanModify(S); FactoryImpl::prependChildLowLevel(S, createPunctuation(A, clang::tok::semi), NodeRole::Unknown); diff --git a/clang/lib/Tooling/Syntax/Tree.cpp b/clang/lib/Tooling/Syntax/Tree.cpp --- a/clang/lib/Tooling/Syntax/Tree.cpp +++ b/clang/lib/Tooling/Syntax/Tree.cpp @@ -19,7 +19,7 @@ static void traverse(const syntax::Node *N, llvm::function_ref Visit) { if (auto *T = dyn_cast(N)) { - for (auto *C = T->firstChild(); C; C = C->nextSibling()) + for (auto *C = T->getFirstChild(); C; C = C->getNextSibling()) traverse(C, Visit); } Visit(N); @@ -36,7 +36,9 @@ const TokenBuffer &Tokens) : SourceMgr(SourceMgr), LangOpts(LangOpts), Tokens(Tokens) {} -const syntax::TokenBuffer &syntax::Arena::tokenBuffer() const { return Tokens; } +const syntax::TokenBuffer &syntax::Arena::getTokenBuffer() const { + return Tokens; +} std::pair> syntax::Arena::lexBuffer(std::unique_ptr Input) { @@ -51,7 +53,7 @@ } bool syntax::Leaf::classof(const Node *N) { - return N->kind() == NodeKind::Leaf; + return N->getKind() == NodeKind::Leaf; } syntax::Node::Node(NodeKind Kind) @@ -60,16 +62,20 @@ this->setRole(NodeRole::Detached); } -bool syntax::Node::isDetached() const { return role() == NodeRole::Detached; } +bool syntax::Node::isDetached() const { + return getRole() == NodeRole::Detached; +} void syntax::Node::setRole(NodeRole NR) { this->Role = static_cast(NR); } -bool syntax::Tree::classof(const Node *N) { return N->kind() > NodeKind::Leaf; } +bool syntax::Tree::classof(const Node *N) { + return N->getKind() > NodeKind::Leaf; +} void syntax::Tree::prependChildLowLevel(Node *Child, NodeRole Role) { - assert(Child->role() == NodeRole::Detached); + assert(Child->getRole() == NodeRole::Detached); assert(Role != NodeRole::Detached); Child->setRole(Role); @@ -79,7 +85,7 @@ void syntax::Tree::prependChildLowLevel(Node *Child) { assert(Child->Parent == nullptr); assert(Child->NextSibling == nullptr); - assert(Child->role() != NodeRole::Detached); + assert(Child->getRole() != NodeRole::Detached); Child->Parent = this; Child->NextSibling = this->FirstChild; @@ -91,15 +97,15 @@ assert(!BeforeBegin || BeforeBegin->Parent == this); #ifndef NDEBUG - for (auto *N = New; N; N = N->nextSibling()) { + for (auto *N = New; N; N = N->getNextSibling()) { assert(N->Parent == nullptr); - assert(N->role() != NodeRole::Detached && "Roles must be set"); + assert(N->getRole() != NodeRole::Detached && "Roles must be set"); // FIXME: sanity-check the role. } #endif // Detach old nodes. - for (auto *N = !BeforeBegin ? FirstChild : BeforeBegin->nextSibling(); + for (auto *N = !BeforeBegin ? FirstChild : BeforeBegin->getNextSibling(); N != End;) { auto *Next = N->NextSibling; @@ -120,7 +126,7 @@ if (New) { auto *Last = New; - for (auto *N = New; N != nullptr; N = N->nextSibling()) { + for (auto *N = New; N != nullptr; N = N->getNextSibling()) { Last = N; N->Parent = this; } @@ -136,7 +142,7 @@ static void dumpLeaf(raw_ostream &OS, const syntax::Leaf *L, const SourceManager &SM) { assert(L); - const auto *Token = L->token(); + const auto *Token = L->getToken(); assert(Token); // Handle 'eof' separately, calling text() on it produces an empty string. if (Token->kind() == tok::eof) @@ -148,8 +154,8 @@ static void dumpNode(raw_ostream &OS, const syntax::Node *N, const SourceManager &SM, std::vector IndentMask) { auto dumpExtraInfo = [&OS](const syntax::Node *N) { - if (N->role() != syntax::NodeRole::Unknown) - OS << " " << N->role(); + if (N->getRole() != syntax::NodeRole::Unknown) + OS << " " << N->getRole(); if (!N->isOriginal()) OS << " synthesized"; if (!N->canModify()) @@ -167,18 +173,18 @@ } const auto *T = cast(N); - OS << T->kind(); + OS << T->getKind(); dumpExtraInfo(N); OS << "\n"; - for (const auto *It = T->firstChild(); It; It = It->nextSibling()) { + for (const auto *It = T->getFirstChild(); It; It = It->getNextSibling()) { for (bool Filled : IndentMask) { if (Filled) OS << "| "; else OS << " "; } - if (!It->nextSibling()) { + if (!It->getNextSibling()) { OS << "`-"; IndentMask.push_back(false); } else { @@ -213,18 +219,18 @@ void syntax::Node::assertInvariants() const { #ifndef NDEBUG if (isDetached()) - assert(parent() == nullptr); + assert(getParent() == nullptr); else - assert(parent() != nullptr); + assert(getParent() != nullptr); auto *T = dyn_cast(this); if (!T) return; - for (auto *C = T->firstChild(); C; C = C->nextSibling()) { + for (auto *C = T->getFirstChild(); C; C = C->getNextSibling()) { if (T->isOriginal()) assert(C->isOriginal()); assert(!C->isDetached()); - assert(C->parent() == T); + assert(C->getParent() == T); } #endif } @@ -235,9 +241,9 @@ #endif } -syntax::Leaf *syntax::Tree::firstLeaf() { +syntax::Leaf *syntax::Tree::findFirstLeaf() { auto *T = this; - while (auto *C = T->firstChild()) { + while (auto *C = T->getFirstChild()) { if (auto *L = dyn_cast(C)) return L; T = cast(C); @@ -245,11 +251,11 @@ return nullptr; } -syntax::Leaf *syntax::Tree::lastLeaf() { +syntax::Leaf *syntax::Tree::findLastLeaf() { auto *T = this; - while (auto *C = T->firstChild()) { + while (auto *C = T->getFirstChild()) { // Find the last child. - while (auto *Next = C->nextSibling()) + while (auto *Next = C->getNextSibling()) C = Next; if (auto *L = dyn_cast(C)) @@ -260,8 +266,8 @@ } syntax::Node *syntax::Tree::findChild(NodeRole R) { - for (auto *C = FirstChild; C; C = C->nextSibling()) { - if (C->role() == R) + for (auto *C = FirstChild; C; C = C->getNextSibling()) { + if (C->getRole() == R) return C; } return nullptr; @@ -269,13 +275,13 @@ std::vector> syntax::List::getElementsAsNodesAndDelimiters() { - if (!firstChild()) + if (!getFirstChild()) return {}; auto children = std::vector>(); syntax::Node *elementWithoutDelimiter = nullptr; - for (auto *C = firstChild(); C; C = C->nextSibling()) { - switch (C->role()) { + for (auto *C = getFirstChild(); C; C = C->getNextSibling()) { + switch (C->getRole()) { case syntax::NodeRole::ListElement: { if (elementWithoutDelimiter) { children.push_back({elementWithoutDelimiter, nullptr}); @@ -314,13 +320,13 @@ // Almost the same implementation of `getElementsAsNodesAndDelimiters` but // ignoring delimiters std::vector syntax::List::getElementsAsNodes() { - if (!firstChild()) + if (!getFirstChild()) return {}; auto children = std::vector(); syntax::Node *elementWithoutDelimiter = nullptr; - for (auto *C = firstChild(); C; C = C->nextSibling()) { - switch (C->role()) { + for (auto *C = getFirstChild(); C; C = C->getNextSibling()) { + switch (C->getRole()) { case syntax::NodeRole::ListElement: { if (elementWithoutDelimiter) { children.push_back(elementWithoutDelimiter); @@ -356,7 +362,7 @@ } clang::tok::TokenKind syntax::List::getDelimiterTokenKind() { - switch (this->kind()) { + switch (this->getKind()) { case NodeKind::NestedNameSpecifier: return clang::tok::coloncolon; case NodeKind::CallArguments: @@ -369,7 +375,7 @@ } syntax::List::TerminationKind syntax::List::getTerminationKind() { - switch (this->kind()) { + switch (this->getKind()) { case NodeKind::NestedNameSpecifier: return TerminationKind::Terminated; case NodeKind::CallArguments: @@ -382,7 +388,7 @@ } bool syntax::List::canBeEmpty() { - switch (this->kind()) { + switch (this->getKind()) { case NodeKind::NestedNameSpecifier: return false; case NodeKind::CallArguments: diff --git a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp --- a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp +++ b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp @@ -28,7 +28,7 @@ << "Source file has syntax errors, they were printed to the test " "log"; } - auto Actual = StringRef(Root->dump(Arena->sourceManager())).trim().str(); + auto Actual = StringRef(Root->dump(Arena->getSourceManager())).trim().str(); // EXPECT_EQ shows the diff between the two strings if they are different. EXPECT_EQ(Tree.trim().str(), Actual); if (Actual != Tree.trim().str()) { @@ -63,7 +63,9 @@ auto *AnnotatedNode = nodeByRange(AnnotatedRanges[i], Root); assert(AnnotatedNode); auto AnnotatedNodeDump = - StringRef(AnnotatedNode->dump(Arena->sourceManager())).trim().str(); + StringRef(AnnotatedNode->dump(Arena->getSourceManager())) + .trim() + .str(); // EXPECT_EQ shows the diff between the two strings if they are different. EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump) << "Dumps diverged for the code:\n" diff --git a/clang/unittests/Tooling/Syntax/SynthesisTest.cpp b/clang/unittests/Tooling/Syntax/SynthesisTest.cpp --- a/clang/unittests/Tooling/Syntax/SynthesisTest.cpp +++ b/clang/unittests/Tooling/Syntax/SynthesisTest.cpp @@ -26,7 +26,7 @@ auto *C = syntax::createPunctuation(*Arena, tok::comma); ASSERT_NE(C, nullptr); - EXPECT_EQ(C->token()->kind(), tok::comma); + EXPECT_EQ(C->getToken()->kind(), tok::comma); EXPECT_TRUE(C->canModify()); EXPECT_FALSE(C->isOriginal()); EXPECT_TRUE(C->isDetached()); diff --git a/clang/unittests/Tooling/Syntax/TreeTestBase.cpp b/clang/unittests/Tooling/Syntax/TreeTestBase.cpp --- a/clang/unittests/Tooling/Syntax/TreeTestBase.cpp +++ b/clang/unittests/Tooling/Syntax/TreeTestBase.cpp @@ -38,10 +38,10 @@ ArrayRef tokens(syntax::Node *N) { assert(N->isOriginal() && "tokens of modified nodes are not well-defined"); if (auto *L = dyn_cast(N)) - return llvm::makeArrayRef(L->token(), 1); + return llvm::makeArrayRef(L->getToken(), 1); auto *T = cast(N); - return llvm::makeArrayRef(T->firstLeaf()->token(), - T->lastLeaf()->token() + 1); + return llvm::makeArrayRef(T->findFirstLeaf()->getToken(), + T->findLastLeaf()->getToken() + 1); } } // namespace @@ -170,7 +170,7 @@ auto *T = dyn_cast(Root); if (!T) return nullptr; - for (auto *C = T->firstChild(); C != nullptr; C = C->nextSibling()) { + for (auto *C = T->getFirstChild(); C != nullptr; C = C->getNextSibling()) { if (auto *Result = nodeByRange(R, C)) return Result; }