clang
10.0.0svn
|
A helper class for constructing the syntax tree while traversing a clang AST. More...
Public Member Functions | |
TreeBuilder (syntax::Arena &Arena) | |
llvm::BumpPtrAllocator & | allocator () |
void | foldNode (llvm::ArrayRef< syntax::Token > Range, syntax::Tree *New) |
Populate children for New node, assuming it covers tokens from Range . More... | |
void | markChildToken (SourceLocation Loc, tok::TokenKind Kind, NodeRole R) |
Set role for a token starting at Loc . More... | |
syntax::TranslationUnit * | finalize () && |
Finish building the tree and consume the root node. More... | |
llvm::ArrayRef< syntax::Token > | getRange (SourceLocation First, SourceLocation Last) const |
getRange() finds the syntax tokens corresponding to the passed source locations. More... | |
llvm::ArrayRef< syntax::Token > | getRange (const Decl *D) const |
llvm::ArrayRef< syntax::Token > | getRange (const Stmt *S) const |
A helper class for constructing the syntax tree while traversing a clang AST.
At each point of the traversal we maintain a list of pending nodes. Initially all tokens are added as pending nodes. When processing a clang AST node, the clients need to:
Note that all children are expected to be processed when building a node.
Call finalize() to finish building the tree and consume the root node.
Definition at line 45 of file BuildTree.cpp.
|
inline |
Definition at line 47 of file BuildTree.cpp.
|
inline |
Definition at line 49 of file BuildTree.cpp.
|
inline |
Finish building the tree and consume the root node.
Definition at line 59 of file BuildTree.cpp.
void syntax::TreeBuilder::foldNode | ( | llvm::ArrayRef< syntax::Token > | Range, |
syntax::Tree * | New | ||
) |
Populate children for New
node, assuming it covers tokens from Range
.
Definition at line 249 of file BuildTree.cpp.
|
inline |
getRange() finds the syntax tokens corresponding to the passed source locations.
First
is the start position of the first token and Last
is the start position of the last token.
Definition at line 75 of file BuildTree.cpp.
References clang::SourceLocation::isValid().
|
inline |
Definition at line 83 of file BuildTree.cpp.
References clang::Decl::getBeginLoc(), and clang::Decl::getEndLoc().
|
inline |
Definition at line 86 of file BuildTree.cpp.
void syntax::TreeBuilder::markChildToken | ( | SourceLocation | Loc, |
tok::TokenKind | Kind, | ||
NodeRole | R | ||
) |
Set role for a token starting at Loc
.
Definition at line 254 of file BuildTree.cpp.
References clang::SourceLocation::isInvalid().