clang 22.0.0git
|
Recursive AST visitor that supports extension via dynamic dispatch. More...
#include "clang/AST/DynamicRecursiveASTVisitor.h"
Public Member Functions | |
virtual void | anchor () |
virtual | ~DynamicRecursiveASTVisitorBase ()=default |
virtual bool | TraverseAST (MaybeConst< ASTContext > &AST) |
Recursively visits an entire AST, starting from the TranslationUnitDecl. | |
virtual bool | TraverseAttr (MaybeConst< Attr > *At) |
Recursively visit an attribute, by dispatching to Traverse*Attr() based on the argument's dynamic type. | |
virtual bool | TraverseConstructorInitializer (MaybeConst< CXXCtorInitializer > *Init) |
Recursively visit a constructor initializer. | |
virtual bool | TraverseCXXBaseSpecifier (const CXXBaseSpecifier &Base) |
Recursively visit a base specifier. | |
virtual bool | TraverseDecl (MaybeConst< 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 (MaybeConst< LambdaExpr > *LE, const LambdaCapture *C, MaybeConst< 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 (MaybeConst< 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, bool TraverseQualifier=true) |
Recursively visit a type, by dispatching to Traverse*Type() based on the argument's getTypeClass() property. | |
virtual bool | TraverseTypeLoc (TypeLoc TL, bool TraverseQualifier=true) |
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 (MaybeConst< concepts::Requirement > *R) |
virtual bool | TraverseConceptTypeRequirement (MaybeConst< concepts::TypeRequirement > *R) |
virtual bool | TraverseConceptExprRequirement (MaybeConst< concepts::ExprRequirement > *R) |
virtual bool | TraverseConceptNestedRequirement (MaybeConst< concepts::NestedRequirement > *R) |
virtual bool | TraverseConceptReference (MaybeConst< ConceptReference > *CR) |
virtual bool | VisitConceptReference (MaybeConst< ConceptReference > *CR) |
virtual bool | VisitAttr (MaybeConst< Attr > *A) |
Visit a node. | |
virtual bool | VisitDecl (MaybeConst< Decl > *D) |
virtual bool | VisitStmt (MaybeConst< Stmt > *S) |
virtual bool | VisitType (MaybeConst< Type > *T) |
virtual bool | VisitTypeLoc (TypeLoc TL) |
bool | WalkUpFromDecl (MaybeConst< Decl > *D) |
Walk up from a node. | |
bool | WalkUpFromStmt (MaybeConst< Stmt > *S) |
bool | WalkUpFromType (MaybeConst< Type > *T) |
bool | WalkUpFromTypeLoc (TypeLoc TL) |
virtual bool | dataTraverseStmtPre (MaybeConst< Stmt > *S) |
Invoked before visiting a statement or expression via data recursion. | |
virtual bool | dataTraverseStmtPost (MaybeConst< Stmt > *S) |
Invoked after visiting a statement or expression via data recursion. | |
virtual bool | dataTraverseNode (MaybeConst< 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 Types | |
template<typename ASTNode> | |
using | MaybeConst = std::conditional_t<IsConst, const ASTNode, ASTNode> |
Protected Member Functions | |
DynamicRecursiveASTVisitorBase ()=default | |
DynamicRecursiveASTVisitorBase (DynamicRecursiveASTVisitorBase &&)=default | |
DynamicRecursiveASTVisitorBase (const DynamicRecursiveASTVisitorBase &)=default | |
DynamicRecursiveASTVisitorBase & | operator= (DynamicRecursiveASTVisitorBase &&)=default |
DynamicRecursiveASTVisitorBase & | operator= (const DynamicRecursiveASTVisitorBase &)=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.
|
protected |
Definition at line 58 of file DynamicRecursiveASTVisitor.h.
|
protecteddefault |
|
protecteddefault |
|
protecteddefault |
|
virtualdefault |
|
virtual |
Definition at line 275 of file DynamicRecursiveASTVisitor.cpp.
|
virtual |
Definition at line 350 of file DynamicRecursiveASTVisitor.cpp.
References dataTraverseNode().
Referenced by dataTraverseNode().
|
inlinevirtual |
Invoked after visiting a statement or expression via data recursion.
This is not invoked if the previously invoked dataTraverseStmtPre
returned false.
Definition at line 239 of file DynamicRecursiveASTVisitor.h.
|
inlinevirtual |
Invoked before visiting a statement or expression via data recursion.
Definition at line 232 of file DynamicRecursiveASTVisitor.h.
|
protecteddefault |
|
protecteddefault |
|
virtual |
Recursively visits an entire AST, starting from the TranslationUnitDecl.
|
virtual |
Recursively visit an attribute, by dispatching to Traverse*Attr() based on the argument's dynamic type.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
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.
|
virtual |
Recursively visit a base specifier.
This can be overridden by a subclass.
|
virtual |
Recursively visit a declaration, by dispatching to Traverse*Decl() based on the argument's dynamic type.
|
virtual |
Recursively visit a name with its location information.
|
virtual |
Recursively visit a lambda capture.
Init
is the expression that will be used to initialize the capture.
Definition at line 341 of file DynamicRecursiveASTVisitor.cpp.
References clang::C, clang::Init, and TraverseLambdaCapture().
Referenced by TraverseLambdaCapture().
|
virtual |
Recursively visit a C++ nested-name-specifier.
|
virtual |
Recursively visit a C++ nested-name-specifier with location information.
|
virtual |
Recursively visit an Objective-C protocol reference with location information.
|
virtual |
Recursively visit a statement or expression, by dispatching to Traverse*() based on the argument's dynamic type.
Referenced by checkOpenMPLoop(), clang::dataflow::getReferencedDecls(), and clang::dataflow::getReferencedDecls().
|
virtual |
Recursively visit a template argument and dispatch to the appropriate method for the argument type.
|
virtual |
Recursively visit a template argument location and dispatch to the appropriate method for the argument type.
bool clang::DynamicRecursiveASTVisitorBase< IsConst >::TraverseTemplateArguments | ( | ArrayRef< TemplateArgument > | Args | ) |
Recursively visit a set of template arguments.
|
virtual |
Recursively visit a template name and dispatch to the appropriate method.
|
virtual |
Recursively visit a type, by dispatching to Traverse*Type() based on the argument's getTypeClass() property.
|
virtual |
Traverse a concept (requirement).
|
virtual |
Recursively visit a type with location, by dispatching to Traverse*TypeLoc() based on the argument type's getTypeClass() property.
Definition at line 330 of file DynamicRecursiveASTVisitor.cpp.
References TraverseTypeLoc().
Referenced by TraverseTypeLoc().
|
inlinevirtual |
Visit a node.
Definition at line 217 of file DynamicRecursiveASTVisitor.h.
|
inlinevirtual |
Definition at line 212 of file DynamicRecursiveASTVisitor.h.
|
inlinevirtual |
Definition at line 218 of file DynamicRecursiveASTVisitor.h.
Referenced by clang::DynamicRecursiveASTVisitorBase< false >::WalkUpFromDecl().
|
inlinevirtual |
Definition at line 219 of file DynamicRecursiveASTVisitor.h.
Referenced by clang::DynamicRecursiveASTVisitorBase< false >::WalkUpFromStmt().
|
inlinevirtual |
Definition at line 220 of file DynamicRecursiveASTVisitor.h.
Referenced by clang::DynamicRecursiveASTVisitorBase< false >::WalkUpFromType().
|
inlinevirtual |
Definition at line 221 of file DynamicRecursiveASTVisitor.h.
Referenced by clang::DynamicRecursiveASTVisitorBase< false >::WalkUpFromTypeLoc().
|
inline |
Walk up from a node.
Definition at line 224 of file DynamicRecursiveASTVisitor.h.
|
inline |
Definition at line 225 of file DynamicRecursiveASTVisitor.h.
|
inline |
Definition at line 226 of file DynamicRecursiveASTVisitor.h.
|
inline |
Definition at line 227 of file DynamicRecursiveASTVisitor.h.
bool clang::DynamicRecursiveASTVisitorBase< IsConst >::ShouldVisitImplicitCode = false |
Whether this visitor should recurse into implicit code, e.g.
implicit constructors and destructors.
Definition at line 69 of file DynamicRecursiveASTVisitor.h.
bool clang::DynamicRecursiveASTVisitorBase< IsConst >::ShouldVisitLambdaBody = true |
Whether this visitor should recurse into lambda body.
Definition at line 72 of file DynamicRecursiveASTVisitor.h.
bool clang::DynamicRecursiveASTVisitorBase< IsConst >::ShouldVisitTemplateInstantiations = false |
Whether this visitor should recurse into template instantiations.
Definition at line 62 of file DynamicRecursiveASTVisitor.h.
bool clang::DynamicRecursiveASTVisitorBase< IsConst >::ShouldWalkTypesOfTypeLocs = true |
Whether this visitor should recurse into the types of TypeLocs.
Definition at line 65 of file DynamicRecursiveASTVisitor.h.