93 DynamicRecursiveASTVisitorBase<Const> &Visitor;
94 Impl(DynamicRecursiveASTVisitorBase<Const> &Visitor) : Visitor(Visitor) {}
96 bool shouldVisitTemplateInstantiations()
const {
97 return Visitor.ShouldVisitTemplateInstantiations;
100 bool shouldWalkTypesOfTypeLocs()
const {
101 return Visitor.ShouldWalkTypesOfTypeLocs;
104 bool shouldVisitImplicitCode()
const {
105 return Visitor.ShouldVisitImplicitCode;
108 bool shouldVisitLambdaBody()
const {
return Visitor.ShouldVisitLambdaBody; }
113 bool shouldTraversePostOrder()
const {
return false; }
115 bool TraverseAST(ASTContext &AST) {
return Visitor.TraverseAST(AST); }
116 bool TraverseAttr(Attr *At) {
return Visitor.TraverseAttr(At); }
117 bool TraverseDecl(Decl *D) {
return Visitor.TraverseDecl(D); }
118 bool TraverseType(QualType
T,
bool TraverseQualifier =
true) {
119 return Visitor.TraverseType(
T, TraverseQualifier);
121 bool TraverseTypeLoc(TypeLoc TL,
bool TraverseQualifier =
true) {
122 return Visitor.TraverseTypeLoc(TL, TraverseQualifier);
124 bool TraverseStmt(Stmt *S) {
return Visitor.TraverseStmt(S); }
126 bool TraverseConstructorInitializer(CXXCtorInitializer *
Init) {
127 return Visitor.TraverseConstructorInitializer(
Init);
130 bool TraverseTemplateArgument(
const TemplateArgument &Arg) {
131 return Visitor.TraverseTemplateArgument(Arg);
134 bool TraverseTemplateArgumentLoc(
const TemplateArgumentLoc &ArgLoc) {
135 return Visitor.TraverseTemplateArgumentLoc(ArgLoc);
139 return Visitor.TraverseTemplateName(
Template);
142 bool TraverseObjCProtocolLoc(ObjCProtocolLoc ProtocolLoc) {
143 return Visitor.TraverseObjCProtocolLoc(ProtocolLoc);
146 bool TraverseTypeConstraint(
const TypeConstraint *
C) {
147 return Visitor.TraverseTypeConstraint(
C);
149 bool TraverseConceptRequirement(concepts::Requirement *R) {
150 return Visitor.TraverseConceptRequirement(R);
152 bool TraverseConceptTypeRequirement(concepts::TypeRequirement *R) {
153 return Visitor.TraverseConceptTypeRequirement(R);
155 bool TraverseConceptExprRequirement(concepts::ExprRequirement *R) {
156 return Visitor.TraverseConceptExprRequirement(R);
158 bool TraverseConceptNestedRequirement(concepts::NestedRequirement *R) {
159 return Visitor.TraverseConceptNestedRequirement(R);
162 bool TraverseConceptReference(ConceptReference *CR) {
163 return Visitor.TraverseConceptReference(CR);
166 bool TraverseCXXBaseSpecifier(
const CXXBaseSpecifier &Base) {
167 return Visitor.TraverseCXXBaseSpecifier(Base);
170 bool TraverseDeclarationNameInfo(DeclarationNameInfo NameInfo) {
171 return Visitor.TraverseDeclarationNameInfo(NameInfo);
174 bool TraverseLambdaCapture(
LambdaExpr *LE,
const LambdaCapture *
C,
176 return Visitor.TraverseLambdaCapture(LE,
C,
Init);
179 bool TraverseNestedNameSpecifier(NestedNameSpecifier NNS) {
180 return Visitor.TraverseNestedNameSpecifier(NNS);
184 return Visitor.TraverseNestedNameSpecifierLoc(NNS);
187 bool VisitConceptReference(ConceptReference *CR) {
188 return Visitor.VisitConceptReference(CR);
191 bool dataTraverseStmtPre(Stmt *S) {
return Visitor.dataTraverseStmtPre(S); }
192 bool dataTraverseStmtPost(Stmt *S) {
return Visitor.dataTraverseStmtPost(S); }
196 bool dataTraverseNode(
202 return Visitor.dataTraverseNode(S);
206 bool VisitAttr(Attr *A) {
return Visitor.VisitAttr(A); }
207 bool VisitDecl(Decl *D) {
return Visitor.VisitDecl(D); }
208 bool VisitStmt(Stmt *S) {
return Visitor.VisitStmt(S); }
209 bool VisitType(
Type *
T) {
return Visitor.VisitType(
T); }
210 bool VisitTypeLoc(TypeLoc TL) {
return Visitor.VisitTypeLoc(TL); }
212#define DEF_TRAVERSE_TMPL_INST(kind) \
213 bool TraverseTemplateInstantiations(kind##TemplateDecl *D) { \
214 return Visitor.TraverseTemplateInstantiations(D); \
219#undef DEF_TRAVERSE_TMPL_INST
222#define ABSTRACT_DECL(DECL)
223#define DECL(CLASS, BASE) \
224 bool Traverse##CLASS##Decl(CLASS##Decl *D) { \
225 return Visitor.Traverse##CLASS##Decl(D); \
227#include "clang/AST/DeclNodes.inc"
229#define DECL(CLASS, BASE) \
230 bool Visit##CLASS##Decl(CLASS##Decl *D) { \
231 return Visitor.Visit##CLASS##Decl(D); \
233#include "clang/AST/DeclNodes.inc"
236#define ABSTRACT_STMT(STMT)
237#define STMT(CLASS, PARENT) \
238 bool Traverse##CLASS(CLASS *S) { return Visitor.Traverse##CLASS(S); }
239#include "clang/AST/StmtNodes.inc"
241#define STMT(CLASS, PARENT) \
242 bool Visit##CLASS(CLASS *S) { return Visitor.Visit##CLASS(S); }
243#include "clang/AST/StmtNodes.inc"
246#define ABSTRACT_TYPE(CLASS, BASE)
247#define TYPE(CLASS, BASE) \
248 bool Traverse##CLASS##Type(CLASS##Type *T, bool TraverseQualifier) { \
249 return Visitor.Traverse##CLASS##Type(T, TraverseQualifier); \
251#include "clang/AST/TypeNodes.inc"
253#define TYPE(CLASS, BASE) \
254 bool Visit##CLASS##Type(CLASS##Type *T) { \
255 return Visitor.Visit##CLASS##Type(T); \
257#include "clang/AST/TypeNodes.inc"
260#define ABSTRACT_TYPELOC(CLASS, BASE)
261#define TYPELOC(CLASS, BASE) \
262 bool Traverse##CLASS##TypeLoc(CLASS##TypeLoc TL, bool TraverseQualifier) { \
263 return Visitor.Traverse##CLASS##TypeLoc(TL, TraverseQualifier); \
265#include "clang/AST/TypeLocNodes.def"
267#define TYPELOC(CLASS, BASE) \
268 bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TL) { \
269 return Visitor.Visit##CLASS##TypeLoc(TL); \
271#include "clang/AST/TypeLocNodes.def"
283#define FORWARD_TO_BASE(Function, Type, RefOrPointer) \
284 template <bool Const> \
285 bool DynamicRecursiveASTVisitorBase<Const>::Function( \
286 MaybeConst<Type> RefOrPointer Param) { \
287 return Impl<Const>(*this).RecursiveASTVisitor<Impl<Const>>::Function( \
288 const_cast<Type RefOrPointer>(Param)); \
292#define FORWARD_TO_BASE_EXACT(Function, Type) \
293 template <bool Const> \
294 bool DynamicRecursiveASTVisitorBase<Const>::Function(Type Param) { \
295 return Impl<Const>(*this).RecursiveASTVisitor<Impl<Const>>::Function( \
325 return Impl<Const>(*this).RecursiveASTVisitor<Impl<Const>>::TraverseType(
326 T, TraverseQualifier);
331 TypeLoc TL,
bool TraverseQualifier) {
333 TL, TraverseQualifier);
344 return Impl<Const>(*
this)
353 const_cast<Stmt *
>(S),
nullptr);
357#define ABSTRACT_DECL(DECL)
358#define DECL(CLASS, BASE) \
359 FORWARD_TO_BASE(Traverse##CLASS##Decl, CLASS##Decl, *) \
360 FORWARD_TO_BASE(WalkUpFrom##CLASS##Decl, CLASS##Decl, *)
361#include "clang/AST/DeclNodes.inc"
364#define ABSTRACT_STMT(STMT)
365#define STMT(CLASS, PARENT) FORWARD_TO_BASE(Traverse##CLASS, CLASS, *)
366#include "clang/AST/StmtNodes.inc"
368#define STMT(CLASS, PARENT) FORWARD_TO_BASE(WalkUpFrom##CLASS, CLASS, *)
369#include "clang/AST/StmtNodes.inc"
372#define ABSTRACT_TYPE(CLASS, BASE)
373#define TYPE(CLASS, BASE) \
374 template <bool Const> \
375 bool DynamicRecursiveASTVisitorBase<Const>::Traverse##CLASS##Type( \
376 MaybeConst<CLASS##Type> *T, bool TraverseQualifier) { \
377 return Impl<Const>(*this) \
378 .RecursiveASTVisitor<Impl<Const>>::Traverse##CLASS##Type( \
379 const_cast<CLASS##Type *>(T), TraverseQualifier); \
381 FORWARD_TO_BASE(WalkUpFrom##CLASS##Type, CLASS##Type, *)
382#include "clang/AST/TypeNodes.inc"
384#define ABSTRACT_TYPELOC(CLASS, BASE)
385#define TYPELOC(CLASS, BASE) \
386 template <bool Const> \
387 bool DynamicRecursiveASTVisitorBase<Const>::Traverse##CLASS##TypeLoc( \
388 CLASS##TypeLoc TL, bool TraverseQualifier) { \
389 return Impl<Const>(*this) \
390 .RecursiveASTVisitor<Impl<Const>>::Traverse##CLASS##TypeLoc( \
391 TL, TraverseQualifier); \
393#include "clang/AST/TypeLocNodes.def"
395#define TYPELOC(CLASS, BASE) \
396 FORWARD_TO_BASE_EXACT(WalkUpFrom##CLASS##TypeLoc, CLASS##TypeLoc)
397#include "clang/AST/TypeLocNodes.def"
bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc QualifierLoc)
#define FORWARD_TO_BASE_EXACT(Function, Type)
#define FORWARD_TO_BASE(Function, Type, RefOrPointer)
#define DEF_TRAVERSE_TMPL_INST(kind)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Attr - This represents one attribute.
Represents a base class of a C++ class.
Represents a C++ base or member initializer.
Declaration of a class template.
A reference to a concept and its template args, as it appears in the code.
Decl - This represents one declaration (or definition), e.g.
Recursive AST visitor that supports extension via dynamic dispatch.
std::conditional_t< IsConst, const ASTNode, ASTNode > MaybeConst
virtual bool TraverseTypeLoc(TypeLoc TL, bool TraverseQualifier=true)
Recursively visit a type with location, by dispatching to Traverse*TypeLoc() based on the argument ty...
virtual bool TraverseLambdaCapture(MaybeConst< LambdaExpr > *LE, const LambdaCapture *C, MaybeConst< Expr > *Init)
Recursively visit a lambda capture.
virtual bool dataTraverseNode(MaybeConst< Stmt > *S)
This represents one expression.
Declaration of a template function.
Describes the capture of a variable or of this, or of a C++1y init-capture.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
A C++ nested-name-specifier augmented with source location information.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
A (possibly-)qualified type.
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
SmallVectorImpl< llvm::PointerIntPair< Stmt *, 1, bool > > DataRecursionQueue
A queue used for performing data recursion over statements.
Stmt - This represents one statement.
Location wrapper for a TemplateArgument.
Represents a template argument.
Represents a C++ template name within the type system.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Base wrapper for a particular "section" of type source info.
Declaration of a variable template.
The JSON file list parser is used to communicate input to InstallAPI.
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
const FunctionProtoType * T
@ Template
We are parsing a template declaration.
@ Type
The name was classified as a type.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...