clang 24.0.0git
RecursiveASTVisitor.h
Go to the documentation of this file.
1//===--- RecursiveASTVisitor.h - Recursive AST Visitor ----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the RecursiveASTVisitor interface, which recursively
10// traverses the entire AST.
11//
12//===----------------------------------------------------------------------===//
13#ifndef LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
14#define LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
15
17#include "clang/AST/Attr.h"
18#include "clang/AST/Decl.h"
19#include "clang/AST/DeclBase.h"
20#include "clang/AST/DeclCXX.h"
22#include "clang/AST/DeclObjC.h"
27#include "clang/AST/Expr.h"
28#include "clang/AST/ExprCXX.h"
30#include "clang/AST/ExprObjC.h"
36#include "clang/AST/Stmt.h"
37#include "clang/AST/StmtCXX.h"
38#include "clang/AST/StmtObjC.h"
41#include "clang/AST/StmtSYCL.h"
44#include "clang/AST/Type.h"
45#include "clang/AST/TypeLoc.h"
46#include "clang/Basic/LLVM.h"
49#include "llvm/ADT/PointerIntPair.h"
50#include "llvm/ADT/SmallVector.h"
51#include "llvm/Support/Casting.h"
52#include <algorithm>
53#include <cstddef>
54#include <type_traits>
55
56namespace clang {
57
58// A helper macro to implement short-circuiting when recursing. It
59// invokes CALL_EXPR, which must be a method call, on the derived
60// object (s.t. a user of RecursiveASTVisitor can override the method
61// in CALL_EXPR).
62#define TRY_TO(CALL_EXPR) \
63 do { \
64 if (!getDerived().CALL_EXPR) \
65 return false; \
66 } while (false)
67
68namespace detail {
69
70template <typename T, typename U>
71struct has_same_member_pointer_type : std::false_type {};
72template <typename T, typename U, typename R, typename... P>
73struct has_same_member_pointer_type<R (T::*)(P...), R (U::*)(P...)>
74 : std::true_type {};
75
76/// Returns true if and only if \p FirstMethodPtr and \p SecondMethodPtr
77/// are pointers to the same non-static member function.
78template <typename FirstMethodPtrTy, typename SecondMethodPtrTy>
79LLVM_ATTRIBUTE_ALWAYS_INLINE LLVM_ATTRIBUTE_NODEBUG auto
80isSameMethod([[maybe_unused]] FirstMethodPtrTy FirstMethodPtr,
81 [[maybe_unused]] SecondMethodPtrTy SecondMethodPtr)
82 -> bool {
83 if constexpr (has_same_member_pointer_type<FirstMethodPtrTy,
84 SecondMethodPtrTy>::value)
85 return FirstMethodPtr == SecondMethodPtr;
86 return false;
87}
88
89} // end namespace detail
90
91/// A class that does preorder or postorder
92/// depth-first traversal on the entire Clang AST and visits each node.
93///
94/// This class performs three distinct tasks:
95/// 1. traverse the AST (i.e. go to each node);
96/// 2. at a given node, walk up the class hierarchy, starting from
97/// the node's dynamic type, until the top-most class (e.g. Stmt,
98/// Decl, or Type) is reached.
99/// 3. given a (node, class) combination, where 'class' is some base
100/// class of the dynamic type of 'node', call a user-overridable
101/// function to actually visit the node.
102///
103/// These tasks are done by three groups of methods, respectively:
104/// 1. TraverseDecl(Decl *x) does task #1. It is the entry point
105/// for traversing an AST rooted at x. This method simply
106/// dispatches (i.e. forwards) to TraverseFoo(Foo *x) where Foo
107/// is the dynamic type of *x, which calls WalkUpFromFoo(x) and
108/// then recursively visits the child nodes of x.
109/// TraverseStmt(Stmt *x) and TraverseType(QualType x) work
110/// similarly.
111/// 2. WalkUpFromFoo(Foo *x) does task #2. It does not try to visit
112/// any child node of x. Instead, it first calls WalkUpFromBar(x)
113/// where Bar is the direct parent class of Foo (unless Foo has
114/// no parent), and then calls VisitFoo(x) (see the next list item).
115/// 3. VisitFoo(Foo *x) does task #3.
116///
117/// These three method groups are tiered (Traverse* > WalkUpFrom* >
118/// Visit*). A method (e.g. Traverse*) may call methods from the same
119/// tier (e.g. other Traverse*) or one tier lower (e.g. WalkUpFrom*).
120/// It may not call methods from a higher tier.
121///
122/// Note that since WalkUpFromFoo() calls WalkUpFromBar() (where Bar
123/// is Foo's super class) before calling VisitFoo(), the result is
124/// that the Visit*() methods for a given node are called in the
125/// top-down order (e.g. for a node of type NamespaceDecl, the order will
126/// be VisitDecl(), VisitNamedDecl(), and then VisitNamespaceDecl()).
127///
128/// This scheme guarantees that all Visit*() calls for the same AST
129/// node are grouped together. In other words, Visit*() methods for
130/// different nodes are never interleaved.
131///
132/// Clients of this visitor should subclass the visitor (providing
133/// themselves as the template argument, using the curiously recurring
134/// template pattern) and override any of the Traverse*, WalkUpFrom*,
135/// and Visit* methods for declarations, types, statements,
136/// expressions, or other AST nodes where the visitor should customize
137/// behavior. Most users only need to override Visit*. Advanced
138/// users may override Traverse* and WalkUpFrom* to implement custom
139/// traversal strategies. Returning false from one of these overridden
140/// functions will abort the entire traversal.
141///
142/// By default, this visitor tries to visit every part of the explicit
143/// source code exactly once. The default policy towards templates
144/// is to descend into the 'pattern' class or function body, not any
145/// explicit or implicit instantiations. Explicit specializations
146/// are still visited, and the patterns of partial specializations
147/// are visited separately. This behavior can be changed by
148/// overriding shouldVisitTemplateInstantiations() in the derived class
149/// to return true, in which case all known implicit and explicit
150/// instantiations will be visited at the same time as the pattern
151/// from which they were produced.
152///
153/// By default, this visitor preorder traverses the AST. If postorder traversal
154/// is needed, the \c shouldTraversePostOrder method needs to be overridden
155/// to return \c true.
156template <typename Derived> class RecursiveASTVisitor {
157public:
158 /// A queue used for performing data recursion over statements.
159 /// Parameters involving this type are used to implement data
160 /// recursion over Stmts and Exprs within this class, and should
161 /// typically not be explicitly specified by derived classes.
162 /// The bool bit indicates whether the statement has been traversed or not.
165
166 /// Return a reference to the derived class.
167 Derived &getDerived() { return *static_cast<Derived *>(this); }
168
169 /// Return whether this visitor should recurse into
170 /// template instantiations.
171 bool shouldVisitTemplateInstantiations() const { return false; }
172
173 /// Return whether this visitor should recurse into the types of
174 /// TypeLocs.
175 bool shouldWalkTypesOfTypeLocs() const { return true; }
176
177 /// Return whether this visitor should recurse into implicit
178 /// code, e.g., implicit constructors and destructors.
179 bool shouldVisitImplicitCode() const { return false; }
180
181 /// Return whether this visitor should recurse into lambda body
182 bool shouldVisitLambdaBody() const { return true; }
183
184 /// Return whether this visitor should traverse post-order.
185 bool shouldTraversePostOrder() const { return false; }
186
187 /// Recursively visits an entire AST, starting from the TranslationUnitDecl.
188 /// \returns false if visitation was terminated early.
190 // Currently just an alias for TraverseDecl(TUDecl), but kept in case
191 // we change the implementation again.
192 return getDerived().TraverseDecl(AST.getTranslationUnitDecl());
193 }
194
195 /// Recursively visit a statement or expression, by
196 /// dispatching to Traverse*() based on the argument's dynamic type.
197 ///
198 /// \returns false if the visitation was terminated early, true
199 /// otherwise (including when the argument is nullptr).
200 bool TraverseStmt(Stmt *S, DataRecursionQueue *Queue = nullptr);
201
202 /// Invoked before visiting a statement or expression via data recursion.
203 ///
204 /// \returns false to skip visiting the node, true otherwise.
205 bool dataTraverseStmtPre(Stmt *S) { return true; }
206
207 /// Invoked after visiting a statement or expression via data recursion.
208 /// This is not invoked if the previously invoked \c dataTraverseStmtPre
209 /// returned false.
210 ///
211 /// \returns false if the visitation was terminated early, true otherwise.
212 bool dataTraverseStmtPost(Stmt *S) { return true; }
213
214 /// Recursively visit a type, by dispatching to
215 /// Traverse*Type() based on the argument's getTypeClass() property.
216 ///
217 /// \returns false if the visitation was terminated early, true
218 /// otherwise (including when the argument is a Null type).
219 bool TraverseType(QualType T, bool TraverseQualifier = true);
220
221 /// Recursively visit a type with location, by dispatching to
222 /// Traverse*TypeLoc() based on the argument type's getTypeClass() property.
223 ///
224 /// \returns false if the visitation was terminated early, true
225 /// otherwise (including when the argument is a Null type location).
226 bool TraverseTypeLoc(TypeLoc TL, bool TraverseQualifier = true);
227
228 /// Recursively visit an attribute, by dispatching to
229 /// Traverse*Attr() based on the argument's dynamic type.
230 ///
231 /// \returns false if the visitation was terminated early, true
232 /// otherwise (including when the argument is a Null type location).
234
235 /// Recursively visit a declaration, by dispatching to
236 /// Traverse*Decl() based on the argument's dynamic type.
237 ///
238 /// \returns false if the visitation was terminated early, true
239 /// otherwise (including when the argument is NULL).
241
242 /// Recursively visit a C++ nested-name-specifier.
243 ///
244 /// \returns false if the visitation was terminated early, true otherwise.
246
247 /// Recursively visit a C++ nested-name-specifier with location
248 /// information.
249 ///
250 /// \returns false if the visitation was terminated early, true otherwise.
252
253 /// Recursively visit a name with its location information.
254 ///
255 /// \returns false if the visitation was terminated early, true otherwise.
257
258 /// Recursively visit a template name and dispatch to the
259 /// appropriate method.
260 ///
261 /// \returns false if the visitation was terminated early, true otherwise.
263 bool TraverseQualifier = true);
264
265 /// Recursively visit a template argument and dispatch to the
266 /// appropriate method for the argument type.
267 ///
268 /// \returns false if the visitation was terminated early, true otherwise.
269 // FIXME: migrate callers to TemplateArgumentLoc instead.
271
272 /// Recursively visit a template argument location and dispatch to the
273 /// appropriate method for the argument type.
274 ///
275 /// \returns false if the visitation was terminated early, true otherwise.
277
278 /// Recursively visit a set of template arguments.
279 /// This can be overridden by a subclass, but it's not expected that
280 /// will be needed -- this visitor always dispatches to another.
281 ///
282 /// \returns false if the visitation was terminated early, true otherwise.
283 // FIXME: take a TemplateArgumentLoc* (or TemplateArgumentListInfo) instead.
285
286 /// Recursively visit a base specifier. This can be overridden by a
287 /// subclass.
288 ///
289 /// \returns false if the visitation was terminated early, true otherwise.
291
292 /// Recursively visit a constructor initializer. This
293 /// automatically dispatches to another visitor for the initializer
294 /// expression, but not for the name of the initializer, so may
295 /// be overridden for clients that need access to the name.
296 ///
297 /// \returns false if the visitation was terminated early, true otherwise.
299
300 /// Recursively visit a lambda capture. \c Init is the expression that
301 /// will be used to initialize the capture.
302 ///
303 /// \returns false if the visitation was terminated early, true otherwise.
305 Expr *Init);
306
307 /// Recursively visit the syntactic or semantic form of an
308 /// initialization list.
309 ///
310 /// \returns false if the visitation was terminated early, true otherwise.
312 DataRecursionQueue *Queue = nullptr);
313
314 /// Recursively visit an Objective-C protocol reference with location
315 /// information.
316 ///
317 /// \returns false if the visitation was terminated early, true otherwise.
319
320 /// Recursively visit concept reference with location information.
321 ///
322 /// \returns false if the visitation was terminated early, true otherwise.
324
325 // Visit concept reference.
326 bool VisitConceptReference(ConceptReference *CR) { return true; }
327
328 /// Recursively visit a single component of an __builtin_offsetof
329 /// designator (a field, identifier, base-class, or array-index node).
330 ///
331 /// \returns false if the visitation was terminated early, true otherwise.
333
334 /// Visit a single component of an __builtin_offsetof designator.
335 bool VisitOffsetOfNode(const OffsetOfNode *Node) { return true; }
336
337 // ---- Methods on Attrs ----
338
339 // Visit an attribute.
340 bool VisitAttr(Attr *A) { return true; }
341
342// Declare Traverse* and empty Visit* for all Attr classes.
343#define ATTR_VISITOR_DECLS_ONLY
344#include "clang/AST/AttrVisitor.inc"
345#undef ATTR_VISITOR_DECLS_ONLY
346
347// ---- Methods on Stmts ----
348
350
351private:
352 // Traverse the given statement. If the most-derived traverse function takes a
353 // data recursion queue, pass it on; otherwise, discard it. Note that the
354 // first branch of this conditional must compile whether or not the derived
355 // class can take a queue, so if we're taking the second arm, make the first
356 // arm call our function rather than the derived class version.
357#define TRAVERSE_STMT_BASE(NAME, CLASS, VAR, QUEUE) \
358 (::clang::detail::has_same_member_pointer_type< \
359 decltype(&RecursiveASTVisitor::Traverse##NAME), \
360 decltype(&Derived::Traverse##NAME)>::value \
361 ? static_cast<std::conditional_t< \
362 ::clang::detail::has_same_member_pointer_type< \
363 decltype(&RecursiveASTVisitor::Traverse##NAME), \
364 decltype(&Derived::Traverse##NAME)>::value, \
365 Derived &, RecursiveASTVisitor &>>(*this) \
366 .Traverse##NAME(static_cast<CLASS *>(VAR), QUEUE) \
367 : getDerived().Traverse##NAME(static_cast<CLASS *>(VAR)))
368
369// Try to traverse the given statement, or enqueue it if we're performing data
370// recursion in the middle of traversing another statement. Can only be called
371// from within a DEF_TRAVERSE_STMT body or similar context.
372#define TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S) \
373 do { \
374 if (!TRAVERSE_STMT_BASE(Stmt, Stmt, S, Queue)) \
375 return false; \
376 } while (false)
377
378public:
379// Declare Traverse*() for all concrete Stmt classes.
380#define ABSTRACT_STMT(STMT)
381#define STMT(CLASS, PARENT) \
382 bool Traverse##CLASS(CLASS *S, DataRecursionQueue *Queue = nullptr);
383#include "clang/AST/StmtNodes.inc"
384 // The above header #undefs ABSTRACT_STMT and STMT upon exit.
385
386 // Define WalkUpFrom*() and empty Visit*() for all Stmt classes.
387 bool WalkUpFromStmt(Stmt *S) { return getDerived().VisitStmt(S); }
388 bool VisitStmt(Stmt *S) { return true; }
389#define STMT(CLASS, PARENT) \
390 bool WalkUpFrom##CLASS(CLASS *S) { \
391 TRY_TO(WalkUpFrom##PARENT(S)); \
392 TRY_TO(Visit##CLASS(S)); \
393 return true; \
394 } \
395 bool Visit##CLASS(CLASS *S) { return true; }
396#include "clang/AST/StmtNodes.inc"
397
398// ---- Methods on Types ----
399// FIXME: revamp to take TypeLoc's rather than Types.
400
401// Declare Traverse*() for all concrete Type classes.
402#define ABSTRACT_TYPE(CLASS, BASE)
403#define TYPE(CLASS, BASE) \
404 bool Traverse##CLASS##Type(CLASS##Type *T, bool TraverseQualifier);
405#include "clang/AST/TypeNodes.inc"
406 // The above header #undefs ABSTRACT_TYPE and TYPE upon exit.
407
408 // Define WalkUpFrom*() and empty Visit*() for all Type classes.
409 bool WalkUpFromType(Type *T) { return getDerived().VisitType(T); }
410 bool VisitType(Type *T) { return true; }
411#define TYPE(CLASS, BASE) \
412 bool WalkUpFrom##CLASS##Type(CLASS##Type *T) { \
413 TRY_TO(WalkUpFrom##BASE(T)); \
414 TRY_TO(Visit##CLASS##Type(T)); \
415 return true; \
416 } \
417 bool Visit##CLASS##Type(CLASS##Type *T) { return true; }
418#include "clang/AST/TypeNodes.inc"
419
420// ---- Methods on TypeLocs ----
421// FIXME: this currently just calls the matching Type methods
422
423// Declare Traverse*() for all concrete TypeLoc classes.
424#define ABSTRACT_TYPELOC(CLASS, BASE)
425#define TYPELOC(CLASS, BASE) \
426 bool Traverse##CLASS##TypeLoc(CLASS##TypeLoc TL, bool TraverseQualifier);
427#include "clang/AST/TypeLocNodes.def"
428 // The above header #undefs ABSTRACT_TYPELOC and TYPELOC upon exit.
429
430 // Define WalkUpFrom*() and empty Visit*() for all TypeLoc classes.
431 bool WalkUpFromTypeLoc(TypeLoc TL) { return getDerived().VisitTypeLoc(TL); }
432 bool VisitTypeLoc(TypeLoc TL) { return true; }
433
434 // QualifiedTypeLoc and UnqualTypeLoc are not declared in
435 // TypeNodes.inc and thus need to be handled specially.
437 return getDerived().VisitUnqualTypeLoc(TL.getUnqualifiedLoc());
438 }
439 bool VisitQualifiedTypeLoc(QualifiedTypeLoc TL) { return true; }
441 return getDerived().VisitUnqualTypeLoc(TL.getUnqualifiedLoc());
442 }
443 bool VisitUnqualTypeLoc(UnqualTypeLoc TL) { return true; }
444
445// Note that BASE includes trailing 'Type' which CLASS doesn't.
446#define TYPE(CLASS, BASE) \
447 bool WalkUpFrom##CLASS##TypeLoc(CLASS##TypeLoc TL) { \
448 TRY_TO(WalkUpFrom##BASE##Loc(TL)); \
449 TRY_TO(Visit##CLASS##TypeLoc(TL)); \
450 return true; \
451 } \
452 bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TL) { return true; }
453#include "clang/AST/TypeNodes.inc"
454
455// ---- Methods on Decls ----
456
457// Declare Traverse*() for all concrete Decl classes.
458#define ABSTRACT_DECL(DECL)
459#define DECL(CLASS, BASE) bool Traverse##CLASS##Decl(CLASS##Decl *D);
460#include "clang/AST/DeclNodes.inc"
461 // The above header #undefs ABSTRACT_DECL and DECL upon exit.
462
463 // Define WalkUpFrom*() and empty Visit*() for all Decl classes.
464 bool WalkUpFromDecl(Decl *D) { return getDerived().VisitDecl(D); }
465 bool VisitDecl(Decl *D) { return true; }
466#define DECL(CLASS, BASE) \
467 bool WalkUpFrom##CLASS##Decl(CLASS##Decl *D) { \
468 TRY_TO(WalkUpFrom##BASE(D)); \
469 TRY_TO(Visit##CLASS##Decl(D)); \
470 return true; \
471 } \
472 bool Visit##CLASS##Decl(CLASS##Decl *D) { return true; }
473#include "clang/AST/DeclNodes.inc"
474
476
477#define DEF_TRAVERSE_TMPL_INST(TMPLDECLKIND) \
478 bool TraverseTemplateInstantiations(TMPLDECLKIND##TemplateDecl *D);
481 DEF_TRAVERSE_TMPL_INST(Function)
482#undef DEF_TRAVERSE_TMPL_INST
483
485
490
492
493private:
494 // These are helper methods used by more than one Traverse* method.
495 bool TraverseTemplateParameterListHelper(TemplateParameterList *TPL);
496
497 // Traverses template parameter lists of either a DeclaratorDecl or TagDecl.
498 template <typename T>
499 bool TraverseDeclTemplateParameterLists(T *D);
500
501 bool TraverseTemplateTypeParamDeclConstraints(const TemplateTypeParmDecl *D);
502
503 bool TraverseTemplateArgumentLocsHelper(const TemplateArgumentLoc *TAL,
504 unsigned Count);
505 bool TraverseArrayTypeLocHelper(ArrayTypeLoc TL);
506 bool TraverseSubstPackTypeHelper(SubstPackType *T);
507 bool TraverseSubstPackTypeLocHelper(SubstPackTypeLoc TL);
508 bool TraverseRecordHelper(RecordDecl *D);
509 bool TraverseCXXRecordHelper(CXXRecordDecl *D);
510 bool TraverseDeclaratorHelper(DeclaratorDecl *D);
511 bool TraverseDeclContextHelper(DeclContext *DC);
512 bool TraverseFunctionHelper(FunctionDecl *D);
513 bool TraverseVarHelper(VarDecl *D);
514 bool TraverseOMPExecutableDirective(OMPExecutableDirective *S);
515 bool TraverseOMPLoopDirective(OMPLoopDirective *S);
516 bool TraverseOMPClause(OMPClause *C);
517 bool TraverseTagType(TagType *T, bool TraverseQualifier);
518 bool TraverseTagTypeLoc(TagTypeLoc TL, bool TraverseQualifier);
519#define GEN_CLANG_CLAUSE_CLASS
520#define CLAUSE_CLASS(Enum, Str, Class) bool Visit##Class(Class *C);
521#include "llvm/Frontend/OpenMP/OMP.inc"
522 /// Process clauses with list of variables.
523 template <typename T> bool VisitOMPClauseList(T *Node);
524 /// Process clauses with pre-initis.
525 bool VisitOMPClauseWithPreInit(OMPClauseWithPreInit *Node);
526 bool VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *Node);
527
528 bool PostVisitStmt(Stmt *S);
529 bool TraverseOpenACCConstructStmt(OpenACCConstructStmt *S);
530 bool
531 TraverseOpenACCAssociatedStmtConstruct(OpenACCAssociatedStmtConstruct *S);
532 bool VisitOpenACCClauseList(ArrayRef<const OpenACCClause *>);
533 bool VisitOpenACCClause(const OpenACCClause *);
534};
535
536template <typename Derived>
538 const TypeConstraint *C) {
540 TRY_TO(TraverseConceptReference(C->getConceptReference()));
541 return true;
542 }
543 if (Expr *IDC = C->getImmediatelyDeclaredConstraint()) {
544 TRY_TO(TraverseStmt(IDC));
545 } else {
546 // Avoid traversing the ConceptReference in the TypeConstraint
547 // if we have an immediately-declared-constraint, otherwise
548 // we'll end up visiting the concept and the arguments in
549 // the TC twice.
550 TRY_TO(TraverseConceptReference(C->getConceptReference()));
551 }
552 return true;
553}
554
555template <typename Derived>
558 switch (R->getKind()) {
560 return getDerived().TraverseConceptTypeRequirement(
564 return getDerived().TraverseConceptExprRequirement(
567 return getDerived().TraverseConceptNestedRequirement(
569 }
570 llvm_unreachable("unexpected case");
571}
572
573template <typename Derived>
575 DataRecursionQueue *Queue) {
576 // Top switch stmt: dispatch to TraverseFooStmt for each concrete FooStmt.
577 switch (S->getStmtClass()) {
579 break;
580#define ABSTRACT_STMT(STMT)
581#define STMT(CLASS, PARENT) \
582 case Stmt::CLASS##Class: \
583 return TRAVERSE_STMT_BASE(CLASS, CLASS, S, Queue);
584#include "clang/AST/StmtNodes.inc"
585 }
586
587 return true;
588}
589
590#undef DISPATCH_STMT
591
592template <typename Derived>
595 if (R->isSubstitutionFailure())
596 return true;
597 return getDerived().TraverseTypeLoc(R->getType()->getTypeLoc());
598}
599
600template <typename Derived>
603 if (!R->isExprSubstitutionFailure())
604 TRY_TO(TraverseStmt(R->getExpr()));
605 auto &RetReq = R->getReturnTypeRequirement();
606 if (RetReq.isTypeConstraint()) {
608 TRY_TO(TraverseTemplateParameterListHelper(
609 RetReq.getTypeConstraintTemplateParameterList()));
610 } else {
611 // Template parameter list is implicit, visit constraint directly.
612 TRY_TO(TraverseTypeConstraint(RetReq.getTypeConstraint()));
613 }
614 }
615 return true;
616}
617
618template <typename Derived>
621 if (!R->hasInvalidConstraint())
622 return getDerived().TraverseStmt(R->getConstraintExpr());
623 return true;
624}
625
626template <typename Derived>
627bool RecursiveASTVisitor<Derived>::PostVisitStmt(Stmt *S) {
628 // In pre-order traversal mode, each Traverse##STMT method is responsible for
629 // calling WalkUpFrom. Therefore, if the user overrides Traverse##STMT and
630 // does not call the default implementation, the WalkUpFrom callback is not
631 // called. Post-order traversal mode should provide the same behavior
632 // regarding method overrides.
633 //
634 // In post-order traversal mode the Traverse##STMT method, when it receives a
635 // DataRecursionQueue, can't call WalkUpFrom after traversing children because
636 // it only enqueues the children and does not traverse them. TraverseStmt
637 // traverses the enqueued children, and we call WalkUpFrom here.
638 //
639 // However, to make pre-order and post-order modes identical with regards to
640 // whether they call WalkUpFrom at all, we call WalkUpFrom if and only if the
641 // user did not override the Traverse##STMT method. We implement the override
642 // check with isSameMethod calls below.
643
644 switch (S->getStmtClass()) {
646 break;
647#define ABSTRACT_STMT(STMT)
648#define STMT(CLASS, PARENT) \
649 case Stmt::CLASS##Class: \
650 if (::clang::detail::isSameMethod(&RecursiveASTVisitor::Traverse##CLASS, \
651 &Derived::Traverse##CLASS)) { \
652 TRY_TO(WalkUpFrom##CLASS(static_cast<CLASS *>(S))); \
653 } \
654 break;
655#define INITLISTEXPR(CLASS, PARENT) \
656 case Stmt::CLASS##Class: \
657 if (::clang::detail::isSameMethod(&RecursiveASTVisitor::Traverse##CLASS, \
658 &Derived::Traverse##CLASS)) { \
659 auto ILE = static_cast<CLASS *>(S); \
660 if (auto Syn = ILE->isSemanticForm() ? ILE->getSyntacticForm() : ILE) \
661 TRY_TO(WalkUpFrom##CLASS(Syn)); \
662 if (auto Sem = ILE->isSemanticForm() ? ILE : ILE->getSemanticForm()) \
663 TRY_TO(WalkUpFrom##CLASS(Sem)); \
664 } \
665 break;
666#include "clang/AST/StmtNodes.inc"
667 }
668
669 return true;
670}
671
672#undef DISPATCH_STMT
673
674// Inlining this method can lead to large code size and compile-time increases
675// without any benefit to runtime performance.
676template <typename Derived>
677LLVM_ATTRIBUTE_NOINLINE bool
679 if (!S)
680 return true;
681
682 if (Queue) {
683 Queue->push_back({S, false});
684 return true;
685 }
686
688 LocalQueue.push_back({S, false});
689
690 while (!LocalQueue.empty()) {
691 auto &CurrSAndVisited = LocalQueue.back();
692 Stmt *CurrS = CurrSAndVisited.getPointer();
693 bool Visited = CurrSAndVisited.getInt();
694 if (Visited) {
695 LocalQueue.pop_back();
698 TRY_TO(PostVisitStmt(CurrS));
699 }
700 continue;
701 }
702
703 if (getDerived().dataTraverseStmtPre(CurrS)) {
704 CurrSAndVisited.setInt(true);
705 size_t N = LocalQueue.size();
706 TRY_TO(dataTraverseNode(CurrS, &LocalQueue));
707 // Process new children in the order they were added.
708 std::reverse(LocalQueue.begin() + N, LocalQueue.end());
709 } else {
710 LocalQueue.pop_back();
711 }
712 }
713
714 return true;
715}
716
717template <typename Derived>
719 bool TraverseQualifier) {
720 if (T.isNull())
721 return true;
722
723 switch (T->getTypeClass()) {
724#define ABSTRACT_TYPE(CLASS, BASE)
725#define TYPE(CLASS, BASE) \
726 case Type::CLASS: \
727 return getDerived().Traverse##CLASS##Type( \
728 static_cast<CLASS##Type *>(const_cast<Type *>(T.getTypePtr())), \
729 TraverseQualifier);
730#include "clang/AST/TypeNodes.inc"
731 }
732
733 return true;
734}
735
736template <typename Derived>
738 bool TraverseQualifier) {
739 if (TL.isNull())
740 return true;
741
742 switch (TL.getTypeLocClass()) {
743#define ABSTRACT_TYPELOC(CLASS, BASE)
744#define TYPELOC(CLASS, BASE) \
745 case TypeLoc::CLASS: \
746 return getDerived().Traverse##CLASS##TypeLoc(TL.castAs<CLASS##TypeLoc>(), \
747 TraverseQualifier);
748#include "clang/AST/TypeLocNodes.def"
749 }
750
751 return true;
752}
753
754// Define the Traverse*Attr(Attr* A) methods
755#define VISITORCLASS RecursiveASTVisitor
756#include "clang/AST/AttrVisitor.inc"
757#undef VISITORCLASS
758
759template <typename Derived>
761 if (!D)
762 return true;
763
764 // As a syntax visitor, by default we want to ignore declarations for
765 // implicit declarations (ones not typed explicitly by the user).
767 if (D->isImplicit()) {
768 // For an implicit template type parameter, its type constraints are not
769 // implicit and are not represented anywhere else. We still need to visit
770 // them.
771 if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(D))
772 return TraverseTemplateTypeParamDeclConstraints(TTPD);
773 return true;
774 }
775
776 // Deduction guides for alias templates are always synthesized, so they
777 // should not be traversed unless shouldVisitImplicitCode() returns true.
778 //
779 // It's important to note that checking the implicit bit is not efficient
780 // for the alias case. For deduction guides synthesized from explicit
781 // user-defined deduction guides, we must maintain the explicit bit to
782 // ensure correct overload resolution.
783 if (auto *FTD = dyn_cast<FunctionTemplateDecl>(D))
784 if (llvm::isa_and_present<TypeAliasTemplateDecl>(
785 FTD->getDeclName().getCXXDeductionGuideTemplate()))
786 return true;
787 }
788
789 switch (D->getKind()) {
790#define ABSTRACT_DECL(DECL)
791#define DECL(CLASS, BASE) \
792 case Decl::CLASS: \
793 if (!getDerived().Traverse##CLASS##Decl(static_cast<CLASS##Decl *>(D))) \
794 return false; \
795 break;
796#include "clang/AST/DeclNodes.inc"
797 }
798 return true;
799}
800
801template <typename Derived>
804 switch (NNS.getKind()) {
808 return true;
811 return true;
813 auto *T = const_cast<Type *>(NNS.getAsType());
814 TRY_TO(TraverseNestedNameSpecifier(T->getPrefix()));
815 TRY_TO(TraverseType(QualType(T, 0), /*TraverseQualifier=*/false));
816 return true;
817 }
818 }
819 llvm_unreachable("unhandled kind");
820}
821
822template <typename Derived>
844
845template <typename Derived>
873
874template <typename Derived>
876 TemplateName Template, bool TraverseQualifier) {
877 if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) {
878 if (TraverseQualifier)
879 TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier()));
880 } else if (QualifiedTemplateName *QTN =
881 Template.getAsQualifiedTemplateName()) {
882 if (TraverseQualifier && QTN->getQualifier()) {
883 TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
884 }
885 } else if (PackIndexingTemplateStorage *PI =
886 Template.getAsPackIndexingTemplate()) {
887 TRY_TO(TraverseTemplateName(PI->getPattern(), TraverseQualifier));
888 TRY_TO(TraverseStmt(PI->getIndexExpr()));
889 }
890
891 return true;
892}
893
894template <typename Derived>
896 const TemplateArgument &Arg) {
897 switch (Arg.getKind()) {
903 return true;
904
906 return getDerived().TraverseType(Arg.getAsType());
907
910 return getDerived().TraverseTemplateName(
912
914 return getDerived().TraverseStmt(Arg.getAsExpr());
915
917 return getDerived().TraverseTemplateArguments(Arg.pack_elements());
918 }
919
920 return true;
921}
922
923// FIXME: no template name location?
924// FIXME: no source locations for a template argument pack?
925template <typename Derived>
927 const TemplateArgumentLoc &ArgLoc) {
928 const TemplateArgument &Arg = ArgLoc.getArgument();
929
930 switch (Arg.getKind()) {
936 return true;
937
939 // FIXME: how can TSI ever be NULL?
940 if (TypeSourceInfo *TSI = ArgLoc.getTypeSourceInfo())
941 return getDerived().TraverseTypeLoc(TSI->getTypeLoc());
942 else
943 return getDerived().TraverseType(Arg.getAsType());
944 }
945
948 if (ArgLoc.getTemplateQualifierLoc())
950 ArgLoc.getTemplateQualifierLoc()));
951 return getDerived().TraverseTemplateName(
953
955 return getDerived().TraverseStmt(ArgLoc.getSourceExpression());
956
958 return getDerived().TraverseTemplateArguments(Arg.pack_elements());
959 }
960
961 return true;
962}
963
964template <typename Derived>
967 for (const TemplateArgument &Arg : Args)
969
970 return true;
971}
972
973template <typename Derived>
976 if (TypeSourceInfo *TInfo = Init->getTypeSourceInfo())
977 TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
978
979 if (Init->isWritten() || getDerived().shouldVisitImplicitCode())
980 TRY_TO(TraverseStmt(Init->getInit()));
981
982 return true;
983}
984
985template <typename Derived>
986bool
988 const LambdaCapture *C,
989 Expr *Init) {
990 if (LE->isInitCapture(C))
991 TRY_TO(TraverseDecl(C->getCapturedVar()));
992 else
994 return true;
995}
996
997// ----------------- Type traversal -----------------
998
999// This macro makes available a variable T, the passed-in type.
1000#define DEF_TRAVERSE_TYPE(TYPE, CODE) \
1001 template <typename Derived> \
1002 bool RecursiveASTVisitor<Derived>::Traverse##TYPE(TYPE *T, \
1003 bool TraverseQualifier) { \
1004 if (!getDerived().shouldTraversePostOrder()) \
1005 TRY_TO(WalkUpFrom##TYPE(T)); \
1006 { \
1007 CODE; \
1008 } \
1009 if (getDerived().shouldTraversePostOrder()) \
1010 TRY_TO(WalkUpFrom##TYPE(T)); \
1011 return true; \
1012 }
1013
1014DEF_TRAVERSE_TYPE(BuiltinType, {})
1015
1016DEF_TRAVERSE_TYPE(ComplexType, { TRY_TO(TraverseType(T->getElementType())); })
1017
1018DEF_TRAVERSE_TYPE(PointerType, { TRY_TO(TraverseType(T->getPointeeType())); })
1019
1021 { TRY_TO(TraverseType(T->getPointeeType())); })
1022
1023DEF_TRAVERSE_TYPE(LValueReferenceType,
1024 { TRY_TO(TraverseType(T->getPointeeType())); })
1025
1027 { TRY_TO(TraverseType(T->getPointeeType())); })
1028
1029DEF_TRAVERSE_TYPE(MemberPointerType, {
1030 NestedNameSpecifier Qualifier =
1031 T->isSugared() ? cast<MemberPointerType>(T->getCanonicalTypeUnqualified())
1032 ->getQualifier()
1033 : T->getQualifier();
1034 TRY_TO(TraverseNestedNameSpecifier(Qualifier));
1035 TRY_TO(TraverseType(T->getPointeeType()));
1036})
1037
1038DEF_TRAVERSE_TYPE(AdjustedType, { TRY_TO(TraverseType(T->getOriginalType())); })
1039
1040DEF_TRAVERSE_TYPE(DecayedType, { TRY_TO(TraverseType(T->getOriginalType())); })
1041
1043 TRY_TO(TraverseType(T->getElementType()));
1044 if (T->getSizeExpr())
1045 TRY_TO(TraverseStmt(const_cast<Expr*>(T->getSizeExpr())));
1046})
1047
1048DEF_TRAVERSE_TYPE(ArrayParameterType, {
1049 TRY_TO(TraverseType(T->getElementType()));
1050 if (T->getSizeExpr())
1051 TRY_TO(TraverseStmt(const_cast<Expr *>(T->getSizeExpr())));
1052})
1053
1055 { TRY_TO(TraverseType(T->getElementType())); })
1056
1057DEF_TRAVERSE_TYPE(VariableArrayType, {
1058 TRY_TO(TraverseType(T->getElementType()));
1059 TRY_TO(TraverseStmt(T->getSizeExpr()));
1060})
1061
1063 TRY_TO(TraverseType(T->getElementType()));
1064 if (T->getSizeExpr())
1065 TRY_TO(TraverseStmt(T->getSizeExpr()));
1066})
1067
1068DEF_TRAVERSE_TYPE(DependentAddressSpaceType, {
1069 TRY_TO(TraverseStmt(T->getAddrSpaceExpr()));
1070 TRY_TO(TraverseType(T->getPointeeType()));
1071})
1072
1074 if (T->getSizeExpr())
1075 TRY_TO(TraverseStmt(T->getSizeExpr()));
1076 TRY_TO(TraverseType(T->getElementType()));
1077})
1078
1079DEF_TRAVERSE_TYPE(DependentSizedExtVectorType, {
1080 if (T->getSizeExpr())
1081 TRY_TO(TraverseStmt(T->getSizeExpr()));
1082 TRY_TO(TraverseType(T->getElementType()));
1083})
1084
1085DEF_TRAVERSE_TYPE(VectorType, { TRY_TO(TraverseType(T->getElementType())); })
1086
1087DEF_TRAVERSE_TYPE(ExtVectorType, { TRY_TO(TraverseType(T->getElementType())); })
1088
1090 { TRY_TO(TraverseType(T->getElementType())); })
1091
1092DEF_TRAVERSE_TYPE(DependentSizedMatrixType, {
1093 if (T->getRowExpr())
1094 TRY_TO(TraverseStmt(T->getRowExpr()));
1095 if (T->getColumnExpr())
1096 TRY_TO(TraverseStmt(T->getColumnExpr()));
1097 TRY_TO(TraverseType(T->getElementType()));
1098})
1099
1101 { TRY_TO(TraverseType(T->getReturnType())); })
1102
1103DEF_TRAVERSE_TYPE(FunctionProtoType, {
1104 TRY_TO(TraverseType(T->getReturnType()));
1105
1106 for (const auto &A : T->param_types()) {
1107 TRY_TO(TraverseType(A));
1108 }
1109
1110 for (const auto &E : T->exceptions()) {
1111 TRY_TO(TraverseType(E));
1112 }
1113
1114 if (Expr *NE = T->getNoexceptExpr())
1115 TRY_TO(TraverseStmt(NE));
1116})
1117
1119 if (TraverseQualifier)
1120 TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
1121})
1122DEF_TRAVERSE_TYPE(UnresolvedUsingType, {
1123 if (TraverseQualifier)
1124 TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
1125})
1127 if (TraverseQualifier)
1128 TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
1129})
1130
1131DEF_TRAVERSE_TYPE(TypeOfExprType,
1132 { TRY_TO(TraverseStmt(T->getUnderlyingExpr())); })
1133
1134DEF_TRAVERSE_TYPE(TypeOfType, { TRY_TO(TraverseType(T->getUnmodifiedType())); })
1135
1136DEF_TRAVERSE_TYPE(DecltypeType,
1137 { TRY_TO(TraverseStmt(T->getUnderlyingExpr())); })
1138
1139DEF_TRAVERSE_TYPE(PackIndexingType, {
1140 TRY_TO(TraverseType(T->getPattern()));
1141 TRY_TO(TraverseStmt(T->getIndexExpr()));
1142})
1143
1144DEF_TRAVERSE_TYPE(UnaryTransformType, {
1145 TRY_TO(TraverseType(T->getBaseType()));
1146 TRY_TO(TraverseType(T->getUnderlyingType()));
1147})
1148
1150 TRY_TO(TraverseType(T->getDeducedType()));
1151 if (T->isConstrained()) {
1152 TRY_TO(TraverseTemplateArguments(T->getTypeConstraintArguments()));
1153 }
1154})
1155
1156DEF_TRAVERSE_TYPE(TemplateTypeParmType, {})
1157DEF_TRAVERSE_TYPE(SubstTemplateTypeParmType, {
1158 TRY_TO(TraverseType(T->getReplacementType()));
1159})
1160DEF_TRAVERSE_TYPE(SubstTemplateTypeParmPackType,
1161 { TRY_TO(TraverseSubstPackTypeHelper(T)); })
1162DEF_TRAVERSE_TYPE(SubstBuiltinTemplatePackType,
1163 { TRY_TO(TraverseSubstPackTypeHelper(T)); })
1164
1165DEF_TRAVERSE_TYPE(AttributedType,
1166 { TRY_TO(TraverseType(T->getModifiedType())); })
1167
1168DEF_TRAVERSE_TYPE(CountAttributedType, {
1169 if (T->getCountExpr())
1170 TRY_TO(TraverseStmt(T->getCountExpr()));
1171 TRY_TO(TraverseType(T->desugar()));
1172})
1173
1175 { TRY_TO(TraverseType(T->getWrappedType())); })
1176
1177DEF_TRAVERSE_TYPE(BTFTagAttributedType,
1178 { TRY_TO(TraverseType(T->getWrappedType())); })
1179
1180DEF_TRAVERSE_TYPE(OverflowBehaviorType,
1181 { TRY_TO(TraverseType(T->getUnderlyingType())); })
1182
1183DEF_TRAVERSE_TYPE(HLSLAttributedResourceType,
1184 { TRY_TO(TraverseType(T->getWrappedType())); })
1185
1186DEF_TRAVERSE_TYPE(HLSLInlineSpirvType, {
1187 for (auto &Operand : T->getOperands()) {
1188 if (Operand.isConstant() || Operand.isType()) {
1189 TRY_TO(TraverseType(Operand.getResultType()));
1190 }
1191 }
1192})
1193
1194DEF_TRAVERSE_TYPE(ParenType, { TRY_TO(TraverseType(T->getInnerType())); })
1195
1197 { TRY_TO(TraverseType(T->getUnderlyingType())); })
1198
1199template <typename Derived>
1200bool RecursiveASTVisitor<Derived>::TraverseTagType(TagType *T,
1201 bool TraverseQualifier) {
1202 if (TraverseQualifier)
1203 TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
1204 return true;
1205}
1206
1207DEF_TRAVERSE_TYPE(EnumType, { TRY_TO(TraverseTagType(T, TraverseQualifier)); })
1208DEF_TRAVERSE_TYPE(RecordType,
1209 { TRY_TO(TraverseTagType(T, TraverseQualifier)); })
1210DEF_TRAVERSE_TYPE(InjectedClassNameType,
1211 { TRY_TO(TraverseTagType(T, TraverseQualifier)); })
1212
1213DEF_TRAVERSE_TYPE(DependentNameType, {
1214 if (TraverseQualifier)
1215 TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
1216})
1217
1218DEF_TRAVERSE_TYPE(TemplateSpecializationType, {
1219 TRY_TO(TraverseTemplateName(T->getTemplateName(), TraverseQualifier));
1220 TRY_TO(TraverseTemplateArguments(T->template_arguments()));
1221})
1222
1223DEF_TRAVERSE_TYPE(DeducedTemplateSpecializationType, {
1224 TRY_TO(TraverseTemplateName(T->getTemplateName(), TraverseQualifier));
1225 TRY_TO(TraverseType(T->getDeducedType()));
1226})
1227
1228DEF_TRAVERSE_TYPE(PackExpansionType, { TRY_TO(TraverseType(T->getPattern())); })
1229
1230DEF_TRAVERSE_TYPE(ObjCTypeParamType, {})
1231
1233
1234DEF_TRAVERSE_TYPE(ObjCObjectType, {
1235 // We have to watch out here because an ObjCInterfaceType's base
1236 // type is itself.
1237 if (T->getBaseType().getTypePtr() != T)
1238 TRY_TO(TraverseType(T->getBaseType()));
1239 for (auto typeArg : T->getTypeArgsAsWritten()) {
1240 TRY_TO(TraverseType(typeArg));
1241 }
1242})
1243
1245 { TRY_TO(TraverseType(T->getPointeeType())); })
1246
1247DEF_TRAVERSE_TYPE(AtomicType, { TRY_TO(TraverseType(T->getValueType())); })
1248
1249DEF_TRAVERSE_TYPE(PipeType, { TRY_TO(TraverseType(T->getElementType())); })
1250
1251DEF_TRAVERSE_TYPE(BitIntType, {})
1253 { TRY_TO(TraverseStmt(T->getNumBitsExpr())); })
1254
1256
1257#undef DEF_TRAVERSE_TYPE
1258
1259// ----------------- TypeLoc traversal -----------------
1260
1261// This macro makes available a variable TL, the passed-in TypeLoc.
1262// If requested, it calls WalkUpFrom* for the Type in the given TypeLoc,
1263// in addition to WalkUpFrom* for the TypeLoc itself, such that existing
1264// clients that override the WalkUpFrom*Type() and/or Visit*Type() methods
1265// continue to work.
1267 template <typename Derived> \
1268 bool RecursiveASTVisitor<Derived>::Traverse##TYPE##Loc( \
1269 TYPE##Loc TL, bool TraverseQualifier) { \
1270 if (!getDerived().shouldTraversePostOrder()) { \
1271 TRY_TO(WalkUpFrom##TYPE##Loc(TL)); \
1272 if (getDerived().shouldWalkTypesOfTypeLocs()) \
1273 TRY_TO(WalkUpFrom##TYPE(const_cast<TYPE *>(TL.getTypePtr()))); \
1274 } \
1275 { \
1276 CODE; \
1277 } \
1278 if (getDerived().shouldTraversePostOrder()) { \
1279 TRY_TO(WalkUpFrom##TYPE##Loc(TL)); \
1280 if (getDerived().shouldWalkTypesOfTypeLocs()) \
1281 TRY_TO(WalkUpFrom##TYPE(const_cast<TYPE *>(TL.getTypePtr()))); \
1282 } \
1283 return true; \
1284 }
1285
1286template <typename Derived>
1288 QualifiedTypeLoc TL, bool TraverseQualifier) {
1289 assert(TraverseQualifier &&
1290 "Qualifiers should never occur within NestedNameSpecifiers");
1291 // Move this over to the 'main' typeloc tree. Note that this is a
1292 // move -- we pretend that we were really looking at the unqualified
1293 // typeloc all along -- rather than a recursion, so we don't follow
1294 // the normal CRTP plan of going through
1295 // getDerived().TraverseTypeLoc. If we did, we'd be traversing
1296 // twice for the same type (once as a QualifiedTypeLoc version of
1297 // the type, once as an UnqualifiedTypeLoc version of the type),
1298 // which in effect means we'd call VisitTypeLoc twice with the
1299 // 'same' type. This solves that problem, at the cost of never
1300 // seeing the qualified version of the type (unless the client
1301 // subclasses TraverseQualifiedTypeLoc themselves). It's not a
1302 // perfect solution. A perfect solution probably requires making
1303 // QualifiedTypeLoc a wrapper around TypeLoc -- like QualType is a
1304 // wrapper around Type* -- rather than being its own class in the
1305 // type hierarchy.
1306 return TraverseTypeLoc(TL.getUnqualifiedLoc());
1307}
1308
1310
1311// FIXME: ComplexTypeLoc is unfinished
1313 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1314})
1315
1316DEF_TRAVERSE_TYPELOC(PointerType,
1317 { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1318
1320 { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1321
1322DEF_TRAVERSE_TYPELOC(LValueReferenceType,
1323 { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1324
1326 { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1327
1328// We traverse this in the type case as well, but how is it not reached through
1329// the pointee type?
1330DEF_TRAVERSE_TYPELOC(MemberPointerType, {
1331 if (NestedNameSpecifierLoc QL = TL.getQualifierLoc())
1333 else
1334 TRY_TO(TraverseNestedNameSpecifier(TL.getTypePtr()->getQualifier()));
1335 TRY_TO(TraverseTypeLoc(TL.getPointeeLoc()));
1336})
1337
1339 { TRY_TO(TraverseTypeLoc(TL.getOriginalLoc())); })
1340
1341DEF_TRAVERSE_TYPELOC(DecayedType,
1342 { TRY_TO(TraverseTypeLoc(TL.getOriginalLoc())); })
1343
1344template <typename Derived>
1345bool RecursiveASTVisitor<Derived>::TraverseArrayTypeLocHelper(ArrayTypeLoc TL) {
1346 // This isn't available for ArrayType, but is for the ArrayTypeLoc.
1347 TRY_TO(TraverseStmt(TL.getSizeExpr()));
1348 return true;
1349}
1350
1352 TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1353 TRY_TO(TraverseArrayTypeLocHelper(TL));
1354})
1355
1356DEF_TRAVERSE_TYPELOC(ArrayParameterType, {
1357 TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1358 TRY_TO(TraverseArrayTypeLocHelper(TL));
1359})
1360
1362 TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1363 TRY_TO(TraverseArrayTypeLocHelper(TL));
1364})
1365
1366DEF_TRAVERSE_TYPELOC(VariableArrayType, {
1367 TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1368 TRY_TO(TraverseArrayTypeLocHelper(TL));
1369})
1370
1372 TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1373 TRY_TO(TraverseArrayTypeLocHelper(TL));
1374})
1375
1376DEF_TRAVERSE_TYPELOC(DependentAddressSpaceType, {
1377 TRY_TO(TraverseStmt(TL.getTypePtr()->getAddrSpaceExpr()));
1378 TRY_TO(TraverseType(TL.getTypePtr()->getPointeeType()));
1379})
1380
1381// FIXME: order? why not size expr first?
1382// FIXME: base VectorTypeLoc is unfinished
1384 TRY_TO(TraverseStmt(TL.getSizeExpr()));
1385 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1386})
1387
1388// FIXME: VectorTypeLoc is unfinished
1389DEF_TRAVERSE_TYPELOC(VectorType, {
1390 TRY_TO(TraverseStmt(TL.getSizeExpr()));
1391 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1392})
1393
1395 TRY_TO(TraverseStmt(TL.getSizeExpr()));
1396 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1397})
1398
1399// FIXME: base VectorTypeLoc is unfinished
1400DEF_TRAVERSE_TYPELOC(ExtVectorType, {
1401 TRY_TO(TraverseStmt(TL.getSizeExpr()));
1402 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1403})
1404
1406 TRY_TO(TraverseStmt(TL.getAttrRowOperand()));
1407 TRY_TO(TraverseStmt(TL.getAttrColumnOperand()));
1408 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1409})
1410
1411DEF_TRAVERSE_TYPELOC(DependentSizedMatrixType, {
1412 TRY_TO(TraverseStmt(TL.getAttrRowOperand()));
1413 TRY_TO(TraverseStmt(TL.getAttrColumnOperand()));
1414 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1415})
1416
1418 { TRY_TO(TraverseTypeLoc(TL.getReturnLoc())); })
1419
1420// FIXME: location of exception specifications (attributes?)
1421DEF_TRAVERSE_TYPELOC(FunctionProtoType, {
1422 TRY_TO(TraverseTypeLoc(TL.getReturnLoc()));
1423
1424 const FunctionProtoType *T = TL.getTypePtr();
1425
1426 for (unsigned I = 0, E = TL.getNumParams(); I != E; ++I) {
1427 if (TL.getParam(I)) {
1428 TRY_TO(TraverseDecl(TL.getParam(I)));
1429 } else if (I < T->getNumParams()) {
1430 TRY_TO(TraverseType(T->getParamType(I)));
1431 }
1432 }
1433
1434 for (const auto &E : T->exceptions()) {
1435 TRY_TO(TraverseType(E));
1436 }
1437
1438 if (Expr *NE = T->getNoexceptExpr())
1439 TRY_TO(TraverseStmt(NE));
1440})
1441
1443 if (NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
1444 TraverseQualifier && QualifierLoc)
1446})
1447DEF_TRAVERSE_TYPELOC(UnresolvedUsingType, {
1448 if (NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
1449 TraverseQualifier && QualifierLoc)
1451})
1453 if (NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
1454 TraverseQualifier && QualifierLoc)
1456})
1457
1458DEF_TRAVERSE_TYPELOC(TypeOfExprType,
1459 { TRY_TO(TraverseStmt(TL.getUnderlyingExpr())); })
1460
1462 TRY_TO(TraverseTypeLoc(TL.getUnmodifiedTInfo()->getTypeLoc()));
1463})
1464
1465// FIXME: location of underlying expr
1466DEF_TRAVERSE_TYPELOC(DecltypeType, {
1467 TRY_TO(TraverseStmt(TL.getTypePtr()->getUnderlyingExpr()));
1468})
1469
1470DEF_TRAVERSE_TYPELOC(PackIndexingType, {
1471 TRY_TO(TraverseTypeLoc(TL.getPatternLoc()));
1472 TRY_TO(TraverseStmt(TL.getTypePtr()->getIndexExpr()));
1473})
1474
1475DEF_TRAVERSE_TYPELOC(UnaryTransformType, {
1476 TRY_TO(TraverseTypeLoc(TL.getUnderlyingTInfo()->getTypeLoc()));
1477})
1478
1480 TRY_TO(TraverseType(TL.getTypePtr()->getDeducedType()));
1481 if (TL.isConstrained()) {
1482 TRY_TO(TraverseConceptReference(TL.getConceptReference()));
1483 }
1484})
1485
1486DEF_TRAVERSE_TYPELOC(TemplateTypeParmType, {})
1487DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmType, {
1488 TRY_TO(TraverseType(TL.getTypePtr()->getReplacementType()));
1489})
1490
1491template <typename Derived>
1492bool RecursiveASTVisitor<Derived>::TraverseSubstPackTypeLocHelper(
1493 SubstPackTypeLoc TL) {
1494 TRY_TO(TraverseTemplateArgument(TL.getTypePtr()->getArgumentPack()));
1495 return true;
1496}
1497
1498template <typename Derived>
1499bool RecursiveASTVisitor<Derived>::TraverseSubstPackTypeHelper(
1500 SubstPackType *T) {
1501 TRY_TO(TraverseTemplateArgument(T->getArgumentPack()));
1502 return true;
1503}
1504
1505DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmPackType,
1506 { TRY_TO(TraverseSubstPackTypeLocHelper(TL)); })
1507
1508DEF_TRAVERSE_TYPELOC(SubstBuiltinTemplatePackType,
1509 { TRY_TO(TraverseSubstPackTypeLocHelper(TL)); })
1510
1511DEF_TRAVERSE_TYPELOC(ParenType, { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
1512
1513DEF_TRAVERSE_TYPELOC(MacroQualifiedType,
1514 { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
1515
1517 { TRY_TO(TraverseTypeLoc(TL.getModifiedLoc())); })
1518
1519DEF_TRAVERSE_TYPELOC(CountAttributedType,
1520 { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
1521
1523 { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
1524
1525DEF_TRAVERSE_TYPELOC(BTFTagAttributedType,
1526 { TRY_TO(TraverseTypeLoc(TL.getWrappedLoc())); })
1527
1528DEF_TRAVERSE_TYPELOC(OverflowBehaviorType,
1529 { TRY_TO(TraverseTypeLoc(TL.getWrappedLoc())); })
1530
1531DEF_TRAVERSE_TYPELOC(HLSLAttributedResourceType,
1532 { TRY_TO(TraverseTypeLoc(TL.getWrappedLoc())); })
1533
1534DEF_TRAVERSE_TYPELOC(HLSLInlineSpirvType,
1535 { TRY_TO(TraverseType(TL.getType())); })
1536
1537template <typename Derived>
1538bool RecursiveASTVisitor<Derived>::TraverseTagTypeLoc(TagTypeLoc TL,
1539 bool TraverseQualifier) {
1540 if (NestedNameSpecifierLoc QualifierLoc = TL.getQualifierLoc();
1541 TraverseQualifier && QualifierLoc)
1543 return true;
1544}
1545
1547 { TRY_TO(TraverseTagTypeLoc(TL, TraverseQualifier)); })
1548DEF_TRAVERSE_TYPELOC(RecordType,
1549 { TRY_TO(TraverseTagTypeLoc(TL, TraverseQualifier)); })
1550DEF_TRAVERSE_TYPELOC(InjectedClassNameType,
1551 { TRY_TO(TraverseTagTypeLoc(TL, TraverseQualifier)); })
1552
1553DEF_TRAVERSE_TYPELOC(DependentNameType, {
1554 if (TraverseQualifier)
1555 TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1556})
1557
1558DEF_TRAVERSE_TYPELOC(TemplateSpecializationType, {
1559 if (TraverseQualifier)
1560 TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1561
1562 TRY_TO(TraverseTemplateName(TL.getTypePtr()->getTemplateName(),
1563 /*TraverseQualifier=*/false));
1564
1565 for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) {
1566 TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(I)));
1567 }
1568})
1569
1570DEF_TRAVERSE_TYPELOC(DeducedTemplateSpecializationType, {
1571 if (TraverseQualifier)
1572 TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1573
1574 const auto *T = TL.getTypePtr();
1575 TRY_TO(TraverseTemplateName(T->getTemplateName(),
1576 /*TraverseQualifier=*/false));
1577
1578 TRY_TO(TraverseType(T->getDeducedType()));
1579})
1580
1581DEF_TRAVERSE_TYPELOC(PackExpansionType,
1582 { TRY_TO(TraverseTypeLoc(TL.getPatternLoc())); })
1583
1584DEF_TRAVERSE_TYPELOC(ObjCTypeParamType, {
1585 for (unsigned I = 0, N = TL.getNumProtocols(); I != N; ++I) {
1586 ObjCProtocolLoc ProtocolLoc(TL.getProtocol(I), TL.getProtocolLoc(I));
1587 TRY_TO(TraverseObjCProtocolLoc(ProtocolLoc));
1588 }
1589})
1590
1592
1593DEF_TRAVERSE_TYPELOC(ObjCObjectType, {
1594 // We have to watch out here because an ObjCInterfaceType's base
1595 // type is itself.
1596 if (TL.getTypePtr()->getBaseType().getTypePtr() != TL.getTypePtr())
1597 TRY_TO(TraverseTypeLoc(TL.getBaseLoc()));
1598 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
1599 TRY_TO(TraverseTypeLoc(TL.getTypeArgTInfo(i)->getTypeLoc()));
1600 for (unsigned I = 0, N = TL.getNumProtocols(); I != N; ++I) {
1601 ObjCProtocolLoc ProtocolLoc(TL.getProtocol(I), TL.getProtocolLoc(I));
1602 TRY_TO(TraverseObjCProtocolLoc(ProtocolLoc));
1603 }
1604})
1605
1607 { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1608
1609DEF_TRAVERSE_TYPELOC(AtomicType, { TRY_TO(TraverseTypeLoc(TL.getValueLoc())); })
1610
1611DEF_TRAVERSE_TYPELOC(PipeType, { TRY_TO(TraverseTypeLoc(TL.getValueLoc())); })
1612
1615 TRY_TO(TraverseStmt(TL.getTypePtr()->getNumBitsExpr()));
1616})
1617
1619
1621
1622// ----------------- Decl traversal -----------------
1623//
1624// For a Decl, we automate (in the DEF_TRAVERSE_DECL macro) traversing
1625// the children that come from the DeclContext associated with it.
1626// Therefore each Traverse* only needs to worry about children other
1627// than those.
1628
1629template <typename Derived>
1631 const Decl *Child) {
1632 // BlockDecls are traversed through BlockExprs,
1633 // CapturedDecls are traversed through CapturedStmts.
1634 if (isa<BlockDecl>(Child) || isa<CapturedDecl>(Child))
1635 return true;
1636 // Lambda classes are traversed through LambdaExprs.
1637 if (const CXXRecordDecl* Cls = dyn_cast<CXXRecordDecl>(Child))
1638 return Cls->isLambda();
1639 return false;
1640}
1641
1642template <typename Derived>
1643bool RecursiveASTVisitor<Derived>::TraverseDeclContextHelper(DeclContext *DC) {
1644 if (!DC)
1645 return true;
1646
1647 for (auto *Child : DC->decls()) {
1648 if (!canIgnoreChildDeclWhileTraversingDeclContext(Child))
1649 TRY_TO(TraverseDecl(Child));
1650 }
1651
1652 return true;
1653}
1654
1655// This macro makes available a variable D, the passed-in decl.
1656#define DEF_TRAVERSE_DECL(DECL, CODE) \
1657 template <typename Derived> \
1658 bool RecursiveASTVisitor<Derived>::Traverse##DECL(DECL *D) { \
1659 bool ShouldVisitChildren = true; \
1660 bool ReturnValue = true; \
1661 if (!getDerived().shouldTraversePostOrder()) \
1662 TRY_TO(WalkUpFrom##DECL(D)); \
1663 { CODE; } \
1664 if (ReturnValue && ShouldVisitChildren) \
1665 TRY_TO(TraverseDeclContextHelper(dyn_cast<DeclContext>(D))); \
1666 if (ReturnValue) { \
1667 /* Visit any attributes attached to this declaration. */ \
1668 for (auto *I : D->attrs()) \
1669 TRY_TO(getDerived().TraverseAttr(I)); \
1670 } \
1671 if (ReturnValue && getDerived().shouldTraversePostOrder()) \
1672 TRY_TO(WalkUpFrom##DECL(D)); \
1673 return ReturnValue; \
1674 }
1675
1677
1679 if (TypeSourceInfo *TInfo = D->getSignatureAsWritten())
1680 TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
1681 TRY_TO(TraverseStmt(D->getBody()));
1682 for (const auto &I : D->captures()) {
1683 if (I.hasCopyExpr()) {
1684 TRY_TO(TraverseStmt(I.getCopyExpr()));
1685 }
1686 }
1687 ShouldVisitChildren = false;
1688})
1689
1691 TRY_TO(TraverseStmt(D->getBody()));
1692 ShouldVisitChildren = false;
1693})
1694
1696 TRY_TO(TraverseStmt(D->getBody()));
1697 ShouldVisitChildren = false;
1698})
1699
1701
1703
1705
1707 TRY_TO(TraverseStmt(D->getTemporaryExpr()));
1708})
1709
1711 { TRY_TO(TraverseStmt(D->getAsmStringExpr())); })
1712
1713DEF_TRAVERSE_DECL(TopLevelStmtDecl, { TRY_TO(TraverseStmt(D->getStmt())); })
1714
1716
1718 // Friend is either decl or a type.
1719 if (D->getFriendType()) {
1720 TRY_TO(TraverseTypeLoc(D->getFriendType()->getTypeLoc()));
1721 // Traverse any CXXRecordDecl owned by this type, since
1722 // it will not be in the parent context:
1723 if (auto *TT = D->getFriendType()->getType()->getAs<TagType>();
1724 TT && TT->isTagOwned())
1725 TRY_TO(TraverseDecl(TT->getDecl()));
1726 } else {
1727 TRY_TO(TraverseDecl(D->getFriendDecl()));
1728 }
1729})
1730
1732 const TemplateName Template = D->getFriendTemplateName();
1733 if (D->getFriendType())
1734 TRY_TO(TraverseTypeLoc(D->getFriendType()->getTypeLoc()));
1735 else if (!Template.isNull())
1736 TRY_TO(TraverseTemplateName(Template));
1737 else
1738 TRY_TO(TraverseDecl(D->getFriendDecl()));
1739 for (TemplateParameterList *TPL : D->getTemplateParameterLists())
1740 TRY_TO(TraverseTemplateParameterListHelper(TPL));
1741})
1742
1744
1746
1747DEF_TRAVERSE_DECL(ObjCPropertyImplDecl, {// FIXME: implement this
1748 })
1749
1751 TRY_TO(TraverseStmt(D->getAssertExpr()));
1752 TRY_TO(TraverseStmt(D->getMessage()));
1753})
1754
1756 // No double visiting: getTypeAsWritten() returns null for class
1757 // templates/nested classes where the qualifier lives inside the TSI.
1758 if (D->getQualifierLoc())
1759 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1760 if (TypeSourceInfo *TSI = D->getTypeAsWritten())
1761 TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
1762 if (auto NumArgs = D->getNumTemplateArgs())
1763 for (unsigned I = 0; I != *NumArgs; ++I)
1764 TRY_TO(TraverseTemplateArgumentLoc(D->getTemplateArg(I)));
1765})
1766
1768 // Code in an unnamed namespace shows up automatically in
1769 // decls_begin()/decls_end(). Thus we don't need to recurse on
1770 // D->getAnonymousNamespace().
1771
1772 // If the traversal scope is set, then consider them to be the children of
1773 // the TUDecl, rather than traversing (and loading?) all top-level decls.
1774 auto Scope = D->getASTContext().getTraversalScope();
1775 bool HasLimitedScope =
1776 Scope.size() != 1 || !isa<TranslationUnitDecl>(Scope.front());
1777 if (HasLimitedScope) {
1778 ShouldVisitChildren = false; // we'll do that here instead
1779 for (auto *Child : Scope) {
1780 if (!canIgnoreChildDeclWhileTraversingDeclContext(Child))
1781 TRY_TO(TraverseDecl(Child));
1782 }
1783 }
1784})
1785
1787
1789
1791
1793 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1794
1795 // We shouldn't traverse an aliased namespace, since it will be
1796 // defined (and, therefore, traversed) somewhere else.
1797 ShouldVisitChildren = false;
1798})
1799
1800DEF_TRAVERSE_DECL(LabelDecl, {// There is no code in a LabelDecl.
1801 })
1802
1805 {// Code in an unnamed namespace shows up automatically in
1806 // decls_begin()/decls_end(). Thus we don't need to recurse on
1807 // D->getAnonymousNamespace().
1808 })
1809
1810DEF_TRAVERSE_DECL(ObjCCompatibleAliasDecl, {// FIXME: implement
1811 })
1812
1814 if (ObjCTypeParamList *typeParamList = D->getTypeParamList()) {
1815 for (auto typeParam : *typeParamList) {
1816 TRY_TO(TraverseObjCTypeParamDecl(typeParam));
1817 }
1818 }
1819 for (auto It : llvm::zip(D->protocols(), D->protocol_locs())) {
1820 ObjCProtocolLoc ProtocolLoc(std::get<0>(It), std::get<1>(It));
1821 TRY_TO(TraverseObjCProtocolLoc(ProtocolLoc));
1822 }
1823})
1824
1825DEF_TRAVERSE_DECL(ObjCCategoryImplDecl, {// FIXME: implement
1826 })
1827
1828DEF_TRAVERSE_DECL(ObjCImplementationDecl, {// FIXME: implement
1829 })
1830
1832 if (ObjCTypeParamList *typeParamList = D->getTypeParamListAsWritten()) {
1833 for (auto typeParam : *typeParamList) {
1834 TRY_TO(TraverseObjCTypeParamDecl(typeParam));
1835 }
1836 }
1837
1838 if (TypeSourceInfo *superTInfo = D->getSuperClassTInfo()) {
1839 TRY_TO(TraverseTypeLoc(superTInfo->getTypeLoc()));
1840 }
1841 if (D->isThisDeclarationADefinition()) {
1842 for (auto It : llvm::zip(D->protocols(), D->protocol_locs())) {
1843 ObjCProtocolLoc ProtocolLoc(std::get<0>(It), std::get<1>(It));
1844 TRY_TO(TraverseObjCProtocolLoc(ProtocolLoc));
1845 }
1846 }
1847})
1848
1850 if (D->isThisDeclarationADefinition()) {
1851 for (auto It : llvm::zip(D->protocols(), D->protocol_locs())) {
1852 ObjCProtocolLoc ProtocolLoc(std::get<0>(It), std::get<1>(It));
1853 TRY_TO(TraverseObjCProtocolLoc(ProtocolLoc));
1854 }
1855 }
1856})
1857
1859 if (D->getReturnTypeSourceInfo()) {
1860 TRY_TO(TraverseTypeLoc(D->getReturnTypeSourceInfo()->getTypeLoc()));
1861 }
1862 for (ParmVarDecl *Parameter : D->parameters()) {
1863 TRY_TO(TraverseDecl(Parameter));
1864 }
1865 if (D->isThisDeclarationADefinition()) {
1866 TRY_TO(TraverseStmt(D->getBody()));
1867 }
1868 ShouldVisitChildren = false;
1869})
1870
1872 if (D->hasExplicitBound()) {
1873 TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1874 // We shouldn't traverse D->getTypeForDecl(); it's a result of
1875 // declaring the type alias, not something that was written in the
1876 // source.
1877 }
1878})
1879
1881 if (D->getTypeSourceInfo())
1882 TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1883 else
1884 TRY_TO(TraverseType(D->getType()));
1885 ShouldVisitChildren = false;
1886})
1887
1889 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1890 TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
1891})
1892
1894 { TRY_TO(TraverseTypeLoc(D->getEnumTypeLoc())); })
1895
1897
1899 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1900})
1901
1903
1905
1907 if (D->getInstantiations() &&
1908 getDerived().shouldVisitTemplateInstantiations())
1909 TRY_TO(TraverseStmt(D->getInstantiations()));
1910
1911 TRY_TO(TraverseStmt(D->getExpansionPattern()));
1912})
1913
1915 for (auto *I : D->varlist()) {
1916 TRY_TO(TraverseStmt(I));
1917 }
1918})
1919
1921 for (auto *I : D->varlist()) {
1922 TRY_TO(TraverseStmt(I));
1923 }
1924})
1925
1927 for (auto *C : D->clauselists()) {
1928 TRY_TO(TraverseOMPClause(C));
1929 }
1930})
1931
1933 TRY_TO(TraverseStmt(D->getCombiner()));
1934 if (auto *Initializer = D->getInitializer())
1935 TRY_TO(TraverseStmt(Initializer));
1936 TRY_TO(TraverseType(D->getType()));
1937 return true;
1938})
1939
1941 for (auto *C : D->clauselists())
1942 TRY_TO(TraverseOMPClause(C));
1943 TRY_TO(TraverseType(D->getType()));
1944 return true;
1945})
1946
1947DEF_TRAVERSE_DECL(OMPCapturedExprDecl, { TRY_TO(TraverseVarHelper(D)); })
1948
1950 for (auto *I : D->varlist())
1951 TRY_TO(TraverseStmt(I));
1952 for (auto *C : D->clauselists())
1953 TRY_TO(TraverseOMPClause(C));
1954})
1955
1957 { TRY_TO(VisitOpenACCClauseList(D->clauses())); })
1958
1960 TRY_TO(TraverseStmt(D->getFunctionReference()));
1961 TRY_TO(VisitOpenACCClauseList(D->clauses()));
1962})
1963
1964// A helper method for TemplateDecl's children.
1965template <typename Derived>
1966bool RecursiveASTVisitor<Derived>::TraverseTemplateParameterListHelper(
1967 TemplateParameterList *TPL) {
1968 if (TPL) {
1969 for (NamedDecl *D : *TPL) {
1970 TRY_TO(TraverseDecl(D));
1971 }
1972 if (Expr *RequiresClause = TPL->getRequiresClause()) {
1973 TRY_TO(TraverseStmt(RequiresClause));
1974 }
1975 }
1976 return true;
1977}
1978
1979template <typename Derived>
1980template <typename T>
1981bool RecursiveASTVisitor<Derived>::TraverseDeclTemplateParameterLists(T *D) {
1982 for (TemplateParameterList *TPL : D->getTemplateParameterLists())
1983 TraverseTemplateParameterListHelper(TPL);
1984 return true;
1985}
1986
1987template <typename Derived>
1989 ClassTemplateDecl *D) {
1990 for (auto *SD : D->specializations()) {
1991 for (auto *RD : SD->redecls()) {
1992 assert(!cast<CXXRecordDecl>(RD)->isInjectedClassName());
1993 switch (
1994 cast<ClassTemplateSpecializationDecl>(RD)->getSpecializationKind()) {
1995 // Visit the implicit instantiations with the requested pattern.
1996 case TSK_Undeclared:
1998 TRY_TO(TraverseDecl(RD));
1999 break;
2000
2001 // We don't need to do anything on an explicit instantiation
2002 // or explicit specialization because there will be an explicit
2003 // node for it elsewhere.
2007 break;
2008 }
2009 }
2010 }
2011
2012 return true;
2013}
2014
2015template <typename Derived>
2017 VarTemplateDecl *D) {
2018 for (auto *SD : D->specializations()) {
2019 for (auto *RD : SD->redecls()) {
2020 switch (
2021 cast<VarTemplateSpecializationDecl>(RD)->getSpecializationKind()) {
2022 case TSK_Undeclared:
2024 TRY_TO(TraverseDecl(RD));
2025 break;
2026
2030 break;
2031 }
2032 }
2033 }
2034
2035 return true;
2036}
2037
2038// A helper method for traversing the instantiations of a
2039// function while skipping its specializations.
2040template <typename Derived>
2043 for (auto *FD : D->specializations()) {
2044 for (auto *RD : FD->redecls()) {
2045 switch (RD->getTemplateSpecializationKind()) {
2046 case TSK_Undeclared:
2048 // We don't know what kind of FunctionDecl this is.
2049 TRY_TO(TraverseDecl(RD));
2050 break;
2051
2052 // Unlike class/variable template specializations, function template
2053 // specializations are not independent children of the DeclContext —
2054 // they are only reachable via FunctionTemplateDecl::specializations().
2055 // We must traverse them here so visitors can see the instantiated body.
2058 TRY_TO(TraverseDecl(RD));
2059 break;
2060
2062 break;
2063 }
2064 }
2065 }
2066
2067 return true;
2068}
2069
2070// This macro unifies the traversal of class, variable and function
2071// template declarations.
2072#define DEF_TRAVERSE_TMPL_DECL(TMPLDECLKIND) \
2073 DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateDecl, { \
2074 TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \
2075 TRY_TO(TraverseDecl(D->getTemplatedDecl())); \
2076 \
2077 /* By default, we do not traverse the instantiations of \
2078 class templates since they do not appear in the user code. The \
2079 following code optionally traverses them. \
2080 \
2081 We only traverse the class instantiations when we see the canonical \
2082 declaration of the template, to ensure we only visit them once. */ \
2083 if (getDerived().shouldVisitTemplateInstantiations() && \
2084 D == D->getCanonicalDecl()) \
2085 TRY_TO(TraverseTemplateInstantiations(D)); \
2086 \
2087 /* Note that getInstantiatedFromMemberTemplate() is just a link \
2088 from a template instantiation back to the template from which \
2089 it was instantiated, and thus should not be traversed. */ \
2090 })
2091
2095
2097 // D is the "T" in something like
2098 // template <template <typename> class T> class container { };
2099 TRY_TO(TraverseDecl(D->getTemplatedDecl()));
2100 if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
2101 TRY_TO(TraverseTemplateArgumentLoc(D->getDefaultArgument()));
2102 TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
2103})
2104
2106 TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
2107})
2108
2109template <typename Derived>
2110bool RecursiveASTVisitor<Derived>::TraverseTemplateTypeParamDeclConstraints(
2111 const TemplateTypeParmDecl *D) {
2112 if (const auto *TC = D->getTypeConstraint())
2113 TRY_TO(TraverseTypeConstraint(TC));
2114 return true;
2115}
2116
2118 // D is the "T" in something like "template<typename T> class vector;"
2119 if (D->getTypeForDecl())
2120 TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
2121 TRY_TO(TraverseTemplateTypeParamDeclConstraints(D));
2122 if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
2123 TRY_TO(TraverseTemplateArgumentLoc(D->getDefaultArgument()));
2124})
2125
2127 TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
2128 // We shouldn't traverse D->getTypeForDecl(); it's a result of
2129 // declaring the typedef, not something that was written in the
2130 // source.
2131})
2132
2134 TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
2135 // We shouldn't traverse D->getTypeForDecl(); it's a result of
2136 // declaring the type alias, not something that was written in the
2137 // source.
2138})
2139
2141 TRY_TO(TraverseDecl(D->getTemplatedDecl()));
2142 TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
2143})
2144
2146 TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
2147 TRY_TO(TraverseStmt(D->getConstraintExpr()));
2148})
2149
2151 // A dependent using declaration which was marked with 'typename'.
2152 // template<class T> class A : public B<T> { using typename B<T>::foo; };
2153 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
2154 // We shouldn't traverse D->getTypeForDecl(); it's a result of
2155 // declaring the type, not something that was written in the
2156 // source.
2157})
2158
2160
2162 TRY_TO(TraverseDeclTemplateParameterLists(D));
2163
2164 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
2165 if (auto *TSI = D->getIntegerTypeSourceInfo())
2166 TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
2167 // The enumerators are already traversed by
2168 // decls_begin()/decls_end().
2169})
2170
2171// Helper methods for RecordDecl and its children.
2172template <typename Derived>
2173bool RecursiveASTVisitor<Derived>::TraverseRecordHelper(RecordDecl *D) {
2174 // We shouldn't traverse D->getTypeForDecl(); it's a result of
2175 // declaring the type, not something that was written in the source.
2176
2177 TRY_TO(TraverseDeclTemplateParameterLists(D));
2178 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
2179 return true;
2180}
2181
2182template <typename Derived>
2184 const CXXBaseSpecifier &Base) {
2185 TRY_TO(TraverseTypeLoc(Base.getTypeSourceInfo()->getTypeLoc()));
2186 return true;
2187}
2188
2189template <typename Derived>
2190bool RecursiveASTVisitor<Derived>::TraverseCXXRecordHelper(CXXRecordDecl *D) {
2191 if (!TraverseRecordHelper(D))
2192 return false;
2193 if (D->isCompleteDefinition()) {
2194 for (const auto &I : D->bases()) {
2195 TRY_TO(TraverseCXXBaseSpecifier(I));
2196 }
2197 // We don't traverse the friends or the conversions, as they are
2198 // already in decls_begin()/decls_end().
2199 }
2200 return true;
2201}
2202
2203DEF_TRAVERSE_DECL(RecordDecl, { TRY_TO(TraverseRecordHelper(D)); })
2204
2205DEF_TRAVERSE_DECL(CXXRecordDecl, { TRY_TO(TraverseCXXRecordHelper(D)); })
2206
2207template <typename Derived>
2208bool RecursiveASTVisitor<Derived>::TraverseTemplateArgumentLocsHelper(
2209 const TemplateArgumentLoc *TAL, unsigned Count) {
2210 for (unsigned I = 0; I < Count; ++I) {
2211 TRY_TO(TraverseTemplateArgumentLoc(TAL[I]));
2212 }
2213 return true;
2214}
2215
2216#define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND, DECLKIND) \
2217 DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateSpecializationDecl, { \
2218 /* For implicit instantiations ("set<int> x;"), we don't want to \
2219 recurse at all, since the instatiated template isn't written in \
2220 the source code anywhere. (Note the instatiated *type* -- \
2221 set<int> -- is written, and will still get a callback of \
2222 TemplateSpecializationType). For explicit instantiations \
2223 ("template set<int>;"), the ExplicitInstantiationDecl node \
2224 handles traversal of template args and qualifier. \
2225 For explicit specializations ("template<> set<int> {...};"), \
2226 we traverse template args here since there is no EID. */ \
2227 if (D->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) { \
2228 const auto *ArgsWritten = D->getTemplateArgsAsWritten(); \
2229 TRY_TO(TraverseTemplateArgumentLocsHelper( \
2230 ArgsWritten->getTemplateArgs(), ArgsWritten->NumTemplateArgs)); \
2231 } else if (!getDerived().shouldVisitTemplateInstantiations()) { \
2232 /* Returning from here skips traversing the \
2233 declaration context of the *TemplateSpecializationDecl \
2234 (embedded in the DEF_TRAVERSE_DECL() macro) \
2235 which contains the instantiated members of the template. */ \
2236 return true; \
2237 } \
2238 \
2239 /* Traverse base definition for explicit specializations */ \
2240 TRY_TO(Traverse##DECLKIND##Helper(D)); \
2241 })
2242
2245
2246#define DEF_TRAVERSE_TMPL_PART_SPEC_DECL(TMPLDECLKIND, DECLKIND) \
2247 DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplatePartialSpecializationDecl, { \
2248 /* The partial specialization. */ \
2249 TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \
2250 /* The args that remains unspecialized. */ \
2251 TRY_TO(TraverseTemplateArgumentLocsHelper( \
2252 D->getTemplateArgsAsWritten()->getTemplateArgs(), \
2253 D->getTemplateArgsAsWritten()->NumTemplateArgs)); \
2254 \
2255 /* Don't need the *TemplatePartialSpecializationHelper, even \
2256 though that's our parent class -- we already visit all the \
2257 template args here. */ \
2258 TRY_TO(Traverse##DECLKIND##Helper(D)); \
2259 \
2260 /* Instantiations will have been visited with the primary template. */ \
2261 })
2262
2265
2266DEF_TRAVERSE_DECL(EnumConstantDecl, { TRY_TO(TraverseStmt(D->getInitExpr())); })
2267
2269 // Like UnresolvedUsingTypenameDecl, but without the 'typename':
2270 // template <class T> Class A : public Base<T> { using Base<T>::foo; };
2271 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
2272 TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
2273})
2274
2276
2277template <typename Derived>
2278bool RecursiveASTVisitor<Derived>::TraverseDeclaratorHelper(DeclaratorDecl *D) {
2279 TRY_TO(TraverseDeclTemplateParameterLists(D));
2280 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
2281 if (D->getTypeSourceInfo())
2282 TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
2283 else
2284 TRY_TO(TraverseType(D->getType()));
2285 return true;
2286}
2287
2289 TRY_TO(TraverseVarHelper(D));
2290 for (auto *Binding : D->bindings()) {
2291 TRY_TO(TraverseDecl(Binding));
2292 }
2293})
2294
2296 if (getDerived().shouldVisitImplicitCode()) {
2297 TRY_TO(TraverseStmt(D->getBinding()));
2298 if (const auto HoldingVar = D->getHoldingVar())
2299 TRY_TO(TraverseDecl(HoldingVar));
2300 }
2301})
2302
2303DEF_TRAVERSE_DECL(MSPropertyDecl, { TRY_TO(TraverseDeclaratorHelper(D)); })
2304
2307
2309
2311 TRY_TO(TraverseDeclaratorHelper(D));
2312 if (D->isBitField())
2313 TRY_TO(TraverseStmt(D->getBitWidth()));
2314 if (D->hasInClassInitializer())
2315 TRY_TO(TraverseStmt(D->getInClassInitializer()));
2316})
2317
2319 TRY_TO(TraverseDeclaratorHelper(D));
2320 if (D->isBitField())
2321 TRY_TO(TraverseStmt(D->getBitWidth()));
2322 // FIXME: implement the rest.
2323})
2324
2326 TRY_TO(TraverseDeclaratorHelper(D));
2327 if (D->isBitField())
2328 TRY_TO(TraverseStmt(D->getBitWidth()));
2329 // FIXME: implement the rest.
2330})
2331
2332template <typename Derived>
2333bool RecursiveASTVisitor<Derived>::TraverseFunctionHelper(FunctionDecl *D) {
2334 TRY_TO(TraverseDeclTemplateParameterLists(D));
2335 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
2336 TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
2337
2338 // If we're an explicit template specialization, iterate over the
2339 // template args that were explicitly specified. If we were doing
2340 // this in typing order, we'd do it between the return type and
2341 // the function args, but both are handled by the FunctionTypeLoc
2342 // above, so we have to choose one side. I've decided to do before.
2343 if (const FunctionTemplateSpecializationInfo *FTSI =
2344 D->getTemplateSpecializationInfo()) {
2345 if (FTSI->getTemplateSpecializationKind() != TSK_Undeclared &&
2346 FTSI->getTemplateSpecializationKind() != TSK_ImplicitInstantiation) {
2347 // A specialization might not have explicit template arguments if it has
2348 // a templated return type and concrete arguments.
2349 if (const ASTTemplateArgumentListInfo *TALI =
2350 FTSI->TemplateArgumentsAsWritten) {
2351 TRY_TO(TraverseTemplateArgumentLocsHelper(TALI->getTemplateArgs(),
2352 TALI->NumTemplateArgs));
2353 }
2354 }
2355 } else if (const DependentFunctionTemplateSpecializationInfo *DFSI =
2356 D->getDependentSpecializationInfo()) {
2357 if (const ASTTemplateArgumentListInfo *TALI =
2358 DFSI->TemplateArgumentsAsWritten) {
2359 TRY_TO(TraverseTemplateArgumentLocsHelper(TALI->getTemplateArgs(),
2360 TALI->NumTemplateArgs));
2361 }
2362 }
2363
2364 // Visit the function type itself, which can be either
2365 // FunctionNoProtoType or FunctionProtoType, or a typedef. This
2366 // also covers the return type and the function parameters,
2367 // including exception specifications.
2368 if (TypeSourceInfo *TSI = D->getTypeSourceInfo()) {
2369 TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
2370 } else if (getDerived().shouldVisitImplicitCode()) {
2371 // Visit parameter variable declarations of the implicit function
2372 // if the traverser is visiting implicit code. Parameter variable
2373 // declarations do not have valid TypeSourceInfo, so to visit them
2374 // we need to traverse the declarations explicitly.
2375 for (ParmVarDecl *Parameter : D->parameters()) {
2376 TRY_TO(TraverseDecl(Parameter));
2377 }
2378 }
2379
2380 // Visit the trailing requires clause, if any.
2381 if (const AssociatedConstraint &TrailingRequiresClause =
2382 D->getTrailingRequiresClause()) {
2383 TRY_TO(TraverseStmt(
2384 const_cast<Expr *>(TrailingRequiresClause.ConstraintExpr)));
2385 }
2386
2387 if (CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(D)) {
2388 // Constructor initializers.
2389 for (auto *I : Ctor->inits()) {
2390 if (I->isWritten() || getDerived().shouldVisitImplicitCode())
2391 TRY_TO(TraverseConstructorInitializer(I));
2392 }
2393 }
2394
2395 bool VisitBody =
2396 D->isThisDeclarationADefinition() &&
2397 // Don't visit the function body if the function definition is generated
2398 // by clang.
2399 (!D->isDefaulted() || getDerived().shouldVisitImplicitCode());
2400
2401 if (const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
2402 if (const CXXRecordDecl *RD = MD->getParent()) {
2403 if (RD->isLambda() &&
2404 declaresSameEntity(RD->getLambdaCallOperator(), MD)) {
2405 VisitBody = VisitBody && getDerived().shouldVisitLambdaBody();
2406 }
2407 }
2408 }
2409
2410 if (VisitBody) {
2411 TRY_TO(TraverseStmt(D->getBody()));
2412 // Body may contain using declarations whose shadows are parented to the
2413 // FunctionDecl itself.
2414 for (auto *Child : D->decls()) {
2415 if (isa<UsingShadowDecl>(Child))
2416 TRY_TO(TraverseDecl(Child));
2417 }
2418 }
2419 return true;
2420}
2421
2423 // We skip decls_begin/decls_end, which are already covered by
2424 // TraverseFunctionHelper().
2425 ShouldVisitChildren = false;
2426 ReturnValue = TraverseFunctionHelper(D);
2427})
2428
2430 // We skip decls_begin/decls_end, which are already covered by
2431 // TraverseFunctionHelper().
2432 ShouldVisitChildren = false;
2433 ReturnValue = TraverseFunctionHelper(D);
2434})
2435
2437 // We skip decls_begin/decls_end, which are already covered by
2438 // TraverseFunctionHelper().
2439 ShouldVisitChildren = false;
2440 ReturnValue = TraverseFunctionHelper(D);
2441})
2442
2444 // We skip decls_begin/decls_end, which are already covered by
2445 // TraverseFunctionHelper().
2446 ShouldVisitChildren = false;
2447 ReturnValue = TraverseFunctionHelper(D);
2448})
2449
2450// CXXConversionDecl is the declaration of a type conversion operator.
2451// It's not a cast expression.
2453 // We skip decls_begin/decls_end, which are already covered by
2454 // TraverseFunctionHelper().
2455 ShouldVisitChildren = false;
2456 ReturnValue = TraverseFunctionHelper(D);
2457})
2458
2460 // We skip decls_begin/decls_end, which are already covered by
2461 // TraverseFunctionHelper().
2462 ShouldVisitChildren = false;
2463 ReturnValue = TraverseFunctionHelper(D);
2464})
2465
2466template <typename Derived>
2467bool RecursiveASTVisitor<Derived>::TraverseVarHelper(VarDecl *D) {
2468 TRY_TO(TraverseDeclaratorHelper(D));
2469 // Default params are taken care of when we traverse the ParmVarDecl.
2470 if (!isa<ParmVarDecl>(D) &&
2471 (!D->isCXXForRangeDecl() || getDerived().shouldVisitImplicitCode()))
2472 TRY_TO(TraverseStmt(D->getInit()));
2473 return true;
2474}
2475
2476DEF_TRAVERSE_DECL(VarDecl, { TRY_TO(TraverseVarHelper(D)); })
2477
2478DEF_TRAVERSE_DECL(ImplicitParamDecl, { TRY_TO(TraverseVarHelper(D)); })
2479
2481 // A non-type template parameter, e.g. "S" in template<int S> class Foo ...
2482 TRY_TO(TraverseDeclaratorHelper(D));
2483 if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
2484 TRY_TO(TraverseTemplateArgumentLoc(D->getDefaultArgument()));
2485})
2486
2488 TRY_TO(TraverseVarHelper(D));
2489
2490 if (D->hasDefaultArg() && D->hasUninstantiatedDefaultArg() &&
2491 !D->hasUnparsedDefaultArg())
2492 TRY_TO(TraverseStmt(D->getUninstantiatedDefaultArg()));
2493
2494 if (D->hasDefaultArg() && !D->hasUninstantiatedDefaultArg() &&
2495 !D->hasUnparsedDefaultArg())
2496 TRY_TO(TraverseStmt(D->getDefaultArg()));
2497})
2498
2500
2502 TRY_TO(TraverseTemplateArguments(D->getTemplateArguments()));
2503})
2504
2505#undef DEF_TRAVERSE_DECL
2506
2507// ----------------- Stmt traversal -----------------
2508//
2509// For stmts, we automate (in the DEF_TRAVERSE_STMT macro) iterating
2510// over the children defined in children() (every stmt defines these,
2511// though sometimes the range is empty). Each individual Traverse*
2512// method only needs to worry about children other than those. To see
2513// what children() does for a given class, see, e.g.,
2514// http://clang.llvm.org/doxygen/Stmt_8cpp_source.html
2515
2516// This macro makes available a variable S, the passed-in stmt.
2517#define DEF_TRAVERSE_STMT(STMT, CODE) \
2518 template <typename Derived> \
2520 STMT *S, DataRecursionQueue *Queue) { \
2521 bool ShouldVisitChildren = true; \
2522 bool ReturnValue = true; \
2523 if (!getDerived().shouldTraversePostOrder()) \
2524 TRY_TO(WalkUpFrom##STMT(S)); \
2525 { CODE; } \
2526 if (ShouldVisitChildren) { \
2527 for (Stmt * SubStmt : getDerived().getStmtChildren(S)) { \
2528 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(SubStmt); \
2529 } \
2530 } \
2531 /* Call WalkUpFrom if TRY_TO_TRAVERSE_OR_ENQUEUE_STMT has traversed the \
2532 * children already. If TRY_TO_TRAVERSE_OR_ENQUEUE_STMT only enqueued the \
2533 * children, PostVisitStmt will call WalkUpFrom after we are done visiting \
2534 * children. */ \
2535 if (!Queue && ReturnValue && getDerived().shouldTraversePostOrder()) { \
2536 TRY_TO(WalkUpFrom##STMT(S)); \
2537 } \
2538 return ReturnValue; \
2539 }
2540
2542 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getAsmStringExpr());
2543 for (unsigned I = 0, E = S->getNumInputs(); I < E; ++I) {
2544 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getInputConstraintExpr(I));
2545 }
2546 for (unsigned I = 0, E = S->getNumOutputs(); I < E; ++I) {
2547 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOutputConstraintExpr(I));
2548 }
2549 for (unsigned I = 0, E = S->getNumClobbers(); I < E; ++I) {
2550 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getClobberExpr(I));
2551 }
2552 // children() iterates over inputExpr and outputExpr.
2553})
2554
2556 MSAsmStmt,
2557 {// FIXME: MS Asm doesn't currently parse Constraints, Clobbers, etc. Once
2558 // added this needs to be implemented.
2559 })
2560
2562 TRY_TO(TraverseDecl(S->getExceptionDecl()));
2563 // children() iterates over the handler block.
2564})
2565
2567 TRY_TO(TraverseDecl(S->getCatchParamDecl()));
2568 // children() iterates over the handler block.
2569})
2570
2572 for (auto *I : S->decls()) {
2573 TRY_TO(TraverseDecl(I));
2574 }
2575 // Suppress the default iteration over children() by
2576 // returning. Here's why: A DeclStmt looks like 'type var [=
2577 // initializer]'. The decls above already traverse over the
2578 // initializers, so we don't have to do it again (which
2579 // children() would do).
2580 ShouldVisitChildren = false;
2581})
2582
2583// These non-expr stmts (most of them), do not need any action except
2584// iterating over the children.
2606
2608 if (!getDerived().shouldVisitImplicitCode()) {
2609 if (S->getInit())
2610 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getInit());
2611 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLoopVarStmt());
2612 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRangeInit());
2613 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getBody());
2614 // Visit everything else only if shouldVisitImplicitCode().
2615 ShouldVisitChildren = false;
2616 }
2617})
2618
2620 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2621 TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2622})
2623
2627
2629
2631 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2632 TRY_TO(TraverseDeclarationNameInfo(S->getMemberNameInfo()));
2633 if (S->hasExplicitTemplateArgs()) {
2634 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2635 S->getNumTemplateArgs()));
2636 }
2637})
2638
2640 TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2641 TRY_TO(TraverseTemplateName(S->getTemplateName()));
2642 TRY_TO(TraverseTemplateArgumentLocsHelper(S->template_arguments().data(),
2643 S->getNumTemplateArgs()));
2644})
2645
2647 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2648 TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2649 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2650 S->getNumTemplateArgs()));
2651})
2652
2654 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2655 TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2656 if (S->hasExplicitTemplateArgs()) {
2657 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2658 S->getNumTemplateArgs()));
2659 }
2660})
2661
2663 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2664 TRY_TO(TraverseDeclarationNameInfo(S->getMemberNameInfo()));
2665 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2666 S->getNumTemplateArgs()));
2667})
2668
2671 {// We don't traverse the cast type, as it's not written in the
2672 // source code.
2673 })
2674
2676 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2677})
2678
2680 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2681})
2682
2684 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2685})
2686
2688 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2689})
2690
2692 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2693})
2694
2696 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2697})
2698
2700 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2701})
2702
2704 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2705})
2706
2707template <typename Derived>
2709 InitListExpr *S, DataRecursionQueue *Queue) {
2710 if (S) {
2711 // Skip this if we traverse postorder. We will visit it later
2712 // in PostVisitStmt.
2713 if (!getDerived().shouldTraversePostOrder())
2714 TRY_TO(WalkUpFromInitListExpr(S));
2715
2716 // All we need are the default actions. FIXME: use a helper function.
2717 for (Stmt *SubStmt : S->children()) {
2719 }
2720
2721 if (!Queue && getDerived().shouldTraversePostOrder())
2722 TRY_TO(WalkUpFromInitListExpr(S));
2723 }
2724 return true;
2725}
2726
2727template <typename Derived>
2729 ObjCProtocolLoc ProtocolLoc) {
2730 return true;
2731}
2732
2733template <typename Derived>
2735 ConceptReference *CR) {
2736 if (!getDerived().shouldTraversePostOrder())
2737 TRY_TO(VisitConceptReference(CR));
2738 TRY_TO(TraverseNestedNameSpecifierLoc(CR->getNestedNameSpecifierLoc()));
2739 TRY_TO(TraverseDeclarationNameInfo(CR->getConceptNameInfo()));
2740 TRY_TO(TraverseTemplateName(CR->getNamedConcept(),
2741 /*TraverseQualifier=*/false));
2742 if (CR->hasExplicitTemplateArgs())
2743 TRY_TO(TraverseTemplateArgumentLocsHelper(
2744 CR->getTemplateArgsAsWritten()->getTemplateArgs(),
2745 CR->getTemplateArgsAsWritten()->NumTemplateArgs));
2746 if (getDerived().shouldTraversePostOrder())
2747 TRY_TO(VisitConceptReference(CR));
2748 return true;
2749}
2750
2751template <typename Derived>
2753 const OffsetOfNode *Node) {
2754 TRY_TO(VisitOffsetOfNode(Node));
2755 return true;
2756}
2757
2758// If shouldVisitImplicitCode() returns false, this method traverses only the
2759// syntactic form of InitListExpr.
2760// If shouldVisitImplicitCode() return true, this method is called once for
2761// each pair of syntactic and semantic InitListExpr, and it traverses the
2762// subtrees defined by the two forms. This may cause some of the children to be
2763// visited twice, if they appear both in the syntactic and the semantic form.
2764//
2765// There is no guarantee about which form \p S takes when this method is called.
2766template <typename Derived>
2768 InitListExpr *S, DataRecursionQueue *Queue) {
2769 if (S->isSemanticForm() && S->isSyntacticForm()) {
2770 // `S` does not have alternative forms, traverse only once.
2771 TRY_TO(TraverseSynOrSemInitListExpr(S, Queue));
2772 return true;
2773 }
2774 TRY_TO(TraverseSynOrSemInitListExpr(
2775 S->isSemanticForm() ? S->getSyntacticForm() : S, Queue));
2776 if (getDerived().shouldVisitImplicitCode()) {
2777 // Only visit the semantic form if the clients are interested in implicit
2778 // compiler-generated.
2779 TRY_TO(TraverseSynOrSemInitListExpr(
2780 S->isSemanticForm() ? S : S->getSemanticForm(), Queue));
2781 }
2782 return true;
2783}
2784
2785// GenericSelectionExpr is a special case because the types and expressions
2786// are interleaved. We also need to watch out for null types (default
2787// generic associations).
2789 if (S->isExprPredicate())
2790 TRY_TO(TraverseStmt(S->getControllingExpr()));
2791 else
2792 TRY_TO(TraverseTypeLoc(S->getControllingType()->getTypeLoc()));
2793
2794 for (const GenericSelectionExpr::Association Assoc : S->associations()) {
2795 if (TypeSourceInfo *TSI = Assoc.getTypeSourceInfo())
2796 TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
2797 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(Assoc.getAssociationExpr());
2798 }
2799 ShouldVisitChildren = false;
2800})
2801
2802// PseudoObjectExpr is a special case because of the weirdness with
2803// syntactic expressions and opaque values.
2805 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSyntacticForm());
2806 for (PseudoObjectExpr::semantics_iterator i = S->semantics_begin(),
2807 e = S->semantics_end();
2808 i != e; ++i) {
2809 Expr *sub = *i;
2810 if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(sub))
2811 sub = OVE->getSourceExpr();
2813 }
2814 ShouldVisitChildren = false;
2815})
2816
2818 // This is called for code like 'return T()' where T is a built-in
2819 // (i.e. non-class) type.
2820 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2821})
2822
2824 // The child-iterator will pick up the other arguments.
2825 TRY_TO(TraverseTypeLoc(S->getAllocatedTypeSourceInfo()->getTypeLoc()));
2826})
2827
2829 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2830 // Visit each designator component (e.g. the `a`, `b`, `c` in
2831 // offsetof(Foo, a.b.c)). Array index expressions are reached through the
2832 // child-iterator, which DEF_TRAVERSE_STMT walks automatically.
2833 for (unsigned I = 0, E = S->getNumComponents(); I != E; ++I)
2834 TRY_TO(TraverseOffsetOfNode(&S->getComponent(I)));
2835})
2836
2838 // The child-iterator will pick up the arg if it's an expression,
2839 // but not if it's a type.
2840 if (S->isArgumentType())
2841 TRY_TO(TraverseTypeLoc(S->getArgumentTypeInfo()->getTypeLoc()));
2842})
2843
2845 // The child-iterator will pick up the arg if it's an expression,
2846 // but not if it's a type.
2847 if (S->isTypeOperand())
2848 TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
2849})
2850
2852 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2853})
2854
2856
2858 // The child-iterator will pick up the arg if it's an expression,
2859 // but not if it's a type.
2860 if (S->isTypeOperand())
2861 TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
2862})
2863
2865 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
2866 TRY_TO(TraverseTypeLoc(S->getArg(I)->getTypeLoc()));
2867})
2868
2870 TRY_TO(TraverseTypeLoc(S->getQueriedTypeSourceInfo()->getTypeLoc()));
2871})
2872
2874 { TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getQueriedExpression()); })
2875
2877 // The child-iterator will pick up the expression argument.
2878 TRY_TO(TraverseTypeLoc(S->getWrittenTypeInfo()->getTypeLoc()));
2879})
2880
2882 // This is called for code like 'return T()' where T is a class type.
2883 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2884})
2885
2886// Walk only the visible parts of lambda expressions.
2888 // Visit the capture list.
2889 for (unsigned I = 0, N = S->capture_size(); I != N; ++I) {
2890 const LambdaCapture *C = S->capture_begin() + I;
2891 if (C->isExplicit() || getDerived().shouldVisitImplicitCode()) {
2892 TRY_TO(TraverseLambdaCapture(S, C, S->capture_init_begin()[I]));
2893 }
2894 }
2895
2896 if (getDerived().shouldVisitImplicitCode()) {
2897 // The implicit model is simple: everything else is in the lambda class.
2898 TRY_TO(TraverseDecl(S->getLambdaClass()));
2899 } else {
2900 // We need to poke around to find the bits that might be explicitly written.
2901 TypeLoc TL = S->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
2903
2904 TRY_TO(TraverseTemplateParameterListHelper(S->getTemplateParameterList()));
2905 if (S->hasExplicitParameters()) {
2906 // Visit parameters.
2907 for (unsigned I = 0, N = Proto.getNumParams(); I != N; ++I)
2908 TRY_TO(TraverseDecl(Proto.getParam(I)));
2909 }
2910
2911 auto *T = Proto.getTypePtr();
2912 for (const auto &E : T->exceptions())
2913 TRY_TO(TraverseType(E));
2914
2915 if (Expr *NE = T->getNoexceptExpr())
2917
2918 if (S->hasExplicitResultType())
2919 TRY_TO(TraverseTypeLoc(Proto.getReturnLoc()));
2921 const_cast<Expr *>(S->getTrailingRequiresClause().ConstraintExpr));
2922
2923 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getBody());
2924 }
2925 ShouldVisitChildren = false;
2926})
2927
2929 // This is called for code like 'T()', where T is a template argument.
2930 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2931})
2932
2934
2935// These expressions all might take explicit template arguments.
2936// We traverse those if so. FIXME: implement these.
2940
2941// These exprs (most of them), do not need any action except iterating
2942// over the children.
2950
2952 TRY_TO(TraverseDecl(S->getBlockDecl()));
2953 return true; // no child statements to loop through.
2954})
2955
2958 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2959})
2962
2964 if (getDerived().shouldVisitImplicitCode())
2965 TRY_TO(TraverseStmt(S->getExpr()));
2966})
2967
2969 if (getDerived().shouldVisitImplicitCode())
2970 TRY_TO(TraverseStmt(S->getExpr()));
2971})
2972
2978
2980 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2981 if (TypeSourceInfo *ScopeInfo = S->getScopeTypeInfo())
2982 TRY_TO(TraverseTypeLoc(ScopeInfo->getTypeLoc()));
2983 if (TypeSourceInfo *DestroyedTypeInfo = S->getDestroyedTypeInfo())
2984 TRY_TO(TraverseTypeLoc(DestroyedTypeInfo->getTypeLoc()));
2985})
2986
2998 // FIXME: The source expression of the OVE should be listed as
2999 // a child of the ArrayInitLoopExpr.
3000 if (OpaqueValueExpr *OVE = S->getCommonExpr())
3001 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(OVE->getSourceExpr());
3002})
3005
3007 if (TypeSourceInfo *TInfo = S->getEncodedTypeSourceInfo())
3008 TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
3009})
3010
3013
3015 if (TypeSourceInfo *TInfo = S->getClassReceiverTypeInfo())
3016 TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
3017})
3018
3020 if (S->isClassReceiver()) {
3021 ObjCInterfaceDecl *IDecl = S->getClassReceiver();
3022 QualType Type = IDecl->getASTContext().getObjCInterfaceType(IDecl);
3024 Data.NameLoc = S->getReceiverLocation();
3025 Data.NameEndLoc = Data.NameLoc;
3026 TRY_TO(TraverseTypeLoc(TypeLoc(Type, &Data)));
3027 }
3028})
3033
3035 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
3036})
3037
3042 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
3043})
3045 if (getDerived().shouldVisitImplicitCode()) {
3046 TRY_TO(TraverseStmt(S->getOriginalStmt()));
3047 TRY_TO(TraverseStmt(S->getKernelLaunchIdExpr()));
3048 ShouldVisitChildren = false;
3049 }
3050})
3058 for (IntegerLiteral *IL : S->underlying_data_elements()) {
3060 }
3061})
3062
3064 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
3065 if (S->hasExplicitTemplateArgs()) {
3066 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
3067 S->getNumTemplateArgs()));
3068 }
3069})
3070
3072 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
3073 if (S->hasExplicitTemplateArgs()) {
3074 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
3075 S->getNumTemplateArgs()));
3076 }
3077})
3078
3083DEF_TRAVERSE_STMT(CapturedStmt, { TRY_TO(TraverseDecl(S->getCapturedDecl())); })
3084
3086 if (getDerived().shouldVisitImplicitCode()) {
3087 TRY_TO(TraverseStmt(S->getOriginalStmt()));
3088 TRY_TO(TraverseStmt(S->getKernelLaunchStmt()));
3089 TRY_TO(TraverseDecl(S->getOutlinedFunctionDecl()));
3090 ShouldVisitChildren = false;
3091 }
3092})
3093
3096 if (!getDerived().shouldVisitImplicitCode()) {
3098 S->getDecomposedForm();
3099 TRY_TO(TraverseStmt(const_cast<Expr*>(Decomposed.LHS)));
3100 TRY_TO(TraverseStmt(const_cast<Expr*>(Decomposed.RHS)));
3101 ShouldVisitChildren = false;
3102 }
3103})
3107
3108// These operators (all of them) do not need any action except
3109// iterating over the children.
3125
3127 if (S->getLifetimeExtendedTemporaryDecl()) {
3128 TRY_TO(TraverseLifetimeExtendedTemporaryDecl(
3129 S->getLifetimeExtendedTemporaryDecl()));
3130 ShouldVisitChildren = false;
3131 }
3132})
3133// For coroutines expressions, traverse either the operand
3134// as written or the implied calls, depending on what the
3135// derived class requests.
3137 if (!getDerived().shouldVisitImplicitCode()) {
3138 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getBody());
3139 ShouldVisitChildren = false;
3140 }
3141})
3143 if (!getDerived().shouldVisitImplicitCode()) {
3144 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand());
3145 ShouldVisitChildren = false;
3146 }
3147})
3149 if (!getDerived().shouldVisitImplicitCode()) {
3150 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand());
3151 ShouldVisitChildren = false;
3152 }
3153})
3155 if (!getDerived().shouldVisitImplicitCode()) {
3156 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand());
3157 ShouldVisitChildren = false;
3158 }
3159})
3161 if (!getDerived().shouldVisitImplicitCode()) {
3162 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand());
3163 ShouldVisitChildren = false;
3164 }
3165})
3166
3168 TRY_TO(TraverseConceptReference(S->getConceptReference()));
3169})
3170
3172 TRY_TO(TraverseDecl(S->getBody()));
3173 for (ParmVarDecl *Parm : S->getLocalParameters())
3174 TRY_TO(TraverseDecl(Parm));
3175 for (concepts::Requirement *Req : S->getRequirements())
3176 TRY_TO(TraverseConceptRequirement(Req));
3177})
3178
3182
3183// These literals (all of them) do not need any action.
3194
3195// Traverse OpenCL: AsType, Convert.
3197
3198// OpenMP directives.
3199template <typename Derived>
3200bool RecursiveASTVisitor<Derived>::TraverseOMPExecutableDirective(
3201 OMPExecutableDirective *S) {
3202 for (auto *C : S->clauses()) {
3203 TRY_TO(TraverseOMPClause(C));
3204 }
3205 return true;
3206}
3207
3208DEF_TRAVERSE_STMT(OMPCanonicalLoop, {
3209 if (!getDerived().shouldVisitImplicitCode()) {
3210 // Visit only the syntactical loop.
3211 TRY_TO(TraverseStmt(S->getLoopStmt()));
3212 ShouldVisitChildren = false;
3213 }
3214})
3215
3216template <typename Derived>
3217bool
3218RecursiveASTVisitor<Derived>::TraverseOMPLoopDirective(OMPLoopDirective *S) {
3219 return TraverseOMPExecutableDirective(S);
3220}
3221
3222DEF_TRAVERSE_STMT(OMPMetaDirective,
3223 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3224
3225DEF_TRAVERSE_STMT(OMPParallelDirective,
3226 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3227
3228DEF_TRAVERSE_STMT(OMPSimdDirective,
3229 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3230
3231DEF_TRAVERSE_STMT(OMPTileDirective,
3232 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3233
3234DEF_TRAVERSE_STMT(OMPStripeDirective,
3235 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3236
3237DEF_TRAVERSE_STMT(OMPUnrollDirective,
3238 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3239
3240DEF_TRAVERSE_STMT(OMPReverseDirective,
3241 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3242
3243DEF_TRAVERSE_STMT(OMPFuseDirective,
3244 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3245
3246DEF_TRAVERSE_STMT(OMPInterchangeDirective,
3247 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3248
3249DEF_TRAVERSE_STMT(OMPFlattenDirective,
3250 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3251
3252DEF_TRAVERSE_STMT(OMPSplitDirective,
3253 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3254
3255DEF_TRAVERSE_STMT(OMPForDirective,
3256 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3257
3258DEF_TRAVERSE_STMT(OMPForSimdDirective,
3259 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3260
3261DEF_TRAVERSE_STMT(OMPSectionsDirective,
3262 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3263
3264DEF_TRAVERSE_STMT(OMPSectionDirective,
3265 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3266
3267DEF_TRAVERSE_STMT(OMPScopeDirective,
3268 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3269
3270DEF_TRAVERSE_STMT(OMPSingleDirective,
3271 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3272
3273DEF_TRAVERSE_STMT(OMPMasterDirective,
3274 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3275
3276DEF_TRAVERSE_STMT(OMPCriticalDirective, {
3277 TRY_TO(TraverseDeclarationNameInfo(S->getDirectiveName()));
3278 TRY_TO(TraverseOMPExecutableDirective(S));
3279})
3280
3281DEF_TRAVERSE_STMT(OMPParallelForDirective,
3282 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3283
3284DEF_TRAVERSE_STMT(OMPParallelForSimdDirective,
3285 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3286
3287DEF_TRAVERSE_STMT(OMPParallelMasterDirective,
3288 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3289
3290DEF_TRAVERSE_STMT(OMPParallelMaskedDirective,
3291 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3292
3293DEF_TRAVERSE_STMT(OMPParallelSectionsDirective,
3294 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3295
3296DEF_TRAVERSE_STMT(OMPTaskDirective,
3297 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3298
3299DEF_TRAVERSE_STMT(OMPTaskyieldDirective,
3300 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3301
3302DEF_TRAVERSE_STMT(OMPBarrierDirective,
3303 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3304
3305DEF_TRAVERSE_STMT(OMPTaskwaitDirective,
3306 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3307
3308DEF_TRAVERSE_STMT(OMPTaskgroupDirective,
3309 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3310
3311DEF_TRAVERSE_STMT(OMPCancellationPointDirective,
3312 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3313
3314DEF_TRAVERSE_STMT(OMPCancelDirective,
3315 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3316
3317DEF_TRAVERSE_STMT(OMPFlushDirective,
3318 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3319
3320DEF_TRAVERSE_STMT(OMPDepobjDirective,
3321 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3322
3323DEF_TRAVERSE_STMT(OMPScanDirective,
3324 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3325
3326DEF_TRAVERSE_STMT(OMPOrderedStandaloneDirective,
3327 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3328
3329DEF_TRAVERSE_STMT(OMPOrderedBlockAssocDirective,
3330 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3331
3332DEF_TRAVERSE_STMT(OMPAtomicDirective,
3333 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3334
3335DEF_TRAVERSE_STMT(OMPTargetDirective,
3336 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3337
3338DEF_TRAVERSE_STMT(OMPTargetDataDirective,
3339 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3340
3341DEF_TRAVERSE_STMT(OMPTargetEnterDataDirective,
3342 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3343
3344DEF_TRAVERSE_STMT(OMPTargetExitDataDirective,
3345 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3346
3347DEF_TRAVERSE_STMT(OMPTargetParallelDirective,
3348 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3349
3350DEF_TRAVERSE_STMT(OMPTargetParallelForDirective,
3351 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3352
3353DEF_TRAVERSE_STMT(OMPTeamsDirective,
3354 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3355
3356DEF_TRAVERSE_STMT(OMPTargetUpdateDirective,
3357 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3358
3359DEF_TRAVERSE_STMT(OMPTaskLoopDirective,
3360 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3361
3362DEF_TRAVERSE_STMT(OMPTaskLoopSimdDirective,
3363 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3364
3365DEF_TRAVERSE_STMT(OMPMasterTaskLoopDirective,
3366 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3367
3368DEF_TRAVERSE_STMT(OMPMasterTaskLoopSimdDirective,
3369 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3370
3371DEF_TRAVERSE_STMT(OMPParallelMasterTaskLoopDirective,
3372 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3373
3374DEF_TRAVERSE_STMT(OMPParallelMasterTaskLoopSimdDirective,
3375 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3376
3377DEF_TRAVERSE_STMT(OMPMaskedTaskLoopDirective,
3378 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3379
3380DEF_TRAVERSE_STMT(OMPMaskedTaskLoopSimdDirective,
3381 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3382
3383DEF_TRAVERSE_STMT(OMPParallelMaskedTaskLoopDirective,
3384 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3385
3386DEF_TRAVERSE_STMT(OMPParallelMaskedTaskLoopSimdDirective,
3387 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3388
3389DEF_TRAVERSE_STMT(OMPDistributeDirective,
3390 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3391
3392DEF_TRAVERSE_STMT(OMPDistributeParallelForDirective,
3393 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3394
3395DEF_TRAVERSE_STMT(OMPDistributeParallelForSimdDirective,
3396 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3397
3398DEF_TRAVERSE_STMT(OMPDistributeSimdDirective,
3399 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3400
3401DEF_TRAVERSE_STMT(OMPTargetParallelForSimdDirective,
3402 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3403
3404DEF_TRAVERSE_STMT(OMPTargetSimdDirective,
3405 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3406
3407DEF_TRAVERSE_STMT(OMPTeamsDistributeDirective,
3408 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3409
3410DEF_TRAVERSE_STMT(OMPTeamsDistributeSimdDirective,
3411 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3412
3413DEF_TRAVERSE_STMT(OMPTeamsDistributeParallelForSimdDirective,
3414 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3415
3416DEF_TRAVERSE_STMT(OMPTeamsDistributeParallelForDirective,
3417 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3418
3419DEF_TRAVERSE_STMT(OMPTargetTeamsDirective,
3420 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3421
3422DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeDirective,
3423 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3424
3425DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeParallelForDirective,
3426 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3427
3428DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeParallelForSimdDirective,
3429 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3430
3431DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeSimdDirective,
3432 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3433
3434DEF_TRAVERSE_STMT(OMPInteropDirective,
3435 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3436
3437DEF_TRAVERSE_STMT(OMPDispatchDirective,
3438 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3439
3440DEF_TRAVERSE_STMT(OMPMaskedDirective,
3441 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3442
3443DEF_TRAVERSE_STMT(OMPGenericLoopDirective,
3444 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3445
3446DEF_TRAVERSE_STMT(OMPTeamsGenericLoopDirective,
3447 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3448
3449DEF_TRAVERSE_STMT(OMPTargetTeamsGenericLoopDirective,
3450 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3451
3452DEF_TRAVERSE_STMT(OMPParallelGenericLoopDirective,
3453 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3454
3455DEF_TRAVERSE_STMT(OMPTargetParallelGenericLoopDirective,
3456 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3457
3458DEF_TRAVERSE_STMT(OMPTargetGenericLoopDirective,
3459 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3460
3461DEF_TRAVERSE_STMT(OMPAssumeDirective,
3462 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3463
3464DEF_TRAVERSE_STMT(OMPErrorDirective,
3465 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3466
3467// OpenMP clauses.
3468template <typename Derived>
3469bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {
3470 if (!C)
3471 return true;
3472 switch (C->getClauseKind()) {
3473#define GEN_CLANG_CLAUSE_CLASS
3474#define CLAUSE_CLASS(Enum, Str, Class) \
3475 case llvm::omp::Clause::Enum: \
3476 TRY_TO(Visit##Class(static_cast<Class *>(C))); \
3477 break;
3478#define CLAUSE_NO_CLASS(Enum, Str) \
3479 case llvm::omp::Clause::Enum: \
3480 break;
3481#include "llvm/Frontend/OpenMP/OMP.inc"
3482 }
3483 return true;
3484}
3485
3486template <typename Derived>
3487bool RecursiveASTVisitor<Derived>::VisitOMPClauseWithPreInit(
3488 OMPClauseWithPreInit *Node) {
3489 TRY_TO(TraverseStmt(Node->getPreInitStmt()));
3490 return true;
3491}
3492
3493template <typename Derived>
3494bool RecursiveASTVisitor<Derived>::VisitOMPClauseWithPostUpdate(
3496 TRY_TO(VisitOMPClauseWithPreInit(Node));
3497 TRY_TO(TraverseStmt(Node->getPostUpdateExpr()));
3498 return true;
3499}
3500
3501template <typename Derived>
3504 TRY_TO(TraverseStmt(C->getAllocator()));
3505 return true;
3506}
3507
3508template <typename Derived>
3510 TRY_TO(TraverseStmt(C->getAllocator()));
3511 TRY_TO(VisitOMPClauseList(C));
3512 return true;
3513}
3514
3515template <typename Derived>
3517 TRY_TO(VisitOMPClauseWithPreInit(C));
3518 TRY_TO(TraverseStmt(C->getCondition()));
3519 return true;
3520}
3521
3522template <typename Derived>
3524 TRY_TO(VisitOMPClauseWithPreInit(C));
3525 TRY_TO(TraverseStmt(C->getCondition()));
3526 return true;
3527}
3528
3529template <typename Derived>
3530bool
3532 if (auto *E = C->getDimsModifierExpr())
3533 TRY_TO(VisitStmt(E));
3534 TRY_TO(VisitOMPClauseList(C));
3535 TRY_TO(VisitOMPClauseWithPreInit(C));
3536 return true;
3537}
3538
3539template <typename Derived>
3541 TRY_TO(TraverseStmt(C->getAlignment()));
3542 return true;
3543}
3544
3545template <typename Derived>
3547 TRY_TO(TraverseStmt(C->getSafelen()));
3548 return true;
3549}
3550
3551template <typename Derived>
3553 TRY_TO(TraverseStmt(C->getSimdlen()));
3554 return true;
3555}
3556
3557template <typename Derived>
3559 for (Expr *E : C->getSizesRefs())
3560 TRY_TO(TraverseStmt(E));
3561 return true;
3562}
3563
3564template <typename Derived>
3566 for (Expr *E : C->getCountsRefs())
3567 TRY_TO(TraverseStmt(E));
3568 return true;
3569}
3570
3571template <typename Derived>
3574 for (Expr *E : C->getArgsRefs())
3575 TRY_TO(TraverseStmt(E));
3576 return true;
3577}
3578
3579template <typename Derived>
3581 return true;
3582}
3583
3584template <typename Derived>
3587 TRY_TO(TraverseStmt(C->getFirst()));
3588 TRY_TO(TraverseStmt(C->getCount()));
3589 return true;
3590}
3591
3592template <typename Derived>
3594 TRY_TO(TraverseStmt(C->getFactor()));
3595 return true;
3596}
3597
3598template <typename Derived>
3600 TRY_TO(TraverseStmt(C->getDepth()));
3601 return true;
3602}
3603
3604template <typename Derived>
3605bool
3607 TRY_TO(TraverseStmt(C->getNumForLoops()));
3608 return true;
3609}
3610
3611template <typename Derived>
3613 return true;
3614}
3615
3616template <typename Derived>
3619 return true;
3620}
3621
3622template <typename Derived>
3624 OMPTransparentClause *C) {
3625 TRY_TO(TraverseStmt(C->getImpexType()));
3626 return true;
3627}
3628
3629template <typename Derived>
3631 return true;
3632}
3633
3634template <typename Derived>
3636 OMPUnifiedAddressClause *) {
3637 return true;
3638}
3639
3640template <typename Derived>
3642 OMPUnifiedSharedMemoryClause *) {
3643 return true;
3644}
3645
3646template <typename Derived>
3648 OMPReverseOffloadClause *) {
3649 return true;
3650}
3651
3652template <typename Derived>
3654 OMPDynamicAllocatorsClause *) {
3655 return true;
3656}
3657
3658template <typename Derived>
3660 OMPAtomicDefaultMemOrderClause *) {
3661 return true;
3662}
3663
3664template <typename Derived>
3666 return true;
3667}
3668
3669template <typename Derived>
3671 return true;
3672}
3673
3674template <typename Derived>
3676 return true;
3677}
3678
3679template <typename Derived>
3681 TRY_TO(TraverseStmt(C->getMessageString()));
3682 return true;
3683}
3684
3685template <typename Derived>
3686bool
3688 TRY_TO(VisitOMPClauseWithPreInit(C));
3689 TRY_TO(TraverseStmt(C->getChunkSize()));
3690 return true;
3691}
3692
3693template <typename Derived>
3695 TRY_TO(TraverseStmt(C->getNumForLoops()));
3696 return true;
3697}
3698
3699template <typename Derived>
3701 TRY_TO(TraverseStmt(C->getCondition()));
3702 return true;
3703}
3704
3705template <typename Derived>
3707 return true;
3708}
3709
3710template <typename Derived>
3711bool
3713 return true;
3714}
3715
3716template <typename Derived>
3718 return true;
3719}
3720
3721template <typename Derived>
3723 return true;
3724}
3725
3726template <typename Derived>
3728 return true;
3729}
3730
3731template <typename Derived>
3733 OMPUpdateDependObjectsClause *) {
3734 return true;
3735}
3736
3737template <typename Derived>
3739 return true;
3740}
3741
3742template <typename Derived>
3744 return true;
3745}
3746
3747template <typename Derived>
3749 return true;
3750}
3751
3752template <typename Derived>
3754 return true;
3755}
3756
3757template <typename Derived>
3759 return true;
3760}
3761
3762template <typename Derived>
3764 return true;
3765}
3766
3767template <typename Derived>
3769 return true;
3770}
3771
3772template <typename Derived>
3774 return true;
3775}
3776
3777template <typename Derived>
3779 return true;
3780}
3781
3782template <typename Derived>
3784 OMPNoOpenMPRoutinesClause *) {
3785 return true;
3786}
3787
3788template <typename Derived>
3790 OMPNoOpenMPConstructsClause *) {
3791 return true;
3792}
3793
3794template <typename Derived>
3796 OMPNoParallelismClause *) {
3797 return true;
3798}
3799
3800template <typename Derived>
3802 return true;
3803}
3804
3805template <typename Derived>
3807 return true;
3808}
3809
3810template <typename Derived>
3812 return true;
3813}
3814
3815template <typename Derived>
3817 return true;
3818}
3819
3820template <typename Derived>
3822 return true;
3823}
3824
3825template <typename Derived>
3827 return true;
3828}
3829
3830template <typename Derived>
3832 return true;
3833}
3834
3835template <typename Derived>
3837 TRY_TO(VisitOMPClauseList(C));
3838 // VisitOMPClauseList covers the interop var and the per-pref-spec fr exprs
3839 // (the varlist); the prefer_type attr() exprs live outside it.
3840 for (Expr *A : C->attrs())
3841 TRY_TO(TraverseStmt(A));
3842 return true;
3843}
3844
3845template <typename Derived>
3847 TRY_TO(TraverseStmt(C->getInteropVar()));
3848 return true;
3849}
3850
3851template <typename Derived>
3853 TRY_TO(TraverseStmt(C->getInteropVar()));
3854 return true;
3855}
3856
3857template <typename Derived>
3859 OMPNovariantsClause *C) {
3860 TRY_TO(VisitOMPClauseWithPreInit(C));
3861 TRY_TO(TraverseStmt(C->getCondition()));
3862 return true;
3863}
3864
3865template <typename Derived>
3867 OMPNocontextClause *C) {
3868 TRY_TO(VisitOMPClauseWithPreInit(C));
3869 TRY_TO(TraverseStmt(C->getCondition()));
3870 return true;
3871}
3872
3873template <typename Derived>
3874template <typename T>
3875bool RecursiveASTVisitor<Derived>::VisitOMPClauseList(T *Node) {
3876 for (auto *E : Node->varlist()) {
3877 TRY_TO(TraverseStmt(E));
3878 }
3879 return true;
3880}
3881
3882template <typename Derived>
3884 OMPInclusiveClause *C) {
3885 TRY_TO(VisitOMPClauseList(C));
3886 return true;
3887}
3888
3889template <typename Derived>
3891 OMPExclusiveClause *C) {
3892 TRY_TO(VisitOMPClauseList(C));
3893 return true;
3894}
3895
3896template <typename Derived>
3898 TRY_TO(VisitOMPClauseList(C));
3899 for (auto *E : C->private_copies()) {
3900 TRY_TO(TraverseStmt(E));
3901 }
3902 return true;
3903}
3904
3905template <typename Derived>
3907 OMPFirstprivateClause *C) {
3908 TRY_TO(VisitOMPClauseList(C));
3909 TRY_TO(VisitOMPClauseWithPreInit(C));
3910 for (auto *E : C->private_copies()) {
3911 TRY_TO(TraverseStmt(E));
3912 }
3913 for (auto *E : C->inits()) {
3914 TRY_TO(TraverseStmt(E));
3915 }
3916 return true;
3917}
3918
3919template <typename Derived>
3921 OMPLastprivateClause *C) {
3922 TRY_TO(VisitOMPClauseList(C));
3923 TRY_TO(VisitOMPClauseWithPostUpdate(C));
3924 for (auto *E : C->private_copies()) {
3925 TRY_TO(TraverseStmt(E));
3926 }
3927 for (auto *E : C->source_exprs()) {
3928 TRY_TO(TraverseStmt(E));
3929 }
3930 for (auto *E : C->destination_exprs()) {
3931 TRY_TO(TraverseStmt(E));
3932 }
3933 for (auto *E : C->assignment_ops()) {
3934 TRY_TO(TraverseStmt(E));
3935 }
3936 return true;
3937}
3938
3939template <typename Derived>
3941 TRY_TO(VisitOMPClauseList(C));
3942 return true;
3943}
3944
3945template <typename Derived>
3947 TRY_TO(TraverseStmt(C->getStep()));
3948 TRY_TO(TraverseStmt(C->getCalcStep()));
3949 TRY_TO(VisitOMPClauseList(C));
3950 TRY_TO(VisitOMPClauseWithPostUpdate(C));
3951 for (auto *E : C->privates()) {
3952 TRY_TO(TraverseStmt(E));
3953 }
3954 for (auto *E : C->inits()) {
3955 TRY_TO(TraverseStmt(E));
3956 }
3957 for (auto *E : C->updates()) {
3958 TRY_TO(TraverseStmt(E));
3959 }
3960 for (auto *E : C->finals()) {
3961 TRY_TO(TraverseStmt(E));
3962 }
3963 return true;
3964}
3965
3966template <typename Derived>
3968 TRY_TO(TraverseStmt(C->getAlignment()));
3969 TRY_TO(VisitOMPClauseList(C));
3970 return true;
3971}
3972
3973template <typename Derived>
3975 TRY_TO(VisitOMPClauseList(C));
3976 for (auto *E : C->source_exprs()) {
3977 TRY_TO(TraverseStmt(E));
3978 }
3979 for (auto *E : C->destination_exprs()) {
3980 TRY_TO(TraverseStmt(E));
3981 }
3982 for (auto *E : C->assignment_ops()) {
3983 TRY_TO(TraverseStmt(E));
3984 }
3985 return true;
3986}
3987
3988template <typename Derived>
3990 OMPCopyprivateClause *C) {
3991 TRY_TO(VisitOMPClauseList(C));
3992 for (auto *E : C->source_exprs()) {
3993 TRY_TO(TraverseStmt(E));
3994 }
3995 for (auto *E : C->destination_exprs()) {
3996 TRY_TO(TraverseStmt(E));
3997 }
3998 for (auto *E : C->assignment_ops()) {
3999 TRY_TO(TraverseStmt(E));
4000 }
4001 return true;
4002}
4003
4004template <typename Derived>
4005bool
4007 TRY_TO(TraverseNestedNameSpecifierLoc(C->getQualifierLoc()));
4008 TRY_TO(TraverseDeclarationNameInfo(C->getNameInfo()));
4009 TRY_TO(VisitOMPClauseList(C));
4010 TRY_TO(VisitOMPClauseWithPostUpdate(C));
4011 for (auto *E : C->privates()) {
4012 TRY_TO(TraverseStmt(E));
4013 }
4014 for (auto *E : C->lhs_exprs()) {
4015 TRY_TO(TraverseStmt(E));
4016 }
4017 for (auto *E : C->rhs_exprs()) {
4018 TRY_TO(TraverseStmt(E));
4019 }
4020 for (auto *E : C->reduction_ops()) {
4021 TRY_TO(TraverseStmt(E));
4022 }
4023 if (C->getModifier() == OMPC_REDUCTION_inscan) {
4024 for (auto *E : C->copy_ops()) {
4025 TRY_TO(TraverseStmt(E));
4026 }
4027 for (auto *E : C->copy_array_temps()) {
4028 TRY_TO(TraverseStmt(E));
4029 }
4030 for (auto *E : C->copy_array_elems()) {
4031 TRY_TO(TraverseStmt(E));
4032 }
4033 }
4034 return true;
4035}
4036
4037template <typename Derived>
4039 OMPTaskReductionClause *C) {
4040 TRY_TO(TraverseNestedNameSpecifierLoc(C->getQualifierLoc()));
4041 TRY_TO(TraverseDeclarationNameInfo(C->getNameInfo()));
4042 TRY_TO(VisitOMPClauseList(C));
4043 TRY_TO(VisitOMPClauseWithPostUpdate(C));
4044 for (auto *E : C->privates()) {
4045 TRY_TO(TraverseStmt(E));
4046 }
4047 for (auto *E : C->lhs_exprs()) {
4048 TRY_TO(TraverseStmt(E));
4049 }
4050 for (auto *E : C->rhs_exprs()) {
4051 TRY_TO(TraverseStmt(E));
4052 }
4053 for (auto *E : C->reduction_ops()) {
4054 TRY_TO(TraverseStmt(E));
4055 }
4056 return true;
4057}
4058
4059template <typename Derived>
4061 OMPInReductionClause *C) {
4062 TRY_TO(TraverseNestedNameSpecifierLoc(C->getQualifierLoc()));
4063 TRY_TO(TraverseDeclarationNameInfo(C->getNameInfo()));
4064 TRY_TO(VisitOMPClauseList(C));
4065 TRY_TO(VisitOMPClauseWithPostUpdate(C));
4066 for (auto *E : C->privates()) {
4067 TRY_TO(TraverseStmt(E));
4068 }
4069 for (auto *E : C->lhs_exprs()) {
4070 TRY_TO(TraverseStmt(E));
4071 }
4072 for (auto *E : C->rhs_exprs()) {
4073 TRY_TO(TraverseStmt(E));
4074 }
4075 for (auto *E : C->reduction_ops()) {
4076 TRY_TO(TraverseStmt(E));
4077 }
4078 for (auto *E : C->taskgroup_descriptors())
4079 TRY_TO(TraverseStmt(E));
4080 return true;
4081}
4082
4083template <typename Derived>
4085 TRY_TO(VisitOMPClauseList(C));
4086 return true;
4087}
4088
4089template <typename Derived>
4091 TRY_TO(TraverseStmt(C->getDepobj()));
4092 return true;
4093}
4094
4095template <typename Derived>
4097 TRY_TO(VisitOMPClauseList(C));
4098 return true;
4099}
4100
4101template <typename Derived>
4103 TRY_TO(VisitOMPClauseWithPreInit(C));
4104 TRY_TO(TraverseStmt(C->getDevice()));
4105 return true;
4106}
4107
4108template <typename Derived>
4110 TRY_TO(VisitOMPClauseList(C));
4111 return true;
4112}
4113
4114template <typename Derived>
4116 OMPNumTeamsClause *C) {
4117 if (auto *E = C->getModifierExpr())
4118 TRY_TO(VisitStmt(E));
4119 TRY_TO(VisitOMPClauseList(C));
4120 TRY_TO(VisitOMPClauseWithPreInit(C));
4121 return true;
4122}
4123
4124template <typename Derived>
4126 OMPThreadLimitClause *C) {
4127 if (auto *E = C->getModifierExpr())
4128 TRY_TO(VisitStmt(E));
4129 TRY_TO(VisitOMPClauseList(C));
4130 TRY_TO(VisitOMPClauseWithPreInit(C));
4131 return true;
4132}
4133
4134template <typename Derived>
4136 OMPPriorityClause *C) {
4137 TRY_TO(VisitOMPClauseWithPreInit(C));
4138 TRY_TO(TraverseStmt(C->getPriority()));
4139 return true;
4140}
4141
4142template <typename Derived>
4144 OMPGrainsizeClause *C) {
4145 TRY_TO(VisitOMPClauseWithPreInit(C));
4146 TRY_TO(TraverseStmt(C->getGrainsize()));
4147 return true;
4148}
4149
4150template <typename Derived>
4152 OMPNumTasksClause *C) {
4153 TRY_TO(VisitOMPClauseWithPreInit(C));
4154 TRY_TO(TraverseStmt(C->getNumTasks()));
4155 return true;
4156}
4157
4158template <typename Derived>
4160 TRY_TO(TraverseStmt(C->getHint()));
4161 return true;
4162}
4163
4164template <typename Derived>
4166 OMPDistScheduleClause *C) {
4167 TRY_TO(VisitOMPClauseWithPreInit(C));
4168 TRY_TO(TraverseStmt(C->getChunkSize()));
4169 return true;
4170}
4171
4172template <typename Derived>
4173bool
4175 return true;
4176}
4177
4178template <typename Derived>
4180 TRY_TO(VisitOMPClauseList(C));
4181 return true;
4182}
4183
4184template <typename Derived>
4186 TRY_TO(VisitOMPClauseList(C));
4187 return true;
4188}
4189
4190template <typename Derived>
4192 OMPUseDevicePtrClause *C) {
4193 TRY_TO(VisitOMPClauseList(C));
4194 return true;
4195}
4196
4197template <typename Derived>
4199 OMPUseDeviceAddrClause *C) {
4200 TRY_TO(VisitOMPClauseList(C));
4201 return true;
4202}
4203
4204template <typename Derived>
4206 OMPIsDevicePtrClause *C) {
4207 TRY_TO(VisitOMPClauseList(C));
4208 return true;
4209}
4210
4211template <typename Derived>
4213 OMPHasDeviceAddrClause *C) {
4214 TRY_TO(VisitOMPClauseList(C));
4215 return true;
4216}
4217
4218template <typename Derived>
4220 OMPNontemporalClause *C) {
4221 TRY_TO(VisitOMPClauseList(C));
4222 for (auto *E : C->private_refs()) {
4223 TRY_TO(TraverseStmt(E));
4224 }
4225 return true;
4226}
4227
4228template <typename Derived>
4230 return true;
4231}
4232
4233template <typename Derived>
4235 TRY_TO(TraverseStmt(C->getEventHandler()));
4236 return true;
4237}
4238
4239template <typename Derived>
4241 OMPUsesAllocatorsClause *C) {
4242 for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) {
4243 const OMPUsesAllocatorsClause::Data Data = C->getAllocatorData(I);
4244 TRY_TO(TraverseStmt(Data.Allocator));
4245 TRY_TO(TraverseStmt(Data.AllocatorTraits));
4246 }
4247 return true;
4248}
4249
4250template <typename Derived>
4252 OMPAffinityClause *C) {
4253 TRY_TO(TraverseStmt(C->getModifier()));
4254 for (Expr *E : C->varlist())
4255 TRY_TO(TraverseStmt(E));
4256 return true;
4257}
4258
4259template <typename Derived>
4261 TRY_TO(VisitOMPClauseWithPreInit(C));
4262 TRY_TO(TraverseStmt(C->getThreadID()));
4263 return true;
4264}
4265
4266template <typename Derived>
4268 return true;
4269}
4270
4271template <typename Derived>
4273 OMPXDynCGroupMemClause *C) {
4274 TRY_TO(VisitOMPClauseWithPreInit(C));
4275 TRY_TO(TraverseStmt(C->getSize()));
4276 return true;
4277}
4278
4279template <typename Derived>
4281 OMPDynGroupprivateClause *C) {
4282 TRY_TO(VisitOMPClauseWithPreInit(C));
4283 TRY_TO(TraverseStmt(C->getSize()));
4284 return true;
4285}
4286
4287template <typename Derived>
4289 OMPDoacrossClause *C) {
4290 TRY_TO(VisitOMPClauseList(C));
4291 return true;
4292}
4293
4294template <typename Derived>
4296 OMPXAttributeClause *C) {
4297 return true;
4298}
4299
4300template <typename Derived>
4302 return true;
4303}
4304
4305template <typename Derived>
4306bool RecursiveASTVisitor<Derived>::TraverseOpenACCConstructStmt(
4308 TRY_TO(VisitOpenACCClauseList(C->clauses()));
4309 return true;
4310}
4311
4312template <typename Derived>
4313bool RecursiveASTVisitor<Derived>::TraverseOpenACCAssociatedStmtConstruct(
4315 TRY_TO(TraverseOpenACCConstructStmt(S));
4316 TRY_TO(TraverseStmt(S->getAssociatedStmt()));
4317 return true;
4318}
4319
4320template <typename Derived>
4321bool RecursiveASTVisitor<Derived>::VisitOpenACCClause(const OpenACCClause *C) {
4322 for (const Stmt *Child : C->children())
4323 TRY_TO(TraverseStmt(const_cast<Stmt *>(Child)));
4324 return true;
4325}
4326
4327template <typename Derived>
4328bool RecursiveASTVisitor<Derived>::VisitOpenACCClauseList(
4330
4331 for (const auto *C : Clauses)
4332 TRY_TO(VisitOpenACCClause(C));
4333 return true;
4334}
4335
4337 { TRY_TO(TraverseOpenACCAssociatedStmtConstruct(S)); })
4338DEF_TRAVERSE_STMT(OpenACCLoopConstruct,
4339 { TRY_TO(TraverseOpenACCAssociatedStmtConstruct(S)); })
4340DEF_TRAVERSE_STMT(OpenACCCombinedConstruct,
4341 { TRY_TO(TraverseOpenACCAssociatedStmtConstruct(S)); })
4342DEF_TRAVERSE_STMT(OpenACCDataConstruct,
4343 { TRY_TO(TraverseOpenACCAssociatedStmtConstruct(S)); })
4344DEF_TRAVERSE_STMT(OpenACCEnterDataConstruct,
4345 { TRY_TO(VisitOpenACCClauseList(S->clauses())); })
4346DEF_TRAVERSE_STMT(OpenACCExitDataConstruct,
4347 { TRY_TO(VisitOpenACCClauseList(S->clauses())); })
4348DEF_TRAVERSE_STMT(OpenACCHostDataConstruct,
4349 { TRY_TO(TraverseOpenACCAssociatedStmtConstruct(S)); })
4350DEF_TRAVERSE_STMT(OpenACCWaitConstruct, {
4351 if (S->hasDevNumExpr())
4352 TRY_TO(TraverseStmt(S->getDevNumExpr()));
4353 for (auto *E : S->getQueueIdExprs())
4354 TRY_TO(TraverseStmt(E));
4355 TRY_TO(VisitOpenACCClauseList(S->clauses()));
4356})
4357DEF_TRAVERSE_STMT(OpenACCInitConstruct,
4358 { TRY_TO(VisitOpenACCClauseList(S->clauses())); })
4359DEF_TRAVERSE_STMT(OpenACCShutdownConstruct,
4360 { TRY_TO(VisitOpenACCClauseList(S->clauses())); })
4361DEF_TRAVERSE_STMT(OpenACCSetConstruct,
4362 { TRY_TO(VisitOpenACCClauseList(S->clauses())); })
4363DEF_TRAVERSE_STMT(OpenACCUpdateConstruct,
4364 { TRY_TO(VisitOpenACCClauseList(S->clauses())); })
4365DEF_TRAVERSE_STMT(OpenACCAtomicConstruct,
4366 { TRY_TO(TraverseOpenACCAssociatedStmtConstruct(S)); })
4367DEF_TRAVERSE_STMT(OpenACCCacheConstruct, {
4368 for (auto *E : S->getVarList())
4369 TRY_TO(TraverseStmt(E));
4370})
4371
4372// Traverse HLSL: Out argument expression
4374
4375// FIXME: look at the following tricky-seeming exprs to see if we
4376// need to recurse on anything. These are ones that have methods
4377// returning decls or qualtypes or nestednamespecifier -- though I'm
4378// not sure if they own them -- or just seemed very complicated, or
4379// had lots of sub-types to explore.
4380//
4381// VisitOverloadExpr and its children: recurse on template args? etc?
4382
4383// FIXME: go through all the stmts and exprs again, and see which of them
4384// create new types, and recurse on the types (TypeLocs?) of those.
4385// Candidates:
4386//
4387// http://clang.llvm.org/doxygen/classclang_1_1CXXTypeidExpr.html
4388// http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html
4389// http://clang.llvm.org/doxygen/classclang_1_1TypesCompatibleExpr.html
4390// Every class that has getQualifier.
4391
4392#undef DEF_TRAVERSE_STMT
4393#undef TRAVERSE_STMT
4394#undef TRAVERSE_STMT_BASE
4395
4396#undef TRY_TO
4397
4398} // end namespace clang
4399
4400#endif // LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
This file provides AST data structures related to concepts.
#define STMT(DERIVED, BASE)
Definition ASTFwd.h:23
#define TYPE(DERIVED, BASE)
Definition ASTFwd.h:26
bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc QualifierLoc)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines OpenACC nodes for declarative directives.
This file defines OpenMP nodes for declarative directives.
Defines the C++ template declaration subclasses.
#define DEF_TRAVERSE_TMPL_INST(kind)
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the LambdaCapture class.
This file defines OpenMP AST classes for clauses.
Defines some OpenMP-specific enums and functions.
#define DEF_TRAVERSE_TMPL_PART_SPEC_DECL(TMPLDECLKIND, DECLKIND)
#define TRAVERSE_STMT_BASE(NAME, CLASS, VAR, QUEUE)
#define DEF_TRAVERSE_TYPE(TYPE, CODE)
#define DEF_TRAVERSE_TYPELOC(TYPE, CODE)
#define TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S)
#define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND, DECLKIND)
#define DEF_TRAVERSE_DECL(DECL, CODE)
#define DEF_TRAVERSE_STMT(STMT, CODE)
#define DEF_TRAVERSE_TMPL_DECL(TMPLDECLKIND)
#define TRY_TO(CALL_EXPR)
Defines various enumerations that describe declaration and type specifiers.
Defines the Objective-C statement AST node classes.
This file defines OpenACC AST classes for statement-level contructs.
This file defines OpenMP AST classes for executable directives and clauses.
This file defines SYCL AST classes used to represent calls to SYCL kernels.
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
This is a common base class for loop directives ('omp simd', 'omp for', 'omp for simd' etc....
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:245
TranslationUnitDecl * getTranslationUnitDecl() const
Represents an access specifier followed by colon ':'.
Definition DeclCXX.h:86
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition Expr.h:4619
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
Definition TypeBase.h:3605
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition Expr.h:6107
Represents a loop initializing the elements of an array.
Definition Expr.h:6054
This class represents BOTH the OpenMP Array Section and OpenACC 'subarray', with a boolean differenti...
Definition Expr.h:7305
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition Expr.h:2790
Wrapper for source info for arrays.
Definition TypeLoc.h:1808
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
Definition ExprCXX.h:3011
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition Expr.h:6819
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Definition Expr.h:7014
Attr - This represents one attribute.
Definition Attr.h:47
Represents an attribute applied to a statement.
Definition Stmt.h:2214
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition Expr.h:4522
A builtin binary operation expression such as "x + y" or "x <= y".
Definition Expr.h:4107
A binding in a decomposition declaration.
Definition DeclCXX.h:4232
A fixed int type of a specified bitwidth.
Definition TypeBase.h:8436
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4856
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition Expr.h:6758
Pointer to a block type.
Definition TypeBase.h:3653
BreakStmt - This represents a break.
Definition Stmt.h:3148
Represents a C++2a __builtin_bit_cast(T, v) expression.
Definition ExprCXX.h:5530
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
This class is used for builtin types like 'int'.
Definition TypeBase.h:3245
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr....
Definition Expr.h:4038
Represents a call to a CUDA kernel function.
Definition ExprCXX.h:239
A C++ addrspace_cast expression (currently only enabled for OpenCL).
Definition ExprCXX.h:609
Represents a base class of a C++ class.
Definition DeclCXX.h:146
Represents binding an expression to a temporary.
Definition ExprCXX.h:1498
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition ExprCXX.h:728
CXXCatchStmt - This represents a C++ catch block.
Definition StmtCXX.h:29
A C++ const_cast expression (C++ [expr.const.cast]).
Definition ExprCXX.h:571
Represents a call to a C++ constructor.
Definition ExprCXX.h:1553
Represents a C++ constructor within a class.
Definition DeclCXX.h:2645
Represents a C++ conversion function within a class.
Definition DeclCXX.h:2994
Represents a C++ base or member initializer.
Definition DeclCXX.h:2410
Represents a C++ deduction guide declaration.
Definition DeclCXX.h:2001
A default argument (C++ [dcl.fct.default]).
Definition ExprCXX.h:1275
A use of a default initializer in a constructor or in aggregate initialization.
Definition ExprCXX.h:1382
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition ExprCXX.h:2631
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition ExprCXX.h:3924
Represents a C++ destructor within a class.
Definition DeclCXX.h:2924
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition ExprCXX.h:486
Helper that selects an expression from an InitListExpr depending on the current expansion index.
Definition ExprCXX.h:5622
Represents a C++26 expansion statement declaration.
Represents the code generated for an expanded expansion statement.
Definition StmtCXX.h:1028
CXXExpansionStmtPattern - Represents an unexpanded C++ expansion statement.
Definition StmtCXX.h:675
Represents a folding of a pack over an operator.
Definition ExprCXX.h:5086
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
Definition StmtCXX.h:136
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr....
Definition ExprCXX.h:1836
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition ExprCXX.h:1756
Represents a call to a member function that may be written either with member call syntax (e....
Definition ExprCXX.h:184
Represents a static or instance method of a struct/union/class.
Definition DeclCXX.h:2153
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition ExprCXX.h:2360
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition ExprCXX.h:4363
The null pointer literal (C++11 [lex.nullptr])
Definition ExprCXX.h:773
A call to an overloaded operator written using operator syntax.
Definition ExprCXX.h:86
Represents a list-initialization with parenthesis.
Definition ExprCXX.h:5195
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition ExprCXX.h:2750
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
Represents a C++26 reflect expression [expr.reflect].
Definition ExprCXX.h:5562
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition ExprCXX.h:531
A rewritten comparison expression that was originally written using operator syntax.
Definition ExprCXX.h:291
An expression "T()" which creates an rvalue of a non-class type T.
Definition ExprCXX.h:2201
A C++ static_cast expression (C++ [expr.static.cast]).
Definition ExprCXX.h:441
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition ExprCXX.h:805
Represents a C++ functional cast expression that builds a temporary object.
Definition ExprCXX.h:1904
Represents the this expression in C++.
Definition ExprCXX.h:1159
A C++ throw-expression (C++ [except.throw]).
Definition ExprCXX.h:1213
CXXTryStmt - A C++ try block, including all handlers.
Definition StmtCXX.h:70
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition ExprCXX.h:853
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition ExprCXX.h:3798
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition ExprCXX.h:1073
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:3012
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition Decl.h:5131
This captures a statement into a function.
Definition Stmt.h:3950
CaseStmt - Represent a case statement.
Definition Stmt.h:1931
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition Expr.h:4917
Declaration of a class template.
Represents a 'co_await' expression.
Definition ExprCXX.h:5423
Complex values, per C99 6.2.5p11.
Definition TypeBase.h:3362
CompoundAssignOperator - For compound assignments (e.g.
Definition Expr.h:4369
CompoundLiteralExpr - [C99 6.5.2.5].
Definition Expr.h:3674
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition Stmt.h:1751
Declaration of a C++20 concept.
A reference to a concept and its template args, as it appears in the code.
Definition ASTConcept.h:127
Represents the specialization of a concept - evaluates to a prvalue of type bool.
ConditionalOperator - The ?
Definition Expr.h:4460
Represents the canonical version of C arrays with a specified constant size.
Definition TypeBase.h:3858
An expression that occurs in a constant context and the result of evaluating the expression.
Definition Expr.h:1127
Represents a concrete matrix type with constant number of rows and columns.
Definition TypeBase.h:4622
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition DeclCXX.h:3724
ContinueStmt - This represents a continue.
Definition Stmt.h:3132
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition Expr.h:4788
Represents a 'co_return' statement in the C++ Coroutines TS.
Definition StmtCXX.h:474
Represents the body of a coroutine.
Definition StmtCXX.h:321
Represents a 'co_yield' expression.
Definition ExprCXX.h:5504
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1467
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition DeclBase.h:2110
A reference to a declared variable, function, enum, etc.
Definition Expr.h:1315
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition Stmt.h:1642
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition DeclBase.h:602
Kind getKind() const
Definition DeclBase.h:451
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
NameKind getNameKind() const
Determine what kind of name this is.
Represents a ValueDecl that came out of a declarator.
Definition Decl.h:782
A decomposition declaration.
Definition DeclCXX.h:4296
DeferStmt - This represents a deferred statement.
Definition Stmt.h:3249
Represents a 'co_await' expression while the type of the promise is dependent.
Definition ExprCXX.h:5455
Provides information about a dependent function-template specialization declaration.
A qualified reference to a name whose declaration cannot yet be resolved.
Definition ExprCXX.h:3564
Represents an array type in C++ whose size is a value-dependent expression.
Definition TypeBase.h:4109
Represents an extended vector type where either the type or size is dependent.
Definition TypeBase.h:4199
A template-id naming a variable template or a concept through a template template parameter.
Definition ExprCXX.h:3480
Represents a vector type where either the type or size is dependent.
Definition TypeBase.h:4457
Represents a C99 designated initializer expression.
Definition Expr.h:5637
DoStmt - This represents a 'do/while' stmt.
Definition Stmt.h:2843
Represents a reference to emded data.
Definition Expr.h:5204
Represents an empty-declaration.
Definition Decl.h:5366
An instance of this object exists for each enum constant that is defined.
Definition Decl.h:3604
Represents an enum.
Definition Decl.h:4192
Represents an explicit instantiation of a template entity in source code.
Represents a standard C++ module export declaration.
Definition Decl.h:5319
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition ExprCXX.h:3715
This represents one expression.
Definition Expr.h:114
An expression trait intrinsic.
Definition ExprCXX.h:3084
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition Expr.h:6696
Declaration context for names declared as extern "C" in C++.
Definition Decl.h:249
Represents a member of a struct/union/class.
Definition Decl.h:3341
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Definition Stmt.h:2899
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
Definition DeclFriend.h:46
Declaration of a friend template.
Represents a function declaration or definition.
Definition Decl.h:2082
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition TypeBase.h:5126
Represents a reference to a function parameter pack, init-capture pack, or binding pack that has been...
Definition ExprCXX.h:4895
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5548
Declaration of a template function.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
This represents a GCC inline-assembly statement extension.
Definition Stmt.h:3459
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Definition Expr.h:4992
Represents a C11 generic selection.
Definition Expr.h:6268
AssociationTy< false > Association
Definition Expr.h:6501
GotoStmt - This represents a direct goto.
Definition Stmt.h:2980
HLSLBufferDecl - Represent a cbuffer or tbuffer declaration.
Definition Decl.h:5381
This class represents temporary values used to represent inout and out arguments in HLSL.
Definition Expr.h:7483
IfStmt - This represents an if/then/else.
Definition Stmt.h:2270
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
Definition Expr.h:1776
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition Expr.h:3922
Represents an implicitly-generated value initialization of an object of a given type.
Definition Expr.h:6143
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition Decl.h:5240
Represents a C array with an unspecified size.
Definition TypeBase.h:4007
Represents a field injected from an anonymous union/struct into the parent scope.
Definition Decl.h:3648
IndirectGotoStmt - This represents an indirect goto.
Definition Stmt.h:3019
Describes an C or C++ initializer list.
Definition Expr.h:5377
Represents the declaration of a label.
Definition Decl.h:526
LabelStmt - Represents a label, which has a substatement.
Definition Stmt.h:2157
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...
Definition ExprCXX.h:1973
Represents a placeholder type for late-parsed type attributes.
Definition TypeBase.h:3577
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
Definition DeclCXX.h:3355
Represents a linkage specification.
Definition DeclCXX.h:3062
This represents a Microsoft inline-assembly statement extension.
Definition Stmt.h:3678
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name.
Definition StmtCXX.h:254
A global _GUID constant.
Definition DeclCXX.h:4468
An instance of this class represents the declaration of a property member.
Definition DeclCXX.h:4414
A member reference to an MSPropertyDecl.
Definition ExprCXX.h:941
MS property subscript expression.
Definition ExprCXX.h:1011
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation.
Definition TypeBase.h:6426
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition ExprCXX.h:4974
MatrixSingleSubscriptExpr - Matrix single subscript expression for the MatrixType extension when you ...
Definition Expr.h:2864
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
Definition Expr.h:2934
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3433
This represents a decl that may have a name.
Definition Decl.h:276
Represents a C++ namespace alias.
Definition DeclCXX.h:3248
Represent a C++ namespace.
Definition Decl.h:594
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
NamespaceAndPrefixLoc castAsNamespaceAndPrefix() const
For a nested-name-specifier that refers to a namespace, retrieve the namespace and its prefix.
TypeLoc castAsTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NamespaceAndPrefix getAsNamespaceAndPrefix() const
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
Represents a place-holder for an object not to be initialized by anything.
Definition Expr.h:5963
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition Stmt.h:1714
This represents the 'align' clause in the 'pragma omp allocate' directive.
This represents clause 'allocate' in the 'pragma omp ...' directives.
This represents 'pragma omp allocate ...' directive.
Definition DeclOpenMP.h:536
This represents 'allocator' clause in the 'pragma omp ...' directive.
An explicit cast in C or a C-style cast in C++, which uses the syntax ([s1][s2]......
Definition ExprOpenMP.h:24
Pseudo declaration for capturing expressions.
Definition DeclOpenMP.h:445
Class that handles post-update expression for some clauses, like 'lastprivate', 'reduction' etc.
Class that handles pre-initialization statement for some clauses, like 'schedule',...
This is a basic class for representing single OpenMP clause.
This represents 'collapse' clause in the 'pragma omp ...' directive.
This represents the 'counts' clause in the 'pragma omp split' directive.
This represents 'pragma omp declare mapper ...' directive.
Definition DeclOpenMP.h:349
This represents 'pragma omp declare reduction ...' directive.
Definition DeclOpenMP.h:239
This represents 'default' clause in the 'pragma omp ...' directive.
This represents the 'depth' clause on the 'pragma omp flatten' (and 'pragma omp fuse') loop-transform...
This represents 'final' clause in the 'pragma omp ...' directive.
Representation of the 'full' clause of the 'pragma omp unroll' directive.
This represents 'pragma omp groupprivate ...' directive.
Definition DeclOpenMP.h:173
This represents 'if' clause in the 'pragma omp ...' directive.
OpenMP 5.0 [2.1.6 Iterators] Iterators are identifiers that expand to multiple values in the clause o...
Definition ExprOpenMP.h:151
This class represents the 'looprange' clause in the 'pragma omp fuse' directive.
This represents 'num_threads' clause in the 'pragma omp ...' directive.
Representation of the 'partial' clause of the 'pragma omp unroll' directive.
This class represents the 'permutation' clause in the 'pragma omp interchange' directive.
This represents 'pragma omp requires...' directive.
Definition DeclOpenMP.h:479
This represents 'safelen' clause in the 'pragma omp ...' directive.
This represents 'simdlen' clause in the 'pragma omp ...' directive.
This represents the 'sizes' clause in the 'pragma omp tile' directive.
This represents 'pragma omp threadprivate ...' directive.
Definition DeclOpenMP.h:110
This represents 'threadset' clause in the 'pragma omp task ...' directive.
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
Definition ExprObjC.h:219
Represents Objective-C's @catch statement.
Definition StmtObjC.h:77
Represents a field declaration created by an @defs(...).
Definition DeclObjC.h:2036
Represents Objective-C's @finally statement.
Definition StmtObjC.h:127
Represents Objective-C's @synchronized statement.
Definition StmtObjC.h:303
Represents Objective-C's @throw statement.
Definition StmtObjC.h:358
Represents Objective-C's @try ... @catch ... @finally statement.
Definition StmtObjC.h:167
Represents Objective-C's @autoreleasepool Statement.
Definition StmtObjC.h:394
A runtime availability query.
Definition ExprObjC.h:1735
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition ExprObjC.h:118
ObjCBoxedExpr - used for generalized expression boxing.
Definition ExprObjC.h:158
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers,...
Definition ExprObjC.h:1675
ObjCCategoryDecl - Represents a category declaration.
Definition DeclObjC.h:2335
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Definition DeclObjC.h:2551
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition DeclObjC.h:2781
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition ExprObjC.h:341
ObjCEncodeExpr, used for @encode in Objective-C.
Definition ExprObjC.h:440
Represents Objective-C's collection statement.
Definition StmtObjC.h:23
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition DeclObjC.h:2603
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition ExprObjC.h:1614
Represents an ObjC class declaration.
Definition DeclObjC.h:1160
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
Definition TypeBase.h:8163
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
Definition ExprObjC.h:1530
ObjCIvarDecl - Represents an ObjC instance variable.
Definition DeclObjC.h:1958
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition ExprObjC.h:581
An expression that sends a message to the given Objective-C object or class.
Definition ExprObjC.h:972
ObjCMethodDecl - Represents an instance or class method declaration.
Definition DeclObjC.h:140
Represents a pointer to an Objective C object.
Definition TypeBase.h:8219
Represents one property declaration in an Objective-C interface.
Definition DeclObjC.h:734
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition DeclObjC.h:2811
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition ExprObjC.h:649
Represents an Objective-C protocol declaration.
Definition DeclObjC.h:2090
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition ExprObjC.h:537
ObjCSelectorExpr used for @selector in Objective-C.
Definition ExprObjC.h:485
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition ExprObjC.h:83
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition ExprObjC.h:871
Represents the declaration of an Objective-C type parameter.
Definition DeclObjC.h:581
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition DeclObjC.h:665
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
Definition Expr.h:2596
Helper class for OffsetOfExpr.
Definition Expr.h:2490
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Definition Expr.h:1223
This is a base class for any OpenACC statement-level constructs that have an associated statement.
Definition StmtOpenACC.h:81
This expression type represents an asterisk in an OpenACC Size-Expr, used in the 'tile' and 'gang' cl...
Definition Expr.h:2159
This is the base type for all OpenACC Clauses.
This is the base class for an OpenACC statement-level construct, other construct types are expected t...
Definition StmtOpenACC.h:26
Represents a partial function definition.
Definition Decl.h:5066
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition ExprCXX.h:4417
A structure for storing a pack-index-template-name ([temp.names]).
ParenExpr - This represents a parenthesized expression, e.g.
Definition Expr.h:2251
Sugar for parentheses used when specifying types.
Definition TypeBase.h:3383
Represents a parameter to a function.
Definition Decl.h:1832
PipeType - OpenCL20.
Definition TypeBase.h:8407
Represents a #pragma comment line.
Definition Decl.h:169
Represents a #pragma detect_mismatch line.
Definition Decl.h:203
[C99 6.4.2.2] - A predefined identifier such as func.
Definition Expr.h:2074
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition Expr.h:6890
Expr *const * semantics_iterator
Definition Expr.h:6949
A (possibly-)qualified type.
Definition TypeBase.h:938
Represents a template name as written in source code.
Wrapper of type source information for a type with non-trivial direct qualifiers.
Definition TypeLoc.h:300
UnqualTypeLoc getUnqualifiedLoc() const
Definition TypeLoc.h:304
An rvalue reference type, per C++11 [dcl.ref].
Definition TypeBase.h:3733
Represents a struct/union/class.
Definition Decl.h:4506
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
Definition Expr.h:7589
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
bool TraverseStmt(Stmt *S, DataRecursionQueue *Queue=nullptr)
Recursively visit a statement or expression, by dispatching to Traverse*() based on the argument's dy...
bool TraverseTemplateArgument(const TemplateArgument &Arg)
Recursively visit a template argument and dispatch to the appropriate method for the argument type.
bool TraverseConceptRequirement(concepts::Requirement *R)
bool dataTraverseStmtPre(Stmt *S)
Invoked before visiting a statement or expression via data recursion.
bool TraverseObjCProtocolLoc(ObjCProtocolLoc ProtocolLoc)
Recursively visit an Objective-C protocol reference with location information.
bool TraverseOffsetOfNode(const OffsetOfNode *Node)
Recursively visit a single component of an __builtin_offsetof designator (a field,...
bool VisitUnqualTypeLoc(UnqualTypeLoc TL)
bool TraverseConceptExprRequirement(concepts::ExprRequirement *R)
bool TraverseNestedNameSpecifier(NestedNameSpecifier NNS)
Recursively visit a C++ nested-name-specifier.
bool TraverseAST(ASTContext &AST)
Recursively visits an entire AST, starting from the TranslationUnitDecl.
bool shouldVisitTemplateInstantiations() const
Return whether this visitor should recurse into template instantiations.
bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc)
Recursively visit a template argument location and dispatch to the appropriate method for the argumen...
bool canIgnoreChildDeclWhileTraversingDeclContext(const Decl *Child)
bool dataTraverseStmtPost(Stmt *S)
Invoked after visiting a statement or expression via data recursion.
bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Recursively visit a C++ nested-name-specifier with location information.
Stmt::child_range getStmtChildren(Stmt *S)
bool shouldVisitImplicitCode() const
Return whether this visitor should recurse into implicit code, e.g., implicit constructors and destru...
bool TraverseConceptReference(ConceptReference *CR)
Recursively visit concept reference with location information.
bool TraverseTemplateArguments(ArrayRef< TemplateArgument > Args)
Recursively visit a set of template arguments.
bool TraverseTypeLoc(TypeLoc TL, bool TraverseQualifier=true)
Recursively visit a type with location, by dispatching to Traverse*TypeLoc() based on the argument ty...
bool WalkUpFromUnqualTypeLoc(UnqualTypeLoc TL)
bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue)
bool TraverseDecl(Decl *D)
Recursively visit a declaration, by dispatching to Traverse*Decl() based on the argument's dynamic ty...
bool TraverseTypeConstraint(const TypeConstraint *C)
bool WalkUpFromQualifiedTypeLoc(QualifiedTypeLoc TL)
bool VisitOffsetOfNode(const OffsetOfNode *Node)
Visit a single component of an __builtin_offsetof designator.
bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C, Expr *Init)
Recursively visit a lambda capture.
bool VisitConceptReference(ConceptReference *CR)
bool shouldTraversePostOrder() const
Return whether this visitor should traverse post-order.
SmallVectorImpl< llvm::PointerIntPair< Stmt *, 1, bool > > DataRecursionQueue
A queue used for performing data recursion over statements.
bool shouldVisitLambdaBody() const
Return whether this visitor should recurse into lambda body.
bool TraverseSynOrSemInitListExpr(InitListExpr *S, DataRecursionQueue *Queue=nullptr)
Recursively visit the syntactic or semantic form of an initialization list.
bool TraverseAttr(Attr *At)
Recursively visit an attribute, by dispatching to Traverse*Attr() based on the argument's dynamic typ...
bool TraverseType(QualType T, bool TraverseQualifier=true)
Recursively visit a type, by dispatching to Traverse*Type() based on the argument's getTypeClass() pr...
bool TraverseConceptNestedRequirement(concepts::NestedRequirement *R)
bool VisitQualifiedTypeLoc(QualifiedTypeLoc TL)
bool shouldWalkTypesOfTypeLocs() const
Return whether this visitor should recurse into the types of TypeLocs.
bool TraverseDeclarationNameInfo(DeclarationNameInfo NameInfo)
Recursively visit a name with its location information.
bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier &Base)
Recursively visit a base specifier.
bool TraverseTemplateName(TemplateName Template, bool TraverseQualifier=true)
Recursively visit a template name and dispatch to the appropriate method.
Derived & getDerived()
Return a reference to the derived class.
bool TraverseConceptTypeRequirement(concepts::TypeRequirement *R)
bool TraverseConstructorInitializer(CXXCtorInitializer *Init)
Recursively visit a constructor initializer.
Represents the body of a requires-expression.
Definition DeclCXX.h:2122
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition Stmt.h:3173
Represents a __leave statement.
Definition Stmt.h:3911
SYCLKernelCallStmt represents the transformation that is applied to the body of a function declared w...
Definition StmtSYCL.h:36
Scope - A scope is a transient data structure that is used while parsing the program.
Definition Scope.h:41
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition Expr.h:4712
Represents an expression that computes the length of a parameter pack.
Definition ExprCXX.h:4495
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
Definition Expr.h:5095
Represents a C++11 static_assert declaration.
Definition DeclCXX.h:4183
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition Expr.h:4664
Stmt - This represents one statement.
Definition Stmt.h:85
@ NoStmtClass
Definition Stmt.h:88
child_range children()
Definition Stmt.cpp:304
StmtClass getStmtClass() const
Definition Stmt.h:1504
llvm::iterator_range< child_iterator > child_range
Definition Stmt.h:1593
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1844
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition ExprCXX.h:4718
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition ExprCXX.h:4808
Abstract type representing delayed type pack expansions.
Definition TypeLoc.h:986
SwitchStmt - This represents a 'switch' stmt.
Definition Stmt.h:2520
Location wrapper for a TemplateArgument.
const TemplateArgument & getArgument() const
TypeSourceInfo * getTypeSourceInfo() const
Expr * getSourceExpression() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Represents a template argument.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
QualType getAsType() const
Retrieve the type for a type template argument.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
Represents a C++ template name within the type system.
A template parameter object.
Stores a list of template parameters for a TemplateDecl and its derived classes.
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Declaration of a template type parameter.
A declaration that models statements at global scope.
Definition Decl.h:4816
The top declaration context.
Definition Decl.h:107
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition Decl.h:3869
Declaration of an alias template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Definition ASTConcept.h:224
Base wrapper for a particular "section" of type source info.
Definition TypeLoc.h:59
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
Definition TypeLoc.h:349
NestedNameSpecifierLoc getPrefix() const
If this type represents a qualified-id, this returns it's nested name specifier.
Definition TypeLoc.cpp:478
TypeLocClass getTypeLocClass() const
Definition TypeLoc.h:116
bool isNull() const
Definition TypeLoc.h:121
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition TypeLoc.h:2787
A container of type source information.
Definition TypeBase.h:8549
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition ExprCXX.h:2901
The base class of the type hierarchy.
Definition TypeBase.h:1879
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition Decl.h:3848
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
Definition Expr.h:2694
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2313
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Definition DeclCXX.h:4525
Wrapper of type source information for a type with no direct qualifiers.
Definition TypeLoc.h:274
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition ExprCXX.h:3373
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition ExprCXX.h:4180
This node is generated when a using-declaration that was annotated with attribute((using_if_exists)) ...
Definition DeclCXX.h:4165
Represents a dependent using declaration which was marked with typename.
Definition DeclCXX.h:4084
Represents a dependent using declaration which was not marked with typename.
Definition DeclCXX.h:3987
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit....
Definition ExprCXX.h:645
Represents a C++ using-declaration.
Definition DeclCXX.h:3638
Represents C++ using-directive.
Definition DeclCXX.h:3143
Represents a C++ using-enum-declaration.
Definition DeclCXX.h:3839
Represents a pack of using declarations that a single using-declarator pack-expanded into.
Definition DeclCXX.h:3920
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3446
Represents a call to the builtin function __builtin_va_arg.
Definition Expr.h:5026
Represents a variable declaration or definition.
Definition Decl.h:934
Declaration of a variable template.
Represents a GCC generic vector type.
Definition TypeBase.h:4398
WhileStmt - This represents a 'while' stmt.
Definition Stmt.h:2708
A requires-expression requirement which queries the validity and properties of an expression ('simple...
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
A static requirement that can be used in a requires-expression to check properties of types and expre...
A requires-expression requirement which queries the existence of a type name or type template special...
LLVM_ATTRIBUTE_ALWAYS_INLINE LLVM_ATTRIBUTE_NODEBUG auto isSameMethod(FirstMethodPtrTy FirstMethodPtr, SecondMethodPtrTy SecondMethodPtr) -> bool
Returns true if and only if FirstMethodPtr and SecondMethodPtr are pointers to the same non-static me...
Top level wrappers for InstallAPI frontend operations.
bool isa(CodeGen::Address addr)
Definition Address.h:330
TRY_TO(TraverseNestedNameSpecifier(Qualifier))
DEF_TRAVERSE_TYPELOC(ComplexType, { TRY_TO(TraverseType(TL.getTypePtr() ->getElementType()));}) DEF_TRAVERSE_TYPELOC(PointerType
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
Definition Parser.h:61
OpenACCComputeConstruct(OpenACCDirectiveKind K, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses, Stmt *StructuredBlock)
@ Parameter
The parameter type of a method or function.
Definition TypeBase.h:909
const FunctionProtoType * T
@ Template
We are parsing a template declaration.
Definition Parser.h:81
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
Definition DeclBase.h:1306
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
Definition Specifiers.h:210
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
Definition Specifiers.h:206
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
Definition Specifiers.h:202
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
Definition Specifiers.h:198
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
Definition Specifiers.h:195
U cast(CodeGen::Address addr)
Definition Address.h:327
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:6157
DEF_TRAVERSE_TYPE(ComplexType, { TRY_TO(TraverseType(T->getElementType()));}) DEF_TRAVERSE_TYPE(PointerType
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
DeclarationName getName() const
getName - Returns the embedded declaration name.
TypeSourceInfo * getNamedTypeInfo() const