clang  11.0.0git
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
clang::syntax::Tree Class Reference

A node that has children and represents a syntactic language construct. More...

#include "clang/Tooling/Syntax/Tree.h"

Inheritance diagram for clang::syntax::Tree:
Inheritance graph
[legend]
Collaboration diagram for clang::syntax::Tree:
Collaboration graph
[legend]

Public Member Functions

NodefirstChild ()
 
const NodefirstChild () const
 
LeaffirstLeaf ()
 
const LeaffirstLeaf () const
 
LeaflastLeaf ()
 
const LeaflastLeaf () const
 
- Public Member Functions inherited from clang::syntax::Node
 Node (NodeKind Kind)
 Newly created nodes are detached from a tree, parent and sibling links are set when the node is added as a child to another one. More...
 
NodeKind kind () const
 
NodeRole role () const
 
bool isDetached () const
 Whether the node is detached from a tree, i.e. does not have a parent. More...
 
bool isOriginal () const
 Whether the node was created from the AST backed by the source code rather than added later through mutation APIs or created with factory functions. More...
 
bool canModify () const
 If this function return false, the tree cannot be modified because there is no reasonable way to produce the corresponding textual replacements. More...
 
const Treeparent () const
 
Treeparent ()
 
const NodenextSibling () const
 
NodenextSibling ()
 
std::string dump (const Arena &A) const
 Dumps the structure of a subtree. For debugging and testing purposes. More...
 
std::string dumpTokens (const Arena &A) const
 Dumps the tokens forming this subtree. More...
 
void assertInvariants () const
 Asserts invariants on this node of the tree and its immediate children. More...
 
void assertInvariantsRecursive () const
 Runs checkInvariants on all nodes in the subtree. No-op if NDEBUG is set. More...
 

Static Public Member Functions

static bool classof (const Node *N)
 

Protected Member Functions

syntax::NodefindChild (NodeRole R)
 Find the first node with a corresponding role. More...
 

Friends

class TreeBuilder
 
class FactoryImpl
 
class MutationsImpl
 

Detailed Description

A node that has children and represents a syntactic language construct.

Definition at line 152 of file Tree.h.

Member Function Documentation

◆ classof()

bool syntax::Tree::classof ( const Node N)
static

◆ findChild()

syntax::Node * syntax::Tree::findChild ( NodeRole  R)
protected

Find the first node with a corresponding role.

Definition at line 266 of file Tree.cpp.

Referenced by clang::syntax::TrailingReturnType::arrowToken(), clang::syntax::SwitchStatement::body(), clang::syntax::CaseStatement::body(), clang::syntax::DefaultStatement::body(), clang::syntax::ForStatement::body(), clang::syntax::WhileStatement::body(), clang::syntax::RangeBasedForStatement::body(), clang::syntax::BreakStatement::breakKeyword(), clang::syntax::CaseStatement::caseKeyword(), clang::syntax::ParenExpression::closeParen(), clang::syntax::StaticAssertDeclaration::condition(), clang::syntax::ContinueStatement::continueKeyword(), clang::syntax::TemplateDeclaration::declaration(), clang::syntax::ExplicitTemplateInstantiation::declaration(), clang::syntax::TrailingReturnType::declarator(), clang::syntax::DefaultStatement::defaultKeyword(), clang::syntax::IfStatement::elseKeyword(), clang::syntax::IfStatement::elseStatement(), clang::syntax::ExpressionStatement::expression(), clang::syntax::ExplicitTemplateInstantiation::externKeyword(), clang::syntax::ForStatement::forKeyword(), clang::syntax::RangeBasedForStatement::forKeyword(), clang::syntax::IfStatement::ifKeyword(), clang::syntax::CompoundStatement::lbrace(), clang::syntax::ArraySubscript::lbracket(), clang::syntax::BinaryOperatorExpression::lhs(), clang::syntax::IntegerLiteralExpression::literalToken(), clang::syntax::CharacterLiteralExpression::literalToken(), clang::syntax::FloatingLiteralExpression::literalToken(), clang::syntax::StringLiteralExpression::literalToken(), clang::syntax::BoolLiteralExpression::literalToken(), clang::syntax::UserDefinedLiteralExpression::literalToken(), clang::syntax::ParenDeclarator::lparen(), clang::syntax::ParametersAndQualifiers::lparen(), clang::syntax::StaticAssertDeclaration::message(), clang::syntax::CxxNullPtrExpression::nullPtrKeyword(), clang::syntax::ParenExpression::openParen(), clang::syntax::UnaryOperatorExpression::operand(), clang::syntax::UnaryOperatorExpression::operatorToken(), clang::syntax::BinaryOperatorExpression::operatorToken(), clang::syntax::IdExpression::qualifier(), clang::syntax::CompoundStatement::rbrace(), clang::syntax::ArraySubscript::rbracket(), clang::syntax::ReturnStatement::returnKeyword(), clang::syntax::BinaryOperatorExpression::rhs(), clang::syntax::ParenDeclarator::rparen(), clang::syntax::ParametersAndQualifiers::rparen(), clang::syntax::ArraySubscript::sizeExpression(), clang::syntax::ParenExpression::subExpression(), clang::syntax::SwitchStatement::switchKeyword(), clang::syntax::TemplateDeclaration::templateKeyword(), clang::syntax::ExplicitTemplateInstantiation::templateKeyword(), clang::syntax::IfStatement::thenStatement(), clang::syntax::ParametersAndQualifiers::trailingReturn(), clang::syntax::IdExpression::unqualifiedId(), clang::syntax::CaseStatement::value(), clang::syntax::ReturnStatement::value(), and clang::syntax::WhileStatement::whileKeyword().

◆ firstChild() [1/2]

Node* clang::syntax::Tree::firstChild ( )
inline

◆ firstChild() [2/2]

const Node* clang::syntax::Tree::firstChild ( ) const
inline

Definition at line 158 of file Tree.h.

◆ firstLeaf() [1/2]

syntax::Leaf * syntax::Tree::firstLeaf ( )

Definition at line 242 of file Tree.cpp.

◆ firstLeaf() [2/2]

const Leaf* clang::syntax::Tree::firstLeaf ( ) const
inline

Definition at line 161 of file Tree.h.

◆ lastLeaf() [1/2]

syntax::Leaf * syntax::Tree::lastLeaf ( )

Definition at line 252 of file Tree.cpp.

◆ lastLeaf() [2/2]

const Leaf* clang::syntax::Tree::lastLeaf ( ) const
inline

Definition at line 166 of file Tree.h.

References lastLeaf().

Referenced by lastLeaf().

Friends And Related Function Documentation

◆ FactoryImpl

friend class FactoryImpl
friend

Definition at line 182 of file Tree.h.

◆ MutationsImpl

friend class MutationsImpl
friend

Definition at line 189 of file Tree.h.

◆ TreeBuilder

friend class TreeBuilder
friend

Definition at line 181 of file Tree.h.


The documentation for this class was generated from the following files: