@@ -52,11 +52,7 @@ class ASTContext;
52
52
// / WalkUpFromX or post-order traversal).
53
53
// /
54
54
// / \see RecursiveASTVisitor.
55
- template <bool IsConst> class DynamicRecursiveASTVisitorBase {
56
- protected:
57
- template <typename ASTNode>
58
- using MaybeConst = std::conditional_t <IsConst, const ASTNode, ASTNode>;
59
-
55
+ class DynamicRecursiveASTVisitor {
60
56
public:
61
57
// / Whether this visitor should recurse into template instantiations.
62
58
bool ShouldVisitTemplateInstantiations = false ;
@@ -72,38 +68,36 @@ template <bool IsConst> class DynamicRecursiveASTVisitorBase {
72
68
bool ShouldVisitLambdaBody = true ;
73
69
74
70
protected:
75
- DynamicRecursiveASTVisitorBase () = default ;
76
- DynamicRecursiveASTVisitorBase (DynamicRecursiveASTVisitorBase &&) = default ;
77
- DynamicRecursiveASTVisitorBase (const DynamicRecursiveASTVisitorBase &) =
78
- default ;
79
- DynamicRecursiveASTVisitorBase &
80
- operator =(DynamicRecursiveASTVisitorBase &&) = default ;
81
- DynamicRecursiveASTVisitorBase &
82
- operator =(const DynamicRecursiveASTVisitorBase &) = default ;
71
+ DynamicRecursiveASTVisitor () = default ;
72
+ DynamicRecursiveASTVisitor (DynamicRecursiveASTVisitor &&) = default ;
73
+ DynamicRecursiveASTVisitor (const DynamicRecursiveASTVisitor &) = default ;
74
+ DynamicRecursiveASTVisitor &
75
+ operator =(DynamicRecursiveASTVisitor &&) = default ;
76
+ DynamicRecursiveASTVisitor &
77
+ operator =(const DynamicRecursiveASTVisitor &) = default ;
83
78
84
79
public:
85
80
virtual void anchor ();
86
- virtual ~DynamicRecursiveASTVisitorBase () = default ;
81
+ virtual ~DynamicRecursiveASTVisitor () = default ;
87
82
88
83
// / Recursively visits an entire AST, starting from the TranslationUnitDecl.
89
84
// / \returns false if visitation was terminated early.
90
- virtual bool TraverseAST (MaybeConst< ASTContext> &AST);
85
+ virtual bool TraverseAST (ASTContext &AST);
91
86
92
87
// / Recursively visit an attribute, by dispatching to
93
88
// / Traverse*Attr() based on the argument's dynamic type.
94
89
// /
95
90
// / \returns false if the visitation was terminated early, true
96
91
// / otherwise (including when the argument is a Null type location).
97
- virtual bool TraverseAttr (MaybeConst< Attr> *At);
92
+ virtual bool TraverseAttr (Attr *At);
98
93
99
94
// / Recursively visit a constructor initializer. This
100
95
// / automatically dispatches to another visitor for the initializer
101
96
// / expression, but not for the name of the initializer, so may
102
97
// / be overridden for clients that need access to the name.
103
98
// /
104
99
// / \returns false if the visitation was terminated early, true otherwise.
105
- virtual bool
106
- TraverseConstructorInitializer (MaybeConst<CXXCtorInitializer> *Init);
100
+ virtual bool TraverseConstructorInitializer (CXXCtorInitializer *Init);
107
101
108
102
// / Recursively visit a base specifier. This can be overridden by a
109
103
// / subclass.
@@ -116,7 +110,7 @@ template <bool IsConst> class DynamicRecursiveASTVisitorBase {
116
110
// /
117
111
// / \returns false if the visitation was terminated early, true
118
112
// / otherwise (including when the argument is NULL).
119
- virtual bool TraverseDecl (MaybeConst< Decl> *D);
113
+ virtual bool TraverseDecl (Decl *D);
120
114
121
115
// / Recursively visit a name with its location information.
122
116
// /
@@ -127,15 +121,13 @@ template <bool IsConst> class DynamicRecursiveASTVisitorBase {
127
121
// / will be used to initialize the capture.
128
122
// /
129
123
// / \returns false if the visitation was terminated early, true otherwise.
130
- virtual bool TraverseLambdaCapture (MaybeConst<LambdaExpr> *LE,
131
- const LambdaCapture *C,
132
- MaybeConst<Expr> *Init);
124
+ virtual bool TraverseLambdaCapture (LambdaExpr *LE, const LambdaCapture *C,
125
+ Expr *Init);
133
126
134
127
// / Recursively visit a C++ nested-name-specifier.
135
128
// /
136
129
// / \returns false if the visitation was terminated early, true otherwise.
137
- virtual bool
138
- TraverseNestedNameSpecifier (MaybeConst<NestedNameSpecifier> *NNS);
130
+ virtual bool TraverseNestedNameSpecifier (NestedNameSpecifier *NNS);
139
131
140
132
// / Recursively visit a C++ nested-name-specifier with location
141
133
// / information.
@@ -148,7 +140,7 @@ template <bool IsConst> class DynamicRecursiveASTVisitorBase {
148
140
// /
149
141
// / \returns false if the visitation was terminated early, true
150
142
// / otherwise (including when the argument is nullptr).
151
- virtual bool TraverseStmt (MaybeConst< Stmt> *S);
143
+ virtual bool TraverseStmt (Stmt *S);
152
144
153
145
// / Recursively visit a template argument and dispatch to the
154
146
// / appropriate method for the argument type.
@@ -198,86 +190,74 @@ template <bool IsConst> class DynamicRecursiveASTVisitorBase {
198
190
199
191
// / Traverse a concept (requirement).
200
192
virtual bool TraverseTypeConstraint (const TypeConstraint *C);
201
- virtual bool TraverseConceptRequirement (MaybeConst<concepts::Requirement> *R);
202
-
203
- virtual bool
204
- TraverseConceptTypeRequirement (MaybeConst<concepts::TypeRequirement> *R);
205
-
206
- virtual bool
207
- TraverseConceptExprRequirement (MaybeConst<concepts::ExprRequirement> *R);
208
-
209
- virtual bool
210
- TraverseConceptNestedRequirement (MaybeConst<concepts::NestedRequirement> *R);
211
-
212
- virtual bool TraverseConceptReference (MaybeConst<ConceptReference> *CR);
213
- virtual bool VisitConceptReference (MaybeConst<ConceptReference> *CR) {
214
- return true ;
215
- }
193
+ virtual bool TraverseConceptRequirement (concepts::Requirement *R);
194
+ virtual bool TraverseConceptTypeRequirement (concepts::TypeRequirement *R);
195
+ virtual bool TraverseConceptExprRequirement (concepts::ExprRequirement *R);
196
+ virtual bool TraverseConceptNestedRequirement (concepts::NestedRequirement *R);
197
+ virtual bool TraverseConceptReference (ConceptReference *CR);
198
+ virtual bool VisitConceptReference (ConceptReference *CR) { return true ; }
216
199
217
200
// / Visit a node.
218
- virtual bool VisitAttr (MaybeConst< Attr> *A) { return true ; }
219
- virtual bool VisitDecl (MaybeConst< Decl> *D) { return true ; }
220
- virtual bool VisitStmt (MaybeConst< Stmt> *S) { return true ; }
221
- virtual bool VisitType (MaybeConst< Type> *T) { return true ; }
201
+ virtual bool VisitAttr (Attr *A) { return true ; }
202
+ virtual bool VisitDecl (Decl *D) { return true ; }
203
+ virtual bool VisitStmt (Stmt *S) { return true ; }
204
+ virtual bool VisitType (Type *T) { return true ; }
222
205
virtual bool VisitTypeLoc (TypeLoc TL) { return true ; }
223
206
224
207
// / Walk up from a node.
225
- bool WalkUpFromDecl (MaybeConst< Decl> *D) { return VisitDecl (D); }
226
- bool WalkUpFromStmt (MaybeConst< Stmt> *S) { return VisitStmt (S); }
227
- bool WalkUpFromType (MaybeConst< Type> *T) { return VisitType (T); }
208
+ bool WalkUpFromDecl (Decl *D) { return VisitDecl (D); }
209
+ bool WalkUpFromStmt (Stmt *S) { return VisitStmt (S); }
210
+ bool WalkUpFromType (Type *T) { return VisitType (T); }
228
211
bool WalkUpFromTypeLoc (TypeLoc TL) { return VisitTypeLoc (TL); }
229
212
230
213
// / Invoked before visiting a statement or expression via data recursion.
231
214
// /
232
215
// / \returns false to skip visiting the node, true otherwise.
233
- virtual bool dataTraverseStmtPre (MaybeConst< Stmt> *S) { return true ; }
216
+ virtual bool dataTraverseStmtPre (Stmt *S) { return true ; }
234
217
235
218
// / Invoked after visiting a statement or expression via data recursion.
236
219
// / This is not invoked if the previously invoked \c dataTraverseStmtPre
237
220
// / returned false.
238
221
// /
239
222
// / \returns false if the visitation was terminated early, true otherwise.
240
- virtual bool dataTraverseStmtPost (MaybeConst< Stmt> *S) { return true ; }
241
- virtual bool dataTraverseNode (MaybeConst< Stmt> *S);
223
+ virtual bool dataTraverseStmtPost (Stmt *S) { return true ; }
224
+ virtual bool dataTraverseNode (Stmt *S);
242
225
243
226
#define DEF_TRAVERSE_TMPL_INST (kind ) \
244
- virtual bool TraverseTemplateInstantiations ( \
245
- MaybeConst<kind##TemplateDecl> *D);
227
+ virtual bool TraverseTemplateInstantiations (kind##TemplateDecl *D);
246
228
DEF_TRAVERSE_TMPL_INST (Class)
247
229
DEF_TRAVERSE_TMPL_INST (Var)
248
230
DEF_TRAVERSE_TMPL_INST (Function)
249
231
#undef DEF_TRAVERSE_TMPL_INST
250
232
251
233
// Decls.
252
234
#define ABSTRACT_DECL (DECL )
253
- #define DECL (CLASS, BASE ) \
254
- virtual bool Traverse##CLASS##Decl(MaybeConst<CLASS##Decl> *D);
235
+ #define DECL (CLASS, BASE ) virtual bool Traverse##CLASS##Decl(CLASS##Decl *D);
255
236
#include " clang/AST/DeclNodes.inc"
256
237
257
238
#define DECL (CLASS, BASE ) \
258
- bool WalkUpFrom##CLASS##Decl(MaybeConst< CLASS##Decl> *D); \
259
- virtual bool Visit##CLASS##Decl(MaybeConst< CLASS##Decl> *D) { return true ; }
239
+ bool WalkUpFrom##CLASS##Decl(CLASS##Decl *D); \
240
+ virtual bool Visit##CLASS##Decl(CLASS##Decl *D) { return true ; }
260
241
#include " clang/AST/DeclNodes.inc"
261
242
262
243
// Stmts.
263
244
#define ABSTRACT_STMT (STMT )
264
- #define STMT (CLASS, PARENT ) virtual bool Traverse##CLASS(MaybeConst< CLASS> *S);
245
+ #define STMT (CLASS, PARENT ) virtual bool Traverse##CLASS(CLASS *S);
265
246
#include " clang/AST/StmtNodes.inc"
266
247
267
248
#define STMT (CLASS, PARENT ) \
268
- bool WalkUpFrom##CLASS(MaybeConst< CLASS> *S); \
269
- virtual bool Visit##CLASS(MaybeConst< CLASS> *S) { return true ; }
249
+ bool WalkUpFrom##CLASS(CLASS *S); \
250
+ virtual bool Visit##CLASS(CLASS *S) { return true ; }
270
251
#include " clang/AST/StmtNodes.inc"
271
252
272
253
// Types.
273
254
#define ABSTRACT_TYPE (CLASS, BASE )
274
- #define TYPE (CLASS, BASE ) \
275
- virtual bool Traverse##CLASS##Type(MaybeConst<CLASS##Type> *T);
255
+ #define TYPE (CLASS, BASE ) virtual bool Traverse##CLASS##Type(CLASS##Type *T);
276
256
#include " clang/AST/TypeNodes.inc"
277
257
278
258
#define TYPE (CLASS, BASE ) \
279
- bool WalkUpFrom##CLASS##Type(MaybeConst< CLASS##Type> *T); \
280
- virtual bool Visit##CLASS##Type(MaybeConst< CLASS##Type> *T) { return true ; }
259
+ bool WalkUpFrom##CLASS##Type(CLASS##Type *T); \
260
+ virtual bool Visit##CLASS##Type(CLASS##Type *T) { return true ; }
281
261
#include " clang/AST/TypeNodes.inc"
282
262
283
263
// TypeLocs.
@@ -291,14 +271,6 @@ template <bool IsConst> class DynamicRecursiveASTVisitorBase {
291
271
virtual bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TL) { return true ; }
292
272
#include " clang/AST/TypeLocNodes.def"
293
273
};
294
-
295
- extern template class DynamicRecursiveASTVisitorBase <false >;
296
- extern template class DynamicRecursiveASTVisitorBase <true >;
297
-
298
- using DynamicRecursiveASTVisitor =
299
- DynamicRecursiveASTVisitorBase</* Const=*/ false >;
300
- using ConstDynamicRecursiveASTVisitor =
301
- DynamicRecursiveASTVisitorBase</* Const=*/ true >;
302
274
} // namespace clang
303
275
304
276
#endif // LLVM_CLANG_AST_DYNAMIC_RECURSIVE_AST_VISITOR_H
0 commit comments