clang 20.0.0git
|
Recursive AST visitor that supports extension via dynamic dispatch. More...
#include "clang/AST/DynamicRecursiveASTVisitor.h"
Public Member Functions | |
virtual void | anchor () |
virtual | ~DynamicRecursiveASTVisitor ()=default |
virtual bool | TraverseAST (ASTContext &AST) |
Recursively visits an entire AST, starting from the TranslationUnitDecl. | |
virtual bool | TraverseAttr (Attr *At) |
Recursively visit an attribute, by dispatching to Traverse*Attr() based on the argument's dynamic type. | |
virtual bool | TraverseConstructorInitializer (CXXCtorInitializer *Init) |
Recursively visit a constructor initializer. | |
virtual bool | TraverseCXXBaseSpecifier (const CXXBaseSpecifier &Base) |
Recursively visit a base specifier. | |
virtual bool | TraverseDecl (Decl *D) |
Recursively visit a declaration, by dispatching to Traverse*Decl() based on the argument's dynamic type. | |
virtual bool | TraverseDeclarationNameInfo (DeclarationNameInfo NameInfo) |
Recursively visit a name with its location information. | |
virtual bool | TraverseLambdaCapture (LambdaExpr *LE, const LambdaCapture *C, Expr *Init) |
Recursively visit a lambda capture. | |
virtual bool | TraverseNestedNameSpecifier (NestedNameSpecifier *NNS) |
Recursively visit a C++ nested-name-specifier. | |
virtual bool | TraverseNestedNameSpecifierLoc (NestedNameSpecifierLoc NNS) |
Recursively visit a C++ nested-name-specifier with location information. | |
virtual bool | TraverseStmt (Stmt *S) |
Recursively visit a statement or expression, by dispatching to Traverse*() based on the argument's dynamic type. | |
virtual bool | TraverseTemplateArgument (const TemplateArgument &Arg) |
Recursively visit a template argument and dispatch to the appropriate method for the argument type. | |
virtual bool | TraverseTemplateArgumentLoc (const TemplateArgumentLoc &ArgLoc) |
Recursively visit a template argument location and dispatch to the appropriate method for the argument type. | |
bool | TraverseTemplateArguments (ArrayRef< TemplateArgument > Args) |
Recursively visit a set of template arguments. | |
virtual bool | TraverseTemplateName (TemplateName Template) |
Recursively visit a template name and dispatch to the appropriate method. | |
virtual bool | TraverseType (QualType T) |
Recursively visit a type, by dispatching to Traverse*Type() based on the argument's getTypeClass() property. | |
virtual bool | TraverseTypeLoc (TypeLoc TL) |
Recursively visit a type with location, by dispatching to Traverse*TypeLoc() based on the argument type's getTypeClass() property. | |
virtual bool | TraverseObjCProtocolLoc (ObjCProtocolLoc ProtocolLoc) |
Recursively visit an Objective-C protocol reference with location information. | |
virtual bool | TraverseTypeConstraint (const TypeConstraint *C) |
Traverse a concept (requirement). | |
virtual bool | TraverseConceptRequirement (concepts::Requirement *R) |
virtual bool | TraverseConceptTypeRequirement (concepts::TypeRequirement *R) |
virtual bool | TraverseConceptExprRequirement (concepts::ExprRequirement *R) |
virtual bool | TraverseConceptNestedRequirement (concepts::NestedRequirement *R) |
virtual bool | TraverseConceptReference (ConceptReference *CR) |
virtual bool | VisitConceptReference (ConceptReference *CR) |
virtual bool | VisitAttr (Attr *A) |
Visit a node. | |
virtual bool | VisitDecl (Decl *D) |
virtual bool | VisitStmt (Stmt *S) |
virtual bool | VisitType (Type *T) |
virtual bool | VisitTypeLoc (TypeLoc TL) |
bool | WalkUpFromDecl (Decl *D) |
Walk up from a node. | |
bool | WalkUpFromStmt (Stmt *S) |
bool | WalkUpFromType (Type *T) |
bool | WalkUpFromTypeLoc (TypeLoc TL) |
virtual bool | dataTraverseStmtPre (Stmt *S) |
Invoked before visiting a statement or expression via data recursion. | |
virtual bool | dataTraverseStmtPost (Stmt *S) |
Invoked after visiting a statement or expression via data recursion. | |
virtual bool | dataTraverseNode (Stmt *S) |
Public Attributes | |
bool | ShouldVisitTemplateInstantiations = false |
Whether this visitor should recurse into template instantiations. | |
bool | ShouldWalkTypesOfTypeLocs = true |
Whether this visitor should recurse into the types of TypeLocs. | |
bool | ShouldVisitImplicitCode = false |
Whether this visitor should recurse into implicit code, e.g. | |
bool | ShouldVisitLambdaBody = true |
Whether this visitor should recurse into lambda body. | |
Protected Member Functions | |
DynamicRecursiveASTVisitor ()=default | |
DynamicRecursiveASTVisitor (DynamicRecursiveASTVisitor &&)=default | |
DynamicRecursiveASTVisitor (const DynamicRecursiveASTVisitor &)=default | |
DynamicRecursiveASTVisitor & | operator= (DynamicRecursiveASTVisitor &&)=default |
DynamicRecursiveASTVisitor & | operator= (const DynamicRecursiveASTVisitor &)=default |
Recursive AST visitor that supports extension via dynamic dispatch.
Like RecursiveASTVisitor, this class allows for traversal of arbitrarily complex ASTs. The main difference is that this uses virtual functions instead of CRTP, which greatly improves compile times of Clang itself, as well as binary size.
Instead of functions (e.g. shouldVisitImplicitCode()), this class uses member variables (e.g. ShouldVisitImplicitCode) to control visitation behaviour.
However, there is no support for overriding some of the less commonly used features of the RAV, such as WalkUpFromX or attribute traversal (attributes can still be traversed, but you can't change what happens when we traverse one).
The following is a list of RAV features that are NOT customisable:
Furthermore, post-order traversal is not supported at all.
Prefer to use this over RecursiveASTVisitor unless you absolutely need to use one of the features listed above (e.g. overriding WalkUpFromX or post-order traversal).
Definition at line 55 of file DynamicRecursiveASTVisitor.h.
|
protecteddefault |
|
protecteddefault |
|
protecteddefault |
|
virtualdefault |
|
virtual |
Definition at line 269 of file DynamicRecursiveASTVisitor.cpp.
Definition at line 386 of file DynamicRecursiveASTVisitor.cpp.
Invoked after visiting a statement or expression via data recursion.
This is not invoked if the previously invoked dataTraverseStmtPre
returned false.
Definition at line 223 of file DynamicRecursiveASTVisitor.h.
Invoked before visiting a statement or expression via data recursion.
Definition at line 216 of file DynamicRecursiveASTVisitor.h.
|
protecteddefault |
|
protecteddefault |
|
virtual |
Recursively visits an entire AST, starting from the TranslationUnitDecl.
Definition at line 271 of file DynamicRecursiveASTVisitor.cpp.
Recursively visit an attribute, by dispatching to Traverse*Attr() based on the argument's dynamic type.
Definition at line 275 of file DynamicRecursiveASTVisitor.cpp.
|
virtual |
Definition at line 347 of file DynamicRecursiveASTVisitor.cpp.
|
virtual |
Definition at line 352 of file DynamicRecursiveASTVisitor.cpp.
|
virtual |
Definition at line 358 of file DynamicRecursiveASTVisitor.cpp.
|
virtual |
Definition at line 338 of file DynamicRecursiveASTVisitor.cpp.
|
virtual |
Definition at line 342 of file DynamicRecursiveASTVisitor.cpp.
|
virtual |
Recursively visit a constructor initializer.
This automatically dispatches to another visitor for the initializer expression, but not for the name of the initializer, so may be overridden for clients that need access to the name.
Definition at line 279 of file DynamicRecursiveASTVisitor.cpp.
References clang::Init.
Referenced by clang::Sema::DiagnoseImmediateEscalatingReason().
|
virtual |
Recursively visit a base specifier.
This can be overridden by a subclass.
Definition at line 363 of file DynamicRecursiveASTVisitor.cpp.
Recursively visit a declaration, by dispatching to Traverse*Decl() based on the argument's dynamic type.
Reimplemented in clang::dataflow::AnalysisASTVisitor, and clang::ast_matchers::MatchDescendantVisitor.
Definition at line 285 of file DynamicRecursiveASTVisitor.cpp.
References D.
Referenced by clang::CallGraph::addToCallGraph(), clang::dataflow::AnalysisASTVisitor::TraverseDecl(), and clang::ast_matchers::MatchDescendantVisitor::TraverseDecl().
|
virtual |
Recursively visit a name with its location information.
Definition at line 368 of file DynamicRecursiveASTVisitor.cpp.
|
virtual |
Recursively visit a lambda capture.
Init
is the expression that will be used to initialize the capture.
Definition at line 289 of file DynamicRecursiveASTVisitor.cpp.
References clang::C, and clang::Init.
|
virtual |
Recursively visit a C++ nested-name-specifier.
Definition at line 374 of file DynamicRecursiveASTVisitor.cpp.
|
virtual |
Recursively visit a C++ nested-name-specifier with location information.
Definition at line 380 of file DynamicRecursiveASTVisitor.cpp.
|
virtual |
Recursively visit an Objective-C protocol reference with location information.
Definition at line 332 of file DynamicRecursiveASTVisitor.cpp.
Recursively visit a statement or expression, by dispatching to Traverse*() based on the argument's dynamic type.
Reimplemented in clang::ast_matchers::MatchDescendantVisitor, and clang::CallGraph.
Definition at line 296 of file DynamicRecursiveASTVisitor.cpp.
Referenced by clang::dataflow::getReferencedDecls(), clang::dataflow::ReferencedDeclsVisitor::traverseConstructorInits(), and clang::ast_matchers::MatchDescendantVisitor::TraverseStmt().
|
virtual |
Recursively visit a template argument and dispatch to the appropriate method for the argument type.
Definition at line 300 of file DynamicRecursiveASTVisitor.cpp.
|
virtual |
Recursively visit a template argument location and dispatch to the appropriate method for the argument type.
Definition at line 310 of file DynamicRecursiveASTVisitor.cpp.
bool DynamicRecursiveASTVisitor::TraverseTemplateArguments | ( | ArrayRef< TemplateArgument > | Args | ) |
Recursively visit a set of template arguments.
Definition at line 305 of file DynamicRecursiveASTVisitor.cpp.
|
virtual |
Recursively visit a template name and dispatch to the appropriate method.
Definition at line 316 of file DynamicRecursiveASTVisitor.cpp.
Recursively visit a type, by dispatching to Traverse*Type() based on the argument's getTypeClass() property.
Definition at line 320 of file DynamicRecursiveASTVisitor.cpp.
References clang::T.
|
virtual |
Traverse a concept (requirement).
Definition at line 328 of file DynamicRecursiveASTVisitor.cpp.
References clang::C.
Recursively visit a type with location, by dispatching to Traverse*TypeLoc() based on the argument type's getTypeClass() property.
Definition at line 324 of file DynamicRecursiveASTVisitor.cpp.
Visit a node.
Definition at line 201 of file DynamicRecursiveASTVisitor.h.
|
inlinevirtual |
Definition at line 198 of file DynamicRecursiveASTVisitor.h.
Reimplemented in clang::dataflow::ReferencedDeclsVisitor.
Definition at line 202 of file DynamicRecursiveASTVisitor.h.
Referenced by WalkUpFromDecl().
Definition at line 203 of file DynamicRecursiveASTVisitor.h.
Referenced by isInCoroutineStmt(), ImmediateCallVisitor::VisitCallExpr(), ImmediateCallVisitor::VisitCXXConstructExpr(), ImmediateCallVisitor::VisitSourceLocExpr(), and WalkUpFromStmt().
Definition at line 204 of file DynamicRecursiveASTVisitor.h.
Referenced by WalkUpFromType().
Definition at line 205 of file DynamicRecursiveASTVisitor.h.
Referenced by WalkUpFromTypeLoc().
Walk up from a node.
Definition at line 208 of file DynamicRecursiveASTVisitor.h.
References D, and VisitDecl().
Definition at line 209 of file DynamicRecursiveASTVisitor.h.
References VisitStmt().
Definition at line 210 of file DynamicRecursiveASTVisitor.h.
References clang::T, and VisitType().
Definition at line 211 of file DynamicRecursiveASTVisitor.h.
References VisitTypeLoc().
Whether this visitor should recurse into implicit code, e.g.
implicit constructors and destructors.
Definition at line 65 of file DynamicRecursiveASTVisitor.h.
Referenced by clang::dataflow::AnalysisASTVisitor::AnalysisASTVisitor(), clang::CallGraph::CallGraph(), and clang::ast_matchers::MatchDescendantVisitor::MatchDescendantVisitor().
Whether this visitor should recurse into lambda body.
Definition at line 68 of file DynamicRecursiveASTVisitor.h.
Referenced by clang::dataflow::AnalysisASTVisitor::AnalysisASTVisitor().
Whether this visitor should recurse into template instantiations.
Definition at line 58 of file DynamicRecursiveASTVisitor.h.
Referenced by clang::CallGraph::CallGraph(), and clang::ast_matchers::MatchDescendantVisitor::MatchDescendantVisitor().
Whether this visitor should recurse into the types of TypeLocs.
Definition at line 61 of file DynamicRecursiveASTVisitor.h.
Referenced by clang::CallGraph::CallGraph().