clang  14.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 
16 #include "clang/AST/Attr.h"
17 #include "clang/AST/Decl.h"
19 #include "clang/AST/DeclBase.h"
20 #include "clang/AST/DeclCXX.h"
21 #include "clang/AST/DeclFriend.h"
22 #include "clang/AST/DeclObjC.h"
23 #include "clang/AST/DeclOpenMP.h"
24 #include "clang/AST/DeclTemplate.h"
25 #include "clang/AST/Expr.h"
26 #include "clang/AST/ExprConcepts.h"
27 #include "clang/AST/ExprCXX.h"
28 #include "clang/AST/ExprObjC.h"
29 #include "clang/AST/ExprOpenMP.h"
32 #include "clang/AST/OpenMPClause.h"
33 #include "clang/AST/Stmt.h"
34 #include "clang/AST/StmtCXX.h"
35 #include "clang/AST/StmtObjC.h"
36 #include "clang/AST/StmtOpenMP.h"
37 #include "clang/AST/TemplateBase.h"
38 #include "clang/AST/TemplateName.h"
39 #include "clang/AST/Type.h"
40 #include "clang/AST/TypeLoc.h"
41 #include "clang/Basic/LLVM.h"
43 #include "clang/Basic/Specifiers.h"
44 #include "llvm/ADT/PointerIntPair.h"
45 #include "llvm/ADT/SmallVector.h"
46 #include "llvm/Support/Casting.h"
47 #include <algorithm>
48 #include <cstddef>
49 #include <type_traits>
50 
51 namespace clang {
52 
53 // A helper macro to implement short-circuiting when recursing. It
54 // invokes CALL_EXPR, which must be a method call, on the derived
55 // object (s.t. a user of RecursiveASTVisitor can override the method
56 // in CALL_EXPR).
57 #define TRY_TO(CALL_EXPR) \
58  do { \
59  if (!getDerived().CALL_EXPR) \
60  return false; \
61  } while (false)
62 
63 namespace detail {
64 
65 template <typename T, typename U>
66 struct has_same_member_pointer_type : std::false_type {};
67 template <typename T, typename U, typename R, typename... P>
68 struct has_same_member_pointer_type<R (T::*)(P...), R (U::*)(P...)>
69  : std::true_type {};
70 
71 template <bool has_same_type> struct is_same_method_impl {
72  template <typename FirstMethodPtrTy, typename SecondMethodPtrTy>
73  static bool isSameMethod(FirstMethodPtrTy FirstMethodPtr,
74  SecondMethodPtrTy SecondMethodPtr) {
75  return false;
76  }
77 };
78 
79 template <> struct is_same_method_impl<true> {
80  template <typename FirstMethodPtrTy, typename SecondMethodPtrTy>
81  static bool isSameMethod(FirstMethodPtrTy FirstMethodPtr,
82  SecondMethodPtrTy SecondMethodPtr) {
83  return FirstMethodPtr == SecondMethodPtr;
84  }
85 };
86 
87 /// Returns true if and only if \p FirstMethodPtr and \p SecondMethodPtr
88 /// are pointers to the same non-static member function.
89 template <typename FirstMethodPtrTy, typename SecondMethodPtrTy>
90 bool isSameMethod(FirstMethodPtrTy FirstMethodPtr,
91  SecondMethodPtrTy SecondMethodPtr) {
93  FirstMethodPtrTy,
94  SecondMethodPtrTy>::value>::isSameMethod(FirstMethodPtr, SecondMethodPtr);
95 }
96 
97 } // end namespace detail
98 
99 /// A class that does preorder or postorder
100 /// depth-first traversal on the entire Clang AST and visits each node.
101 ///
102 /// This class performs three distinct tasks:
103 /// 1. traverse the AST (i.e. go to each node);
104 /// 2. at a given node, walk up the class hierarchy, starting from
105 /// the node's dynamic type, until the top-most class (e.g. Stmt,
106 /// Decl, or Type) is reached.
107 /// 3. given a (node, class) combination, where 'class' is some base
108 /// class of the dynamic type of 'node', call a user-overridable
109 /// function to actually visit the node.
110 ///
111 /// These tasks are done by three groups of methods, respectively:
112 /// 1. TraverseDecl(Decl *x) does task #1. It is the entry point
113 /// for traversing an AST rooted at x. This method simply
114 /// dispatches (i.e. forwards) to TraverseFoo(Foo *x) where Foo
115 /// is the dynamic type of *x, which calls WalkUpFromFoo(x) and
116 /// then recursively visits the child nodes of x.
117 /// TraverseStmt(Stmt *x) and TraverseType(QualType x) work
118 /// similarly.
119 /// 2. WalkUpFromFoo(Foo *x) does task #2. It does not try to visit
120 /// any child node of x. Instead, it first calls WalkUpFromBar(x)
121 /// where Bar is the direct parent class of Foo (unless Foo has
122 /// no parent), and then calls VisitFoo(x) (see the next list item).
123 /// 3. VisitFoo(Foo *x) does task #3.
124 ///
125 /// These three method groups are tiered (Traverse* > WalkUpFrom* >
126 /// Visit*). A method (e.g. Traverse*) may call methods from the same
127 /// tier (e.g. other Traverse*) or one tier lower (e.g. WalkUpFrom*).
128 /// It may not call methods from a higher tier.
129 ///
130 /// Note that since WalkUpFromFoo() calls WalkUpFromBar() (where Bar
131 /// is Foo's super class) before calling VisitFoo(), the result is
132 /// that the Visit*() methods for a given node are called in the
133 /// top-down order (e.g. for a node of type NamespaceDecl, the order will
134 /// be VisitDecl(), VisitNamedDecl(), and then VisitNamespaceDecl()).
135 ///
136 /// This scheme guarantees that all Visit*() calls for the same AST
137 /// node are grouped together. In other words, Visit*() methods for
138 /// different nodes are never interleaved.
139 ///
140 /// Clients of this visitor should subclass the visitor (providing
141 /// themselves as the template argument, using the curiously recurring
142 /// template pattern) and override any of the Traverse*, WalkUpFrom*,
143 /// and Visit* methods for declarations, types, statements,
144 /// expressions, or other AST nodes where the visitor should customize
145 /// behavior. Most users only need to override Visit*. Advanced
146 /// users may override Traverse* and WalkUpFrom* to implement custom
147 /// traversal strategies. Returning false from one of these overridden
148 /// functions will abort the entire traversal.
149 ///
150 /// By default, this visitor tries to visit every part of the explicit
151 /// source code exactly once. The default policy towards templates
152 /// is to descend into the 'pattern' class or function body, not any
153 /// explicit or implicit instantiations. Explicit specializations
154 /// are still visited, and the patterns of partial specializations
155 /// are visited separately. This behavior can be changed by
156 /// overriding shouldVisitTemplateInstantiations() in the derived class
157 /// to return true, in which case all known implicit and explicit
158 /// instantiations will be visited at the same time as the pattern
159 /// from which they were produced.
160 ///
161 /// By default, this visitor preorder traverses the AST. If postorder traversal
162 /// is needed, the \c shouldTraversePostOrder method needs to be overridden
163 /// to return \c true.
164 template <typename Derived> class RecursiveASTVisitor {
165 public:
166  /// A queue used for performing data recursion over statements.
167  /// Parameters involving this type are used to implement data
168  /// recursion over Stmts and Exprs within this class, and should
169  /// typically not be explicitly specified by derived classes.
170  /// The bool bit indicates whether the statement has been traversed or not.
173 
174  /// Return a reference to the derived class.
175  Derived &getDerived() { return *static_cast<Derived *>(this); }
176 
177  /// Return whether this visitor should recurse into
178  /// template instantiations.
179  bool shouldVisitTemplateInstantiations() const { return false; }
180 
181  /// Return whether this visitor should recurse into the types of
182  /// TypeLocs.
183  bool shouldWalkTypesOfTypeLocs() const { return true; }
184 
185  /// Return whether this visitor should recurse into implicit
186  /// code, e.g., implicit constructors and destructors.
187  bool shouldVisitImplicitCode() const { return false; }
188 
189  /// Return whether this visitor should recurse into lambda body
190  bool shouldVisitLambdaBody() const { return true; }
191 
192  /// Return whether this visitor should traverse post-order.
193  bool shouldTraversePostOrder() const { return false; }
194 
195  /// Recursively visits an entire AST, starting from the TranslationUnitDecl.
196  /// \returns false if visitation was terminated early.
197  bool TraverseAST(ASTContext &AST) {
198  // Currently just an alias for TraverseDecl(TUDecl), but kept in case
199  // we change the implementation again.
200  return getDerived().TraverseDecl(AST.getTranslationUnitDecl());
201  }
202 
203  /// Recursively visit a statement or expression, by
204  /// dispatching to Traverse*() based on the argument's dynamic type.
205  ///
206  /// \returns false if the visitation was terminated early, true
207  /// otherwise (including when the argument is nullptr).
208  bool TraverseStmt(Stmt *S, DataRecursionQueue *Queue = nullptr);
209 
210  /// Invoked before visiting a statement or expression via data recursion.
211  ///
212  /// \returns false to skip visiting the node, true otherwise.
213  bool dataTraverseStmtPre(Stmt *S) { return true; }
214 
215  /// Invoked after visiting a statement or expression via data recursion.
216  /// This is not invoked if the previously invoked \c dataTraverseStmtPre
217  /// returned false.
218  ///
219  /// \returns false if the visitation was terminated early, true otherwise.
220  bool dataTraverseStmtPost(Stmt *S) { return true; }
221 
222  /// Recursively visit a type, by dispatching to
223  /// Traverse*Type() based on the argument's getTypeClass() property.
224  ///
225  /// \returns false if the visitation was terminated early, true
226  /// otherwise (including when the argument is a Null type).
227  bool TraverseType(QualType T);
228 
229  /// Recursively visit a type with location, by dispatching to
230  /// Traverse*TypeLoc() based on the argument type's getTypeClass() property.
231  ///
232  /// \returns false if the visitation was terminated early, true
233  /// otherwise (including when the argument is a Null type location).
234  bool TraverseTypeLoc(TypeLoc TL);
235 
236  /// Recursively visit an attribute, by dispatching to
237  /// Traverse*Attr() based on the argument's dynamic type.
238  ///
239  /// \returns false if the visitation was terminated early, true
240  /// otherwise (including when the argument is a Null type location).
241  bool TraverseAttr(Attr *At);
242 
243  /// Recursively visit a declaration, by dispatching to
244  /// Traverse*Decl() based on the argument's dynamic type.
245  ///
246  /// \returns false if the visitation was terminated early, true
247  /// otherwise (including when the argument is NULL).
248  bool TraverseDecl(Decl *D);
249 
250  /// Recursively visit a C++ nested-name-specifier.
251  ///
252  /// \returns false if the visitation was terminated early, true otherwise.
254 
255  /// Recursively visit a C++ nested-name-specifier with location
256  /// information.
257  ///
258  /// \returns false if the visitation was terminated early, true otherwise.
260 
261  /// Recursively visit a name with its location information.
262  ///
263  /// \returns false if the visitation was terminated early, true otherwise.
265 
266  /// Recursively visit a template name and dispatch to the
267  /// appropriate method.
268  ///
269  /// \returns false if the visitation was terminated early, true otherwise.
270  bool TraverseTemplateName(TemplateName Template);
271 
272  /// Recursively visit a template argument and dispatch to the
273  /// appropriate method for the argument type.
274  ///
275  /// \returns false if the visitation was terminated early, true otherwise.
276  // FIXME: migrate callers to TemplateArgumentLoc instead.
278 
279  /// Recursively visit a template argument location and dispatch to the
280  /// appropriate method for the argument type.
281  ///
282  /// \returns false if the visitation was terminated early, true otherwise.
284 
285  /// Recursively visit a set of template arguments.
286  /// This can be overridden by a subclass, but it's not expected that
287  /// will be needed -- this visitor always dispatches to another.
288  ///
289  /// \returns false if the visitation was terminated early, true otherwise.
290  // FIXME: take a TemplateArgumentLoc* (or TemplateArgumentListInfo) instead.
292  unsigned NumArgs);
293 
294  /// Recursively visit a base specifier. This can be overridden by a
295  /// subclass.
296  ///
297  /// \returns false if the visitation was terminated early, true otherwise.
299 
300  /// Recursively visit a constructor initializer. This
301  /// automatically dispatches to another visitor for the initializer
302  /// expression, but not for the name of the initializer, so may
303  /// be overridden for clients that need access to the name.
304  ///
305  /// \returns false if the visitation was terminated early, true otherwise.
307 
308  /// Recursively visit a lambda capture. \c Init is the expression that
309  /// will be used to initialize the capture.
310  ///
311  /// \returns false if the visitation was terminated early, true otherwise.
313  Expr *Init);
314 
315  /// Recursively visit the syntactic or semantic form of an
316  /// initialization list.
317  ///
318  /// \returns false if the visitation was terminated early, true otherwise.
320  DataRecursionQueue *Queue = nullptr);
321 
322  /// Recursively visit a reference to a concept with potential arguments.
323  ///
324  /// \returns false if the visitation was terminated early, true otherwise.
326 
327  // ---- Methods on Attrs ----
328 
329  // Visit an attribute.
330  bool VisitAttr(Attr *A) { return true; }
331 
332 // Declare Traverse* and empty Visit* for all Attr classes.
333 #define ATTR_VISITOR_DECLS_ONLY
334 #include "clang/AST/AttrVisitor.inc"
335 #undef ATTR_VISITOR_DECLS_ONLY
336 
337 // ---- Methods on Stmts ----
338 
339  Stmt::child_range getStmtChildren(Stmt *S) { return S->children(); }
340 
341 private:
342  // Traverse the given statement. If the most-derived traverse function takes a
343  // data recursion queue, pass it on; otherwise, discard it. Note that the
344  // first branch of this conditional must compile whether or not the derived
345  // class can take a queue, so if we're taking the second arm, make the first
346  // arm call our function rather than the derived class version.
347 #define TRAVERSE_STMT_BASE(NAME, CLASS, VAR, QUEUE) \
348  (::clang::detail::has_same_member_pointer_type< \
349  decltype(&RecursiveASTVisitor::Traverse##NAME), \
350  decltype(&Derived::Traverse##NAME)>::value \
351  ? static_cast<std::conditional_t< \
352  ::clang::detail::has_same_member_pointer_type< \
353  decltype(&RecursiveASTVisitor::Traverse##NAME), \
354  decltype(&Derived::Traverse##NAME)>::value, \
355  Derived &, RecursiveASTVisitor &>>(*this) \
356  .Traverse##NAME(static_cast<CLASS *>(VAR), QUEUE) \
357  : getDerived().Traverse##NAME(static_cast<CLASS *>(VAR)))
358 
359 // Try to traverse the given statement, or enqueue it if we're performing data
360 // recursion in the middle of traversing another statement. Can only be called
361 // from within a DEF_TRAVERSE_STMT body or similar context.
362 #define TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S) \
363  do { \
364  if (!TRAVERSE_STMT_BASE(Stmt, Stmt, S, Queue)) \
365  return false; \
366  } while (false)
367 
368 public:
369 // Declare Traverse*() for all concrete Stmt classes.
370 #define ABSTRACT_STMT(STMT)
371 #define STMT(CLASS, PARENT) \
372  bool Traverse##CLASS(CLASS *S, DataRecursionQueue *Queue = nullptr);
373 #include "clang/AST/StmtNodes.inc"
374  // The above header #undefs ABSTRACT_STMT and STMT upon exit.
375 
376  // Define WalkUpFrom*() and empty Visit*() for all Stmt classes.
377  bool WalkUpFromStmt(Stmt *S) { return getDerived().VisitStmt(S); }
378  bool VisitStmt(Stmt *S) { return true; }
379 #define STMT(CLASS, PARENT) \
380  bool WalkUpFrom##CLASS(CLASS *S) { \
381  TRY_TO(WalkUpFrom##PARENT(S)); \
382  TRY_TO(Visit##CLASS(S)); \
383  return true; \
384  } \
385  bool Visit##CLASS(CLASS *S) { return true; }
386 #include "clang/AST/StmtNodes.inc"
387 
388 // ---- Methods on Types ----
389 // FIXME: revamp to take TypeLoc's rather than Types.
390 
391 // Declare Traverse*() for all concrete Type classes.
392 #define ABSTRACT_TYPE(CLASS, BASE)
393 #define TYPE(CLASS, BASE) bool Traverse##CLASS##Type(CLASS##Type *T);
394 #include "clang/AST/TypeNodes.inc"
395  // The above header #undefs ABSTRACT_TYPE and TYPE upon exit.
396 
397  // Define WalkUpFrom*() and empty Visit*() for all Type classes.
398  bool WalkUpFromType(Type *T) { return getDerived().VisitType(T); }
399  bool VisitType(Type *T) { return true; }
400 #define TYPE(CLASS, BASE) \
401  bool WalkUpFrom##CLASS##Type(CLASS##Type *T) { \
402  TRY_TO(WalkUpFrom##BASE(T)); \
403  TRY_TO(Visit##CLASS##Type(T)); \
404  return true; \
405  } \
406  bool Visit##CLASS##Type(CLASS##Type *T) { return true; }
407 #include "clang/AST/TypeNodes.inc"
408 
409 // ---- Methods on TypeLocs ----
410 // FIXME: this currently just calls the matching Type methods
411 
412 // Declare Traverse*() for all concrete TypeLoc classes.
413 #define ABSTRACT_TYPELOC(CLASS, BASE)
414 #define TYPELOC(CLASS, BASE) bool Traverse##CLASS##TypeLoc(CLASS##TypeLoc TL);
415 #include "clang/AST/TypeLocNodes.def"
416  // The above header #undefs ABSTRACT_TYPELOC and TYPELOC upon exit.
417 
418  // Define WalkUpFrom*() and empty Visit*() for all TypeLoc classes.
419  bool WalkUpFromTypeLoc(TypeLoc TL) { return getDerived().VisitTypeLoc(TL); }
420  bool VisitTypeLoc(TypeLoc TL) { return true; }
421 
422  // QualifiedTypeLoc and UnqualTypeLoc are not declared in
423  // TypeNodes.inc and thus need to be handled specially.
425  return getDerived().VisitUnqualTypeLoc(TL.getUnqualifiedLoc());
426  }
427  bool VisitQualifiedTypeLoc(QualifiedTypeLoc TL) { return true; }
429  return getDerived().VisitUnqualTypeLoc(TL.getUnqualifiedLoc());
430  }
431  bool VisitUnqualTypeLoc(UnqualTypeLoc TL) { return true; }
432 
433 // Note that BASE includes trailing 'Type' which CLASS doesn't.
434 #define TYPE(CLASS, BASE) \
435  bool WalkUpFrom##CLASS##TypeLoc(CLASS##TypeLoc TL) { \
436  TRY_TO(WalkUpFrom##BASE##Loc(TL)); \
437  TRY_TO(Visit##CLASS##TypeLoc(TL)); \
438  return true; \
439  } \
440  bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TL) { return true; }
441 #include "clang/AST/TypeNodes.inc"
442 
443 // ---- Methods on Decls ----
444 
445 // Declare Traverse*() for all concrete Decl classes.
446 #define ABSTRACT_DECL(DECL)
447 #define DECL(CLASS, BASE) bool Traverse##CLASS##Decl(CLASS##Decl *D);
448 #include "clang/AST/DeclNodes.inc"
449  // The above header #undefs ABSTRACT_DECL and DECL upon exit.
450 
451  // Define WalkUpFrom*() and empty Visit*() for all Decl classes.
452  bool WalkUpFromDecl(Decl *D) { return getDerived().VisitDecl(D); }
453  bool VisitDecl(Decl *D) { return true; }
454 #define DECL(CLASS, BASE) \
455  bool WalkUpFrom##CLASS##Decl(CLASS##Decl *D) { \
456  TRY_TO(WalkUpFrom##BASE(D)); \
457  TRY_TO(Visit##CLASS##Decl(D)); \
458  return true; \
459  } \
460  bool Visit##CLASS##Decl(CLASS##Decl *D) { return true; }
461 #include "clang/AST/DeclNodes.inc"
462 
463  bool canIgnoreChildDeclWhileTraversingDeclContext(const Decl *Child);
464 
465 #define DEF_TRAVERSE_TMPL_INST(TMPLDECLKIND) \
466  bool TraverseTemplateInstantiations(TMPLDECLKIND##TemplateDecl *D);
469  DEF_TRAVERSE_TMPL_INST(Function)
470 #undef DEF_TRAVERSE_TMPL_INST
471 
472  bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue);
473 
474 private:
475  // These are helper methods used by more than one Traverse* method.
476  bool TraverseTemplateParameterListHelper(TemplateParameterList *TPL);
477 
478  // Traverses template parameter lists of either a DeclaratorDecl or TagDecl.
479  template <typename T>
480  bool TraverseDeclTemplateParameterLists(T *D);
481 
482  bool TraverseTemplateTypeParamDeclConstraints(const TemplateTypeParmDecl *D);
483 
484  bool TraverseTemplateArgumentLocsHelper(const TemplateArgumentLoc *TAL,
485  unsigned Count);
486  bool TraverseArrayTypeLocHelper(ArrayTypeLoc TL);
487  bool TraverseRecordHelper(RecordDecl *D);
488  bool TraverseCXXRecordHelper(CXXRecordDecl *D);
489  bool TraverseDeclaratorHelper(DeclaratorDecl *D);
490  bool TraverseDeclContextHelper(DeclContext *DC);
491  bool TraverseFunctionHelper(FunctionDecl *D);
492  bool TraverseVarHelper(VarDecl *D);
493  bool TraverseOMPExecutableDirective(OMPExecutableDirective *S);
494  bool TraverseOMPLoopDirective(OMPLoopDirective *S);
495  bool TraverseOMPClause(OMPClause *C);
496 #define GEN_CLANG_CLAUSE_CLASS
497 #define CLAUSE_CLASS(Enum, Str, Class) bool Visit##Class(Class *C);
498 #include "llvm/Frontend/OpenMP/OMP.inc"
499  /// Process clauses with list of variables.
500  template <typename T> bool VisitOMPClauseList(T *Node);
501  /// Process clauses with pre-initis.
502  bool VisitOMPClauseWithPreInit(OMPClauseWithPreInit *Node);
503  bool VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *Node);
504 
505  bool PostVisitStmt(Stmt *S);
506 };
507 
508 template <typename Derived>
510  DataRecursionQueue *Queue) {
511  // Top switch stmt: dispatch to TraverseFooStmt for each concrete FooStmt.
512  switch (S->getStmtClass()) {
513  case Stmt::NoStmtClass:
514  break;
515 #define ABSTRACT_STMT(STMT)
516 #define STMT(CLASS, PARENT) \
517  case Stmt::CLASS##Class: \
518  return TRAVERSE_STMT_BASE(CLASS, CLASS, S, Queue);
519 #include "clang/AST/StmtNodes.inc"
520  }
521 
522  return true;
523 }
524 
525 #undef DISPATCH_STMT
526 
527 template <typename Derived>
529  // In pre-order traversal mode, each Traverse##STMT method is responsible for
530  // calling WalkUpFrom. Therefore, if the user overrides Traverse##STMT and
531  // does not call the default implementation, the WalkUpFrom callback is not
532  // called. Post-order traversal mode should provide the same behavior
533  // regarding method overrides.
534  //
535  // In post-order traversal mode the Traverse##STMT method, when it receives a
536  // DataRecursionQueue, can't call WalkUpFrom after traversing children because
537  // it only enqueues the children and does not traverse them. TraverseStmt
538  // traverses the enqueued children, and we call WalkUpFrom here.
539  //
540  // However, to make pre-order and post-order modes identical with regards to
541  // whether they call WalkUpFrom at all, we call WalkUpFrom if and only if the
542  // user did not override the Traverse##STMT method. We implement the override
543  // check with isSameMethod calls below.
544 
545  switch (S->getStmtClass()) {
546  case Stmt::NoStmtClass:
547  break;
548 #define ABSTRACT_STMT(STMT)
549 #define STMT(CLASS, PARENT) \
550  case Stmt::CLASS##Class: \
551  if (::clang::detail::isSameMethod(&RecursiveASTVisitor::Traverse##CLASS, \
552  &Derived::Traverse##CLASS)) { \
553  TRY_TO(WalkUpFrom##CLASS(static_cast<CLASS *>(S))); \
554  } \
555  break;
556 #define INITLISTEXPR(CLASS, PARENT) \
557  case Stmt::CLASS##Class: \
558  if (::clang::detail::isSameMethod(&RecursiveASTVisitor::Traverse##CLASS, \
559  &Derived::Traverse##CLASS)) { \
560  auto ILE = static_cast<CLASS *>(S); \
561  if (auto Syn = ILE->isSemanticForm() ? ILE->getSyntacticForm() : ILE) \
562  TRY_TO(WalkUpFrom##CLASS(Syn)); \
563  if (auto Sem = ILE->isSemanticForm() ? ILE : ILE->getSemanticForm()) \
564  TRY_TO(WalkUpFrom##CLASS(Sem)); \
565  } \
566  break;
567 #include "clang/AST/StmtNodes.inc"
568  }
569 
570  return true;
571 }
572 
573 #undef DISPATCH_STMT
574 
575 template <typename Derived>
577  DataRecursionQueue *Queue) {
578  if (!S)
579  return true;
580 
581  if (Queue) {
582  Queue->push_back({S, false});
583  return true;
584  }
585 
587  LocalQueue.push_back({S, false});
588 
589  while (!LocalQueue.empty()) {
590  auto &CurrSAndVisited = LocalQueue.back();
591  Stmt *CurrS = CurrSAndVisited.getPointer();
592  bool Visited = CurrSAndVisited.getInt();
593  if (Visited) {
594  LocalQueue.pop_back();
595  TRY_TO(dataTraverseStmtPost(CurrS));
596  if (getDerived().shouldTraversePostOrder()) {
597  TRY_TO(PostVisitStmt(CurrS));
598  }
599  continue;
600  }
601 
602  if (getDerived().dataTraverseStmtPre(CurrS)) {
603  CurrSAndVisited.setInt(true);
604  size_t N = LocalQueue.size();
605  TRY_TO(dataTraverseNode(CurrS, &LocalQueue));
606  // Process new children in the order they were added.
607  std::reverse(LocalQueue.begin() + N, LocalQueue.end());
608  } else {
609  LocalQueue.pop_back();
610  }
611  }
612 
613  return true;
614 }
615 
616 template <typename Derived>
618  if (T.isNull())
619  return true;
620 
621  switch (T->getTypeClass()) {
622 #define ABSTRACT_TYPE(CLASS, BASE)
623 #define TYPE(CLASS, BASE) \
624  case Type::CLASS: \
625  return getDerived().Traverse##CLASS##Type( \
626  static_cast<CLASS##Type *>(const_cast<Type *>(T.getTypePtr())));
627 #include "clang/AST/TypeNodes.inc"
628  }
629 
630  return true;
631 }
632 
633 template <typename Derived>
635  if (TL.isNull())
636  return true;
637 
638  switch (TL.getTypeLocClass()) {
639 #define ABSTRACT_TYPELOC(CLASS, BASE)
640 #define TYPELOC(CLASS, BASE) \
641  case TypeLoc::CLASS: \
642  return getDerived().Traverse##CLASS##TypeLoc(TL.castAs<CLASS##TypeLoc>());
643 #include "clang/AST/TypeLocNodes.def"
644  }
645 
646  return true;
647 }
648 
649 // Define the Traverse*Attr(Attr* A) methods
650 #define VISITORCLASS RecursiveASTVisitor
651 #include "clang/AST/AttrVisitor.inc"
652 #undef VISITORCLASS
653 
654 template <typename Derived>
656  if (!D)
657  return true;
658 
659  // As a syntax visitor, by default we want to ignore declarations for
660  // implicit declarations (ones not typed explicitly by the user).
661  if (!getDerived().shouldVisitImplicitCode() && D->isImplicit()) {
662  // For an implicit template type parameter, its type constraints are not
663  // implicit and are not represented anywhere else. We still need to visit
664  // them.
665  if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(D))
666  return TraverseTemplateTypeParamDeclConstraints(TTPD);
667  return true;
668  }
669 
670  switch (D->getKind()) {
671 #define ABSTRACT_DECL(DECL)
672 #define DECL(CLASS, BASE) \
673  case Decl::CLASS: \
674  if (!getDerived().Traverse##CLASS##Decl(static_cast<CLASS##Decl *>(D))) \
675  return false; \
676  break;
677 #include "clang/AST/DeclNodes.inc"
678  }
679  return true;
680 }
681 
682 template <typename Derived>
684  NestedNameSpecifier *NNS) {
685  if (!NNS)
686  return true;
687 
688  if (NNS->getPrefix())
689  TRY_TO(TraverseNestedNameSpecifier(NNS->getPrefix()));
690 
691  switch (NNS->getKind()) {
697  return true;
698 
701  TRY_TO(TraverseType(QualType(NNS->getAsType(), 0)));
702  }
703 
704  return true;
705 }
706 
707 template <typename Derived>
710  if (!NNS)
711  return true;
712 
713  if (NestedNameSpecifierLoc Prefix = NNS.getPrefix())
714  TRY_TO(TraverseNestedNameSpecifierLoc(Prefix));
715 
716  switch (NNS.getNestedNameSpecifier()->getKind()) {
722  return true;
723 
726  TRY_TO(TraverseTypeLoc(NNS.getTypeLoc()));
727  break;
728  }
729 
730  return true;
731 }
732 
733 template <typename Derived>
735  DeclarationNameInfo NameInfo) {
736  switch (NameInfo.getName().getNameKind()) {
740  if (TypeSourceInfo *TSInfo = NameInfo.getNamedTypeInfo())
741  TRY_TO(TraverseTypeLoc(TSInfo->getTypeLoc()));
742  break;
743 
745  TRY_TO(TraverseTemplateName(
747  break;
748 
756  break;
757  }
758 
759  return true;
760 }
761 
762 template <typename Derived>
765  TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier()));
766  else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
767  TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
768 
769  return true;
770 }
771 
772 template <typename Derived>
774  const TemplateArgument &Arg) {
775  switch (Arg.getKind()) {
780  return true;
781 
783  return getDerived().TraverseType(Arg.getAsType());
784 
787  return getDerived().TraverseTemplateName(
789 
791  return getDerived().TraverseStmt(Arg.getAsExpr());
792 
794  return getDerived().TraverseTemplateArguments(Arg.pack_begin(),
795  Arg.pack_size());
796  }
797 
798  return true;
799 }
800 
801 // FIXME: no template name location?
802 // FIXME: no source locations for a template argument pack?
803 template <typename Derived>
805  const TemplateArgumentLoc &ArgLoc) {
806  const TemplateArgument &Arg = ArgLoc.getArgument();
807 
808  switch (Arg.getKind()) {
813  return true;
814 
815  case TemplateArgument::Type: {
816  // FIXME: how can TSI ever be NULL?
817  if (TypeSourceInfo *TSI = ArgLoc.getTypeSourceInfo())
818  return getDerived().TraverseTypeLoc(TSI->getTypeLoc());
819  else
820  return getDerived().TraverseType(Arg.getAsType());
821  }
822 
825  if (ArgLoc.getTemplateQualifierLoc())
826  TRY_TO(getDerived().TraverseNestedNameSpecifierLoc(
827  ArgLoc.getTemplateQualifierLoc()));
828  return getDerived().TraverseTemplateName(
830 
832  return getDerived().TraverseStmt(ArgLoc.getSourceExpression());
833 
835  return getDerived().TraverseTemplateArguments(Arg.pack_begin(),
836  Arg.pack_size());
837  }
838 
839  return true;
840 }
841 
842 template <typename Derived>
844  const TemplateArgument *Args, unsigned NumArgs) {
845  for (unsigned I = 0; I != NumArgs; ++I) {
846  TRY_TO(TraverseTemplateArgument(Args[I]));
847  }
848 
849  return true;
850 }
851 
852 template <typename Derived>
854  CXXCtorInitializer *Init) {
855  if (TypeSourceInfo *TInfo = Init->getTypeSourceInfo())
856  TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
857 
858  if (Init->isWritten() || getDerived().shouldVisitImplicitCode())
859  TRY_TO(TraverseStmt(Init->getInit()));
860 
861  return true;
862 }
863 
864 template <typename Derived>
865 bool
867  const LambdaCapture *C,
868  Expr *Init) {
869  if (LE->isInitCapture(C))
870  TRY_TO(TraverseDecl(C->getCapturedVar()));
871  else
872  TRY_TO(TraverseStmt(Init));
873  return true;
874 }
875 
876 // ----------------- Type traversal -----------------
877 
878 // This macro makes available a variable T, the passed-in type.
879 #define DEF_TRAVERSE_TYPE(TYPE, CODE) \
880  template <typename Derived> \
881  bool RecursiveASTVisitor<Derived>::Traverse##TYPE(TYPE *T) { \
882  if (!getDerived().shouldTraversePostOrder()) \
883  TRY_TO(WalkUpFrom##TYPE(T)); \
884  { CODE; } \
885  if (getDerived().shouldTraversePostOrder()) \
886  TRY_TO(WalkUpFrom##TYPE(T)); \
887  return true; \
888  }
889 
890 DEF_TRAVERSE_TYPE(BuiltinType, {})
891 
892 DEF_TRAVERSE_TYPE(ComplexType, { TRY_TO(TraverseType(T->getElementType())); })
893 
894 DEF_TRAVERSE_TYPE(PointerType, { TRY_TO(TraverseType(T->getPointeeType())); })
895 
896 DEF_TRAVERSE_TYPE(BlockPointerType,
897  { TRY_TO(TraverseType(T->getPointeeType())); })
898 
899 DEF_TRAVERSE_TYPE(LValueReferenceType,
900  { TRY_TO(TraverseType(T->getPointeeType())); })
901 
902 DEF_TRAVERSE_TYPE(RValueReferenceType,
903  { TRY_TO(TraverseType(T->getPointeeType())); })
904 
905 DEF_TRAVERSE_TYPE(MemberPointerType, {
906  TRY_TO(TraverseType(QualType(T->getClass(), 0)));
907  TRY_TO(TraverseType(T->getPointeeType()));
908 })
909 
910 DEF_TRAVERSE_TYPE(AdjustedType, { TRY_TO(TraverseType(T->getOriginalType())); })
911 
912 DEF_TRAVERSE_TYPE(DecayedType, { TRY_TO(TraverseType(T->getOriginalType())); })
913 
914 DEF_TRAVERSE_TYPE(ConstantArrayType, {
915  TRY_TO(TraverseType(T->getElementType()));
916  if (T->getSizeExpr())
917  TRY_TO(TraverseStmt(const_cast<Expr*>(T->getSizeExpr())));
918 })
919 
920 DEF_TRAVERSE_TYPE(IncompleteArrayType,
921  { TRY_TO(TraverseType(T->getElementType())); })
922 
923 DEF_TRAVERSE_TYPE(VariableArrayType, {
924  TRY_TO(TraverseType(T->getElementType()));
925  TRY_TO(TraverseStmt(T->getSizeExpr()));
926 })
927 
928 DEF_TRAVERSE_TYPE(DependentSizedArrayType, {
929  TRY_TO(TraverseType(T->getElementType()));
930  if (T->getSizeExpr())
931  TRY_TO(TraverseStmt(T->getSizeExpr()));
932 })
933 
934 DEF_TRAVERSE_TYPE(DependentAddressSpaceType, {
935  TRY_TO(TraverseStmt(T->getAddrSpaceExpr()));
936  TRY_TO(TraverseType(T->getPointeeType()));
937 })
938 
939 DEF_TRAVERSE_TYPE(DependentVectorType, {
940  if (T->getSizeExpr())
941  TRY_TO(TraverseStmt(T->getSizeExpr()));
942  TRY_TO(TraverseType(T->getElementType()));
943 })
944 
945 DEF_TRAVERSE_TYPE(DependentSizedExtVectorType, {
946  if (T->getSizeExpr())
947  TRY_TO(TraverseStmt(T->getSizeExpr()));
948  TRY_TO(TraverseType(T->getElementType()));
949 })
950 
951 DEF_TRAVERSE_TYPE(VectorType, { TRY_TO(TraverseType(T->getElementType())); })
952 
953 DEF_TRAVERSE_TYPE(ExtVectorType, { TRY_TO(TraverseType(T->getElementType())); })
954 
955 DEF_TRAVERSE_TYPE(ConstantMatrixType,
956  { TRY_TO(TraverseType(T->getElementType())); })
957 
958 DEF_TRAVERSE_TYPE(DependentSizedMatrixType, {
959  if (T->getRowExpr())
960  TRY_TO(TraverseStmt(T->getRowExpr()));
961  if (T->getColumnExpr())
962  TRY_TO(TraverseStmt(T->getColumnExpr()));
963  TRY_TO(TraverseType(T->getElementType()));
964 })
965 
966 DEF_TRAVERSE_TYPE(FunctionNoProtoType,
967  { TRY_TO(TraverseType(T->getReturnType())); })
968 
969 DEF_TRAVERSE_TYPE(FunctionProtoType, {
970  TRY_TO(TraverseType(T->getReturnType()));
971 
972  for (const auto &A : T->param_types()) {
973  TRY_TO(TraverseType(A));
974  }
975 
976  for (const auto &E : T->exceptions()) {
977  TRY_TO(TraverseType(E));
978  }
979 
980  if (Expr *NE = T->getNoexceptExpr())
981  TRY_TO(TraverseStmt(NE));
982 })
983 
984 DEF_TRAVERSE_TYPE(UsingType, {})
985 DEF_TRAVERSE_TYPE(UnresolvedUsingType, {})
986 DEF_TRAVERSE_TYPE(TypedefType, {})
987 
988 DEF_TRAVERSE_TYPE(TypeOfExprType,
989  { TRY_TO(TraverseStmt(T->getUnderlyingExpr())); })
990 
991 DEF_TRAVERSE_TYPE(TypeOfType, { TRY_TO(TraverseType(T->getUnderlyingType())); })
992 
993 DEF_TRAVERSE_TYPE(DecltypeType,
994  { TRY_TO(TraverseStmt(T->getUnderlyingExpr())); })
995 
996 DEF_TRAVERSE_TYPE(UnaryTransformType, {
997  TRY_TO(TraverseType(T->getBaseType()));
998  TRY_TO(TraverseType(T->getUnderlyingType()));
999 })
1000 
1001 DEF_TRAVERSE_TYPE(AutoType, {
1002  TRY_TO(TraverseType(T->getDeducedType()));
1003  if (T->isConstrained()) {
1004  TRY_TO(TraverseDecl(T->getTypeConstraintConcept()));
1005  TRY_TO(TraverseTemplateArguments(T->getArgs(), T->getNumArgs()));
1006  }
1007 })
1008 DEF_TRAVERSE_TYPE(DeducedTemplateSpecializationType, {
1009  TRY_TO(TraverseTemplateName(T->getTemplateName()));
1010  TRY_TO(TraverseType(T->getDeducedType()));
1011 })
1012 
1013 DEF_TRAVERSE_TYPE(RecordType, {})
1014 DEF_TRAVERSE_TYPE(EnumType, {})
1015 DEF_TRAVERSE_TYPE(TemplateTypeParmType, {})
1016 DEF_TRAVERSE_TYPE(SubstTemplateTypeParmType, {
1017  TRY_TO(TraverseType(T->getReplacementType()));
1018 })
1019 DEF_TRAVERSE_TYPE(SubstTemplateTypeParmPackType, {
1020  TRY_TO(TraverseTemplateArgument(T->getArgumentPack()));
1021 })
1022 
1023 DEF_TRAVERSE_TYPE(TemplateSpecializationType, {
1024  TRY_TO(TraverseTemplateName(T->getTemplateName()));
1025  TRY_TO(TraverseTemplateArguments(T->getArgs(), T->getNumArgs()));
1026 })
1027 
1028 DEF_TRAVERSE_TYPE(InjectedClassNameType, {})
1029 
1030 DEF_TRAVERSE_TYPE(AttributedType,
1031  { TRY_TO(TraverseType(T->getModifiedType())); })
1032 
1033 DEF_TRAVERSE_TYPE(ParenType, { TRY_TO(TraverseType(T->getInnerType())); })
1034 
1035 DEF_TRAVERSE_TYPE(MacroQualifiedType,
1036  { TRY_TO(TraverseType(T->getUnderlyingType())); })
1037 
1038 DEF_TRAVERSE_TYPE(ElaboratedType, {
1039  if (T->getQualifier()) {
1040  TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
1041  }
1042  TRY_TO(TraverseType(T->getNamedType()));
1043 })
1044 
1045 DEF_TRAVERSE_TYPE(DependentNameType,
1046  { TRY_TO(TraverseNestedNameSpecifier(T->getQualifier())); })
1047 
1048 DEF_TRAVERSE_TYPE(DependentTemplateSpecializationType, {
1049  TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
1050  TRY_TO(TraverseTemplateArguments(T->getArgs(), T->getNumArgs()));
1051 })
1052 
1053 DEF_TRAVERSE_TYPE(PackExpansionType, { TRY_TO(TraverseType(T->getPattern())); })
1054 
1055 DEF_TRAVERSE_TYPE(ObjCTypeParamType, {})
1056 
1057 DEF_TRAVERSE_TYPE(ObjCInterfaceType, {})
1058 
1059 DEF_TRAVERSE_TYPE(ObjCObjectType, {
1060  // We have to watch out here because an ObjCInterfaceType's base
1061  // type is itself.
1062  if (T->getBaseType().getTypePtr() != T)
1063  TRY_TO(TraverseType(T->getBaseType()));
1064  for (auto typeArg : T->getTypeArgsAsWritten()) {
1065  TRY_TO(TraverseType(typeArg));
1066  }
1067 })
1068 
1069 DEF_TRAVERSE_TYPE(ObjCObjectPointerType,
1070  { TRY_TO(TraverseType(T->getPointeeType())); })
1071 
1072 DEF_TRAVERSE_TYPE(AtomicType, { TRY_TO(TraverseType(T->getValueType())); })
1073 
1074 DEF_TRAVERSE_TYPE(PipeType, { TRY_TO(TraverseType(T->getElementType())); })
1075 
1076 DEF_TRAVERSE_TYPE(BitIntType, {})
1077 DEF_TRAVERSE_TYPE(DependentBitIntType,
1078  { TRY_TO(TraverseStmt(T->getNumBitsExpr())); })
1079 
1080 #undef DEF_TRAVERSE_TYPE
1081 
1082 // ----------------- TypeLoc traversal -----------------
1083 
1084 // This macro makes available a variable TL, the passed-in TypeLoc.
1085 // If requested, it calls WalkUpFrom* for the Type in the given TypeLoc,
1086 // in addition to WalkUpFrom* for the TypeLoc itself, such that existing
1087 // clients that override the WalkUpFrom*Type() and/or Visit*Type() methods
1088 // continue to work.
1089 #define DEF_TRAVERSE_TYPELOC(TYPE, CODE) \
1090  template <typename Derived> \
1091  bool RecursiveASTVisitor<Derived>::Traverse##TYPE##Loc(TYPE##Loc TL) { \
1092  if (!getDerived().shouldTraversePostOrder()) { \
1093  TRY_TO(WalkUpFrom##TYPE##Loc(TL)); \
1094  if (getDerived().shouldWalkTypesOfTypeLocs()) \
1095  TRY_TO(WalkUpFrom##TYPE(const_cast<TYPE *>(TL.getTypePtr()))); \
1096  } \
1097  { CODE; } \
1098  if (getDerived().shouldTraversePostOrder()) { \
1099  TRY_TO(WalkUpFrom##TYPE##Loc(TL)); \
1100  if (getDerived().shouldWalkTypesOfTypeLocs()) \
1101  TRY_TO(WalkUpFrom##TYPE(const_cast<TYPE *>(TL.getTypePtr()))); \
1102  } \
1103  return true; \
1104  }
1105 
1106 template <typename Derived>
1107 bool
1108 RecursiveASTVisitor<Derived>::TraverseQualifiedTypeLoc(QualifiedTypeLoc TL) {
1109  // Move this over to the 'main' typeloc tree. Note that this is a
1110  // move -- we pretend that we were really looking at the unqualified
1111  // typeloc all along -- rather than a recursion, so we don't follow
1112  // the normal CRTP plan of going through
1113  // getDerived().TraverseTypeLoc. If we did, we'd be traversing
1114  // twice for the same type (once as a QualifiedTypeLoc version of
1115  // the type, once as an UnqualifiedTypeLoc version of the type),
1116  // which in effect means we'd call VisitTypeLoc twice with the
1117  // 'same' type. This solves that problem, at the cost of never
1118  // seeing the qualified version of the type (unless the client
1119  // subclasses TraverseQualifiedTypeLoc themselves). It's not a
1120  // perfect solution. A perfect solution probably requires making
1121  // QualifiedTypeLoc a wrapper around TypeLoc -- like QualType is a
1122  // wrapper around Type* -- rather than being its own class in the
1123  // type hierarchy.
1124  return TraverseTypeLoc(TL.getUnqualifiedLoc());
1125 }
1126 
1127 DEF_TRAVERSE_TYPELOC(BuiltinType, {})
1128 
1129 // FIXME: ComplexTypeLoc is unfinished
1130 DEF_TRAVERSE_TYPELOC(ComplexType, {
1131  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1132 })
1133 
1134 DEF_TRAVERSE_TYPELOC(PointerType,
1135  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1136 
1137 DEF_TRAVERSE_TYPELOC(BlockPointerType,
1138  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1139 
1140 DEF_TRAVERSE_TYPELOC(LValueReferenceType,
1141  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1142 
1143 DEF_TRAVERSE_TYPELOC(RValueReferenceType,
1144  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1145 
1146 // We traverse this in the type case as well, but how is it not reached through
1147 // the pointee type?
1148 DEF_TRAVERSE_TYPELOC(MemberPointerType, {
1149  if (auto *TSI = TL.getClassTInfo())
1150  TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
1151  else
1152  TRY_TO(TraverseType(QualType(TL.getTypePtr()->getClass(), 0)));
1153  TRY_TO(TraverseTypeLoc(TL.getPointeeLoc()));
1154 })
1155 
1156 DEF_TRAVERSE_TYPELOC(AdjustedType,
1157  { TRY_TO(TraverseTypeLoc(TL.getOriginalLoc())); })
1158 
1159 DEF_TRAVERSE_TYPELOC(DecayedType,
1160  { TRY_TO(TraverseTypeLoc(TL.getOriginalLoc())); })
1161 
1162 template <typename Derived>
1163 bool RecursiveASTVisitor<Derived>::TraverseArrayTypeLocHelper(ArrayTypeLoc TL) {
1164  // This isn't available for ArrayType, but is for the ArrayTypeLoc.
1165  TRY_TO(TraverseStmt(TL.getSizeExpr()));
1166  return true;
1167 }
1168 
1169 DEF_TRAVERSE_TYPELOC(ConstantArrayType, {
1170  TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1171  TRY_TO(TraverseArrayTypeLocHelper(TL));
1172 })
1173 
1174 DEF_TRAVERSE_TYPELOC(IncompleteArrayType, {
1175  TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1176  TRY_TO(TraverseArrayTypeLocHelper(TL));
1177 })
1178 
1179 DEF_TRAVERSE_TYPELOC(VariableArrayType, {
1180  TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1181  TRY_TO(TraverseArrayTypeLocHelper(TL));
1182 })
1183 
1184 DEF_TRAVERSE_TYPELOC(DependentSizedArrayType, {
1185  TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1186  TRY_TO(TraverseArrayTypeLocHelper(TL));
1187 })
1188 
1189 DEF_TRAVERSE_TYPELOC(DependentAddressSpaceType, {
1190  TRY_TO(TraverseStmt(TL.getTypePtr()->getAddrSpaceExpr()));
1191  TRY_TO(TraverseType(TL.getTypePtr()->getPointeeType()));
1192 })
1193 
1194 // FIXME: order? why not size expr first?
1195 // FIXME: base VectorTypeLoc is unfinished
1196 DEF_TRAVERSE_TYPELOC(DependentSizedExtVectorType, {
1197  if (TL.getTypePtr()->getSizeExpr())
1198  TRY_TO(TraverseStmt(TL.getTypePtr()->getSizeExpr()));
1199  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1200 })
1201 
1202 // FIXME: VectorTypeLoc is unfinished
1203 DEF_TRAVERSE_TYPELOC(VectorType, {
1204  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1205 })
1206 
1207 DEF_TRAVERSE_TYPELOC(DependentVectorType, {
1208  if (TL.getTypePtr()->getSizeExpr())
1209  TRY_TO(TraverseStmt(TL.getTypePtr()->getSizeExpr()));
1210  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1211 })
1212 
1213 // FIXME: size and attributes
1214 // FIXME: base VectorTypeLoc is unfinished
1215 DEF_TRAVERSE_TYPELOC(ExtVectorType, {
1216  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1217 })
1218 
1219 DEF_TRAVERSE_TYPELOC(ConstantMatrixType, {
1220  TRY_TO(TraverseStmt(TL.getAttrRowOperand()));
1221  TRY_TO(TraverseStmt(TL.getAttrColumnOperand()));
1222  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1223 })
1224 
1225 DEF_TRAVERSE_TYPELOC(DependentSizedMatrixType, {
1226  TRY_TO(TraverseStmt(TL.getAttrRowOperand()));
1227  TRY_TO(TraverseStmt(TL.getAttrColumnOperand()));
1228  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1229 })
1230 
1231 DEF_TRAVERSE_TYPELOC(FunctionNoProtoType,
1232  { TRY_TO(TraverseTypeLoc(TL.getReturnLoc())); })
1233 
1234 // FIXME: location of exception specifications (attributes?)
1235 DEF_TRAVERSE_TYPELOC(FunctionProtoType, {
1236  TRY_TO(TraverseTypeLoc(TL.getReturnLoc()));
1237 
1238  const FunctionProtoType *T = TL.getTypePtr();
1239 
1240  for (unsigned I = 0, E = TL.getNumParams(); I != E; ++I) {
1241  if (TL.getParam(I)) {
1242  TRY_TO(TraverseDecl(TL.getParam(I)));
1243  } else if (I < T->getNumParams()) {
1244  TRY_TO(TraverseType(T->getParamType(I)));
1245  }
1246  }
1247 
1248  for (const auto &E : T->exceptions()) {
1249  TRY_TO(TraverseType(E));
1250  }
1251 
1252  if (Expr *NE = T->getNoexceptExpr())
1253  TRY_TO(TraverseStmt(NE));
1254 })
1255 
1256 DEF_TRAVERSE_TYPELOC(UsingType, {})
1257 DEF_TRAVERSE_TYPELOC(UnresolvedUsingType, {})
1258 DEF_TRAVERSE_TYPELOC(TypedefType, {})
1259 
1260 DEF_TRAVERSE_TYPELOC(TypeOfExprType,
1261  { TRY_TO(TraverseStmt(TL.getUnderlyingExpr())); })
1262 
1263 DEF_TRAVERSE_TYPELOC(TypeOfType, {
1264  TRY_TO(TraverseTypeLoc(TL.getUnderlyingTInfo()->getTypeLoc()));
1265 })
1266 
1267 // FIXME: location of underlying expr
1268 DEF_TRAVERSE_TYPELOC(DecltypeType, {
1269  TRY_TO(TraverseStmt(TL.getTypePtr()->getUnderlyingExpr()));
1270 })
1271 
1272 DEF_TRAVERSE_TYPELOC(UnaryTransformType, {
1273  TRY_TO(TraverseTypeLoc(TL.getUnderlyingTInfo()->getTypeLoc()));
1274 })
1275 
1276 DEF_TRAVERSE_TYPELOC(AutoType, {
1277  TRY_TO(TraverseType(TL.getTypePtr()->getDeducedType()));
1278  if (TL.isConstrained()) {
1279  TRY_TO(TraverseNestedNameSpecifierLoc(TL.getNestedNameSpecifierLoc()));
1280  TRY_TO(TraverseDeclarationNameInfo(TL.getConceptNameInfo()));
1281  for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I)
1282  TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(I)));
1283  }
1284 })
1285 
1286 DEF_TRAVERSE_TYPELOC(DeducedTemplateSpecializationType, {
1287  TRY_TO(TraverseTemplateName(TL.getTypePtr()->getTemplateName()));
1288  TRY_TO(TraverseType(TL.getTypePtr()->getDeducedType()));
1289 })
1290 
1291 DEF_TRAVERSE_TYPELOC(RecordType, {})
1292 DEF_TRAVERSE_TYPELOC(EnumType, {})
1293 DEF_TRAVERSE_TYPELOC(TemplateTypeParmType, {})
1294 DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmType, {
1295  TRY_TO(TraverseType(TL.getTypePtr()->getReplacementType()));
1296 })
1297 DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmPackType, {
1298  TRY_TO(TraverseTemplateArgument(TL.getTypePtr()->getArgumentPack()));
1299 })
1300 
1301 // FIXME: use the loc for the template name?
1302 DEF_TRAVERSE_TYPELOC(TemplateSpecializationType, {
1303  TRY_TO(TraverseTemplateName(TL.getTypePtr()->getTemplateName()));
1304  for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) {
1305  TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(I)));
1306  }
1307 })
1308 
1309 DEF_TRAVERSE_TYPELOC(InjectedClassNameType, {})
1310 
1311 DEF_TRAVERSE_TYPELOC(ParenType, { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
1312 
1313 DEF_TRAVERSE_TYPELOC(MacroQualifiedType,
1314  { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
1315 
1316 DEF_TRAVERSE_TYPELOC(AttributedType,
1317  { TRY_TO(TraverseTypeLoc(TL.getModifiedLoc())); })
1318 
1319 DEF_TRAVERSE_TYPELOC(ElaboratedType, {
1320  if (TL.getQualifierLoc()) {
1321  TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1322  }
1323  TRY_TO(TraverseTypeLoc(TL.getNamedTypeLoc()));
1324 })
1325 
1326 DEF_TRAVERSE_TYPELOC(DependentNameType, {
1327  TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1328 })
1329 
1330 DEF_TRAVERSE_TYPELOC(DependentTemplateSpecializationType, {
1331  if (TL.getQualifierLoc()) {
1332  TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1333  }
1334 
1335  for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) {
1336  TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(I)));
1337  }
1338 })
1339 
1340 DEF_TRAVERSE_TYPELOC(PackExpansionType,
1341  { TRY_TO(TraverseTypeLoc(TL.getPatternLoc())); })
1342 
1343 DEF_TRAVERSE_TYPELOC(ObjCTypeParamType, {})
1344 
1345 DEF_TRAVERSE_TYPELOC(ObjCInterfaceType, {})
1346 
1347 DEF_TRAVERSE_TYPELOC(ObjCObjectType, {
1348  // We have to watch out here because an ObjCInterfaceType's base
1349  // type is itself.
1350  if (TL.getTypePtr()->getBaseType().getTypePtr() != TL.getTypePtr())
1351  TRY_TO(TraverseTypeLoc(TL.getBaseLoc()));
1352  for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
1353  TRY_TO(TraverseTypeLoc(TL.getTypeArgTInfo(i)->getTypeLoc()));
1354 })
1355 
1356 DEF_TRAVERSE_TYPELOC(ObjCObjectPointerType,
1357  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1358 
1359 DEF_TRAVERSE_TYPELOC(AtomicType, { TRY_TO(TraverseTypeLoc(TL.getValueLoc())); })
1360 
1361 DEF_TRAVERSE_TYPELOC(PipeType, { TRY_TO(TraverseTypeLoc(TL.getValueLoc())); })
1362 
1363 DEF_TRAVERSE_TYPELOC(BitIntType, {})
1364 DEF_TRAVERSE_TYPELOC(DependentBitIntType, {
1365  TRY_TO(TraverseStmt(TL.getTypePtr()->getNumBitsExpr()));
1366 })
1367 
1368 #undef DEF_TRAVERSE_TYPELOC
1369 
1370 // ----------------- Decl traversal -----------------
1371 //
1372 // For a Decl, we automate (in the DEF_TRAVERSE_DECL macro) traversing
1373 // the children that come from the DeclContext associated with it.
1374 // Therefore each Traverse* only needs to worry about children other
1375 // than those.
1376 
1377 template <typename Derived>
1379  const Decl *Child) {
1380  // BlockDecls are traversed through BlockExprs,
1381  // CapturedDecls are traversed through CapturedStmts.
1382  if (isa<BlockDecl>(Child) || isa<CapturedDecl>(Child))
1383  return true;
1384  // Lambda classes are traversed through LambdaExprs.
1385  if (const CXXRecordDecl* Cls = dyn_cast<CXXRecordDecl>(Child))
1386  return Cls->isLambda();
1387  return false;
1388 }
1389 
1390 template <typename Derived>
1391 bool RecursiveASTVisitor<Derived>::TraverseDeclContextHelper(DeclContext *DC) {
1392  if (!DC)
1393  return true;
1394 
1395  for (auto *Child : DC->decls()) {
1396  if (!canIgnoreChildDeclWhileTraversingDeclContext(Child))
1397  TRY_TO(TraverseDecl(Child));
1398  }
1399 
1400  return true;
1401 }
1402 
1403 // This macro makes available a variable D, the passed-in decl.
1404 #define DEF_TRAVERSE_DECL(DECL, CODE) \
1405  template <typename Derived> \
1406  bool RecursiveASTVisitor<Derived>::Traverse##DECL(DECL *D) { \
1407  bool ShouldVisitChildren = true; \
1408  bool ReturnValue = true; \
1409  if (!getDerived().shouldTraversePostOrder()) \
1410  TRY_TO(WalkUpFrom##DECL(D)); \
1411  { CODE; } \
1412  if (ReturnValue && ShouldVisitChildren) \
1413  TRY_TO(TraverseDeclContextHelper(dyn_cast<DeclContext>(D))); \
1414  if (ReturnValue) { \
1415  /* Visit any attributes attached to this declaration. */ \
1416  for (auto *I : D->attrs()) \
1417  TRY_TO(getDerived().TraverseAttr(I)); \
1418  } \
1419  if (ReturnValue && getDerived().shouldTraversePostOrder()) \
1420  TRY_TO(WalkUpFrom##DECL(D)); \
1421  return ReturnValue; \
1422  }
1423 
1424 DEF_TRAVERSE_DECL(AccessSpecDecl, {})
1425 
1426 DEF_TRAVERSE_DECL(BlockDecl, {
1427  if (TypeSourceInfo *TInfo = D->getSignatureAsWritten())
1428  TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
1429  TRY_TO(TraverseStmt(D->getBody()));
1430  for (const auto &I : D->captures()) {
1431  if (I.hasCopyExpr()) {
1432  TRY_TO(TraverseStmt(I.getCopyExpr()));
1433  }
1434  }
1435  ShouldVisitChildren = false;
1436 })
1437 
1438 DEF_TRAVERSE_DECL(CapturedDecl, {
1439  TRY_TO(TraverseStmt(D->getBody()));
1440  ShouldVisitChildren = false;
1441 })
1442 
1443 DEF_TRAVERSE_DECL(EmptyDecl, {})
1444 
1445 DEF_TRAVERSE_DECL(LifetimeExtendedTemporaryDecl, {
1446  TRY_TO(TraverseStmt(D->getTemporaryExpr()));
1447 })
1448 
1449 DEF_TRAVERSE_DECL(FileScopeAsmDecl,
1450  { TRY_TO(TraverseStmt(D->getAsmString())); })
1451 
1452 DEF_TRAVERSE_DECL(ImportDecl, {})
1453 
1454 DEF_TRAVERSE_DECL(FriendDecl, {
1455  // Friend is either decl or a type.
1456  if (D->getFriendType())
1457  TRY_TO(TraverseTypeLoc(D->getFriendType()->getTypeLoc()));
1458  else
1459  TRY_TO(TraverseDecl(D->getFriendDecl()));
1460 })
1461 
1462 DEF_TRAVERSE_DECL(FriendTemplateDecl, {
1463  if (D->getFriendType())
1464  TRY_TO(TraverseTypeLoc(D->getFriendType()->getTypeLoc()));
1465  else
1466  TRY_TO(TraverseDecl(D->getFriendDecl()));
1467  for (unsigned I = 0, E = D->getNumTemplateParameters(); I < E; ++I) {
1468  TemplateParameterList *TPL = D->getTemplateParameterList(I);
1469  for (TemplateParameterList::iterator ITPL = TPL->begin(), ETPL = TPL->end();
1470  ITPL != ETPL; ++ITPL) {
1471  TRY_TO(TraverseDecl(*ITPL));
1472  }
1473  }
1474 })
1475 
1476 DEF_TRAVERSE_DECL(ClassScopeFunctionSpecializationDecl, {
1477  TRY_TO(TraverseDecl(D->getSpecialization()));
1478 
1479  if (D->hasExplicitTemplateArgs()) {
1480  TRY_TO(TraverseTemplateArgumentLocsHelper(
1481  D->getTemplateArgsAsWritten()->getTemplateArgs(),
1482  D->getTemplateArgsAsWritten()->NumTemplateArgs));
1483  }
1484 })
1485 
1486 DEF_TRAVERSE_DECL(LinkageSpecDecl, {})
1487 
1488 DEF_TRAVERSE_DECL(ExportDecl, {})
1489 
1490 DEF_TRAVERSE_DECL(ObjCPropertyImplDecl, {// FIXME: implement this
1491  })
1492 
1493 DEF_TRAVERSE_DECL(StaticAssertDecl, {
1494  TRY_TO(TraverseStmt(D->getAssertExpr()));
1495  TRY_TO(TraverseStmt(D->getMessage()));
1496 })
1497 
1498 DEF_TRAVERSE_DECL(TranslationUnitDecl, {
1499  // Code in an unnamed namespace shows up automatically in
1500  // decls_begin()/decls_end(). Thus we don't need to recurse on
1501  // D->getAnonymousNamespace().
1502 
1503  // If the traversal scope is set, then consider them to be the children of
1504  // the TUDecl, rather than traversing (and loading?) all top-level decls.
1505  auto Scope = D->getASTContext().getTraversalScope();
1506  bool HasLimitedScope =
1507  Scope.size() != 1 || !isa<TranslationUnitDecl>(Scope.front());
1508  if (HasLimitedScope) {
1509  ShouldVisitChildren = false; // we'll do that here instead
1510  for (auto *Child : Scope) {
1511  if (!canIgnoreChildDeclWhileTraversingDeclContext(Child))
1512  TRY_TO(TraverseDecl(Child));
1513  }
1514  }
1515 })
1516 
1517 DEF_TRAVERSE_DECL(PragmaCommentDecl, {})
1518 
1519 DEF_TRAVERSE_DECL(PragmaDetectMismatchDecl, {})
1520 
1521 DEF_TRAVERSE_DECL(ExternCContextDecl, {})
1522 
1523 DEF_TRAVERSE_DECL(NamespaceAliasDecl, {
1524  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1525 
1526  // We shouldn't traverse an aliased namespace, since it will be
1527  // defined (and, therefore, traversed) somewhere else.
1528  ShouldVisitChildren = false;
1529 })
1530 
1531 DEF_TRAVERSE_DECL(LabelDecl, {// There is no code in a LabelDecl.
1532  })
1533 
1535  NamespaceDecl,
1536  {// Code in an unnamed namespace shows up automatically in
1537  // decls_begin()/decls_end(). Thus we don't need to recurse on
1538  // D->getAnonymousNamespace().
1539  })
1540 
1541 DEF_TRAVERSE_DECL(ObjCCompatibleAliasDecl, {// FIXME: implement
1542  })
1543 
1544 DEF_TRAVERSE_DECL(ObjCCategoryDecl, {// FIXME: implement
1545  if (ObjCTypeParamList *typeParamList = D->getTypeParamList()) {
1546  for (auto typeParam : *typeParamList) {
1547  TRY_TO(TraverseObjCTypeParamDecl(typeParam));
1548  }
1549  }
1550 })
1551 
1552 DEF_TRAVERSE_DECL(ObjCCategoryImplDecl, {// FIXME: implement
1553  })
1554 
1555 DEF_TRAVERSE_DECL(ObjCImplementationDecl, {// FIXME: implement
1556  })
1557 
1558 DEF_TRAVERSE_DECL(ObjCInterfaceDecl, {// FIXME: implement
1559  if (ObjCTypeParamList *typeParamList = D->getTypeParamListAsWritten()) {
1560  for (auto typeParam : *typeParamList) {
1561  TRY_TO(TraverseObjCTypeParamDecl(typeParam));
1562  }
1563  }
1564 
1565  if (TypeSourceInfo *superTInfo = D->getSuperClassTInfo()) {
1566  TRY_TO(TraverseTypeLoc(superTInfo->getTypeLoc()));
1567  }
1568 })
1569 
1570 DEF_TRAVERSE_DECL(ObjCProtocolDecl, {// FIXME: implement
1571  })
1572 
1573 DEF_TRAVERSE_DECL(ObjCMethodDecl, {
1574  if (D->getReturnTypeSourceInfo()) {
1575  TRY_TO(TraverseTypeLoc(D->getReturnTypeSourceInfo()->getTypeLoc()));
1576  }
1577  for (ParmVarDecl *Parameter : D->parameters()) {
1578  TRY_TO(TraverseDecl(Parameter));
1579  }
1580  if (D->isThisDeclarationADefinition()) {
1581  TRY_TO(TraverseStmt(D->getBody()));
1582  }
1583  ShouldVisitChildren = false;
1584 })
1585 
1586 DEF_TRAVERSE_DECL(ObjCTypeParamDecl, {
1587  if (D->hasExplicitBound()) {
1588  TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1589  // We shouldn't traverse D->getTypeForDecl(); it's a result of
1590  // declaring the type alias, not something that was written in the
1591  // source.
1592  }
1593 })
1594 
1595 DEF_TRAVERSE_DECL(ObjCPropertyDecl, {
1596  if (D->getTypeSourceInfo())
1597  TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1598  else
1599  TRY_TO(TraverseType(D->getType()));
1600  ShouldVisitChildren = false;
1601 })
1602 
1603 DEF_TRAVERSE_DECL(UsingDecl, {
1604  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1605  TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
1606 })
1607 
1608 DEF_TRAVERSE_DECL(UsingEnumDecl, {})
1609 
1610 DEF_TRAVERSE_DECL(UsingPackDecl, {})
1611 
1612 DEF_TRAVERSE_DECL(UsingDirectiveDecl, {
1613  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1614 })
1615 
1616 DEF_TRAVERSE_DECL(UsingShadowDecl, {})
1617 
1618 DEF_TRAVERSE_DECL(ConstructorUsingShadowDecl, {})
1619 
1620 DEF_TRAVERSE_DECL(OMPThreadPrivateDecl, {
1621  for (auto *I : D->varlists()) {
1622  TRY_TO(TraverseStmt(I));
1623  }
1624  })
1625 
1626 DEF_TRAVERSE_DECL(OMPRequiresDecl, {
1627  for (auto *C : D->clauselists()) {
1628  TRY_TO(TraverseOMPClause(C));
1629  }
1630 })
1631 
1632 DEF_TRAVERSE_DECL(OMPDeclareReductionDecl, {
1633  TRY_TO(TraverseStmt(D->getCombiner()));
1634  if (auto *Initializer = D->getInitializer())
1635  TRY_TO(TraverseStmt(Initializer));
1636  TRY_TO(TraverseType(D->getType()));
1637  return true;
1638 })
1639 
1640 DEF_TRAVERSE_DECL(OMPDeclareMapperDecl, {
1641  for (auto *C : D->clauselists())
1642  TRY_TO(TraverseOMPClause(C));
1643  TRY_TO(TraverseType(D->getType()));
1644  return true;
1645 })
1646 
1647 DEF_TRAVERSE_DECL(OMPCapturedExprDecl, { TRY_TO(TraverseVarHelper(D)); })
1648 
1649 DEF_TRAVERSE_DECL(OMPAllocateDecl, {
1650  for (auto *I : D->varlists())
1651  TRY_TO(TraverseStmt(I));
1652  for (auto *C : D->clauselists())
1653  TRY_TO(TraverseOMPClause(C));
1654 })
1655 
1656 // A helper method for TemplateDecl's children.
1657 template <typename Derived>
1658 bool RecursiveASTVisitor<Derived>::TraverseTemplateParameterListHelper(
1659  TemplateParameterList *TPL) {
1660  if (TPL) {
1661  for (NamedDecl *D : *TPL) {
1662  TRY_TO(TraverseDecl(D));
1663  }
1664  if (Expr *RequiresClause = TPL->getRequiresClause()) {
1665  TRY_TO(TraverseStmt(RequiresClause));
1666  }
1667  }
1668  return true;
1669 }
1670 
1671 template <typename Derived>
1672 template <typename T>
1673 bool RecursiveASTVisitor<Derived>::TraverseDeclTemplateParameterLists(T *D) {
1674  for (unsigned i = 0; i < D->getNumTemplateParameterLists(); i++) {
1675  TemplateParameterList *TPL = D->getTemplateParameterList(i);
1676  TraverseTemplateParameterListHelper(TPL);
1677  }
1678  return true;
1679 }
1680 
1681 template <typename Derived>
1682 bool RecursiveASTVisitor<Derived>::TraverseTemplateInstantiations(
1683  ClassTemplateDecl *D) {
1684  for (auto *SD : D->specializations()) {
1685  for (auto *RD : SD->redecls()) {
1686  assert(!cast<CXXRecordDecl>(RD)->isInjectedClassName());
1687  switch (
1688  cast<ClassTemplateSpecializationDecl>(RD)->getSpecializationKind()) {
1689  // Visit the implicit instantiations with the requested pattern.
1690  case TSK_Undeclared:
1692  TRY_TO(TraverseDecl(RD));
1693  break;
1694 
1695  // We don't need to do anything on an explicit instantiation
1696  // or explicit specialization because there will be an explicit
1697  // node for it elsewhere.
1701  break;
1702  }
1703  }
1704  }
1705 
1706  return true;
1707 }
1708 
1709 template <typename Derived>
1710 bool RecursiveASTVisitor<Derived>::TraverseTemplateInstantiations(
1711  VarTemplateDecl *D) {
1712  for (auto *SD : D->specializations()) {
1713  for (auto *RD : SD->redecls()) {
1714  switch (
1715  cast<VarTemplateSpecializationDecl>(RD)->getSpecializationKind()) {
1716  case TSK_Undeclared:
1718  TRY_TO(TraverseDecl(RD));
1719  break;
1720 
1724  break;
1725  }
1726  }
1727  }
1728 
1729  return true;
1730 }
1731 
1732 // A helper method for traversing the instantiations of a
1733 // function while skipping its specializations.
1734 template <typename Derived>
1735 bool RecursiveASTVisitor<Derived>::TraverseTemplateInstantiations(
1736  FunctionTemplateDecl *D) {
1737  for (auto *FD : D->specializations()) {
1738  for (auto *RD : FD->redecls()) {
1739  switch (RD->getTemplateSpecializationKind()) {
1740  case TSK_Undeclared:
1742  // We don't know what kind of FunctionDecl this is.
1743  TRY_TO(TraverseDecl(RD));
1744  break;
1745 
1746  // FIXME: For now traverse explicit instantiations here. Change that
1747  // once they are represented as dedicated nodes in the AST.
1750  TRY_TO(TraverseDecl(RD));
1751  break;
1752 
1754  break;
1755  }
1756  }
1757  }
1758 
1759  return true;
1760 }
1761 
1762 // This macro unifies the traversal of class, variable and function
1763 // template declarations.
1764 #define DEF_TRAVERSE_TMPL_DECL(TMPLDECLKIND) \
1765  DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateDecl, { \
1766  TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \
1767  TRY_TO(TraverseDecl(D->getTemplatedDecl())); \
1768  \
1769  /* By default, we do not traverse the instantiations of \
1770  class templates since they do not appear in the user code. The \
1771  following code optionally traverses them. \
1772  \
1773  We only traverse the class instantiations when we see the canonical \
1774  declaration of the template, to ensure we only visit them once. */ \
1775  if (getDerived().shouldVisitTemplateInstantiations() && \
1776  D == D->getCanonicalDecl()) \
1777  TRY_TO(TraverseTemplateInstantiations(D)); \
1778  \
1779  /* Note that getInstantiatedFromMemberTemplate() is just a link \
1780  from a template instantiation back to the template from which \
1781  it was instantiated, and thus should not be traversed. */ \
1782  })
1783 
1786 DEF_TRAVERSE_TMPL_DECL(Function)
1787 
1788 DEF_TRAVERSE_DECL(TemplateTemplateParmDecl, {
1789  // D is the "T" in something like
1790  // template <template <typename> class T> class container { };
1791  TRY_TO(TraverseDecl(D->getTemplatedDecl()));
1792  if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
1793  TRY_TO(TraverseTemplateArgumentLoc(D->getDefaultArgument()));
1794  TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1795 })
1796 
1797 DEF_TRAVERSE_DECL(BuiltinTemplateDecl, {
1798  TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1799 })
1800 
1801 template <typename Derived>
1802 bool RecursiveASTVisitor<Derived>::TraverseTemplateTypeParamDeclConstraints(
1803  const TemplateTypeParmDecl *D) {
1804  if (const auto *TC = D->getTypeConstraint()) {
1805  if (Expr *IDC = TC->getImmediatelyDeclaredConstraint()) {
1806  TRY_TO(TraverseStmt(IDC));
1807  } else {
1808  // Avoid traversing the ConceptReference in the TypeCosntraint
1809  // if we have an immediately-declared-constraint, otherwise
1810  // we'll end up visiting the concept and the arguments in
1811  // the TC twice.
1812  TRY_TO(TraverseConceptReference(*TC));
1813  }
1814  }
1815  return true;
1816 }
1817 
1818 DEF_TRAVERSE_DECL(TemplateTypeParmDecl, {
1819  // D is the "T" in something like "template<typename T> class vector;"
1820  if (D->getTypeForDecl())
1821  TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
1822  TRY_TO(TraverseTemplateTypeParamDeclConstraints(D));
1823  if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
1824  TRY_TO(TraverseTypeLoc(D->getDefaultArgumentInfo()->getTypeLoc()));
1825 })
1826 
1827 DEF_TRAVERSE_DECL(TypedefDecl, {
1828  TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1829  // We shouldn't traverse D->getTypeForDecl(); it's a result of
1830  // declaring the typedef, not something that was written in the
1831  // source.
1832 })
1833 
1834 DEF_TRAVERSE_DECL(TypeAliasDecl, {
1835  TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1836  // We shouldn't traverse D->getTypeForDecl(); it's a result of
1837  // declaring the type alias, not something that was written in the
1838  // source.
1839 })
1840 
1841 DEF_TRAVERSE_DECL(TypeAliasTemplateDecl, {
1842  TRY_TO(TraverseDecl(D->getTemplatedDecl()));
1843  TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1844 })
1845 
1846 DEF_TRAVERSE_DECL(ConceptDecl, {
1847  TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1848  TRY_TO(TraverseStmt(D->getConstraintExpr()));
1849 })
1850 
1851 DEF_TRAVERSE_DECL(UnresolvedUsingTypenameDecl, {
1852  // A dependent using declaration which was marked with 'typename'.
1853  // template<class T> class A : public B<T> { using typename B<T>::foo; };
1854  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1855  // We shouldn't traverse D->getTypeForDecl(); it's a result of
1856  // declaring the type, not something that was written in the
1857  // source.
1858 })
1859 
1860 DEF_TRAVERSE_DECL(UnresolvedUsingIfExistsDecl, {})
1861 
1862 DEF_TRAVERSE_DECL(EnumDecl, {
1863  TRY_TO(TraverseDeclTemplateParameterLists(D));
1864 
1865  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1866  if (auto *TSI = D->getIntegerTypeSourceInfo())
1867  TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
1868  // The enumerators are already traversed by
1869  // decls_begin()/decls_end().
1870 })
1871 
1872 // Helper methods for RecordDecl and its children.
1873 template <typename Derived>
1874 bool RecursiveASTVisitor<Derived>::TraverseRecordHelper(RecordDecl *D) {
1875  // We shouldn't traverse D->getTypeForDecl(); it's a result of
1876  // declaring the type, not something that was written in the source.
1877 
1878  TRY_TO(TraverseDeclTemplateParameterLists(D));
1879  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1880  return true;
1881 }
1882 
1883 template <typename Derived>
1884 bool RecursiveASTVisitor<Derived>::TraverseCXXBaseSpecifier(
1885  const CXXBaseSpecifier &Base) {
1886  TRY_TO(TraverseTypeLoc(Base.getTypeSourceInfo()->getTypeLoc()));
1887  return true;
1888 }
1889 
1890 template <typename Derived>
1891 bool RecursiveASTVisitor<Derived>::TraverseCXXRecordHelper(CXXRecordDecl *D) {
1892  if (!TraverseRecordHelper(D))
1893  return false;
1894  if (D->isCompleteDefinition()) {
1895  for (const auto &I : D->bases()) {
1896  TRY_TO(TraverseCXXBaseSpecifier(I));
1897  }
1898  // We don't traverse the friends or the conversions, as they are
1899  // already in decls_begin()/decls_end().
1900  }
1901  return true;
1902 }
1903 
1904 DEF_TRAVERSE_DECL(RecordDecl, { TRY_TO(TraverseRecordHelper(D)); })
1905 
1906 DEF_TRAVERSE_DECL(CXXRecordDecl, { TRY_TO(TraverseCXXRecordHelper(D)); })
1907 
1908 #define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND) \
1909  DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateSpecializationDecl, { \
1910  /* For implicit instantiations ("set<int> x;"), we don't want to \
1911  recurse at all, since the instatiated template isn't written in \
1912  the source code anywhere. (Note the instatiated *type* -- \
1913  set<int> -- is written, and will still get a callback of \
1914  TemplateSpecializationType). For explicit instantiations \
1915  ("template set<int>;"), we do need a callback, since this \
1916  is the only callback that's made for this instantiation. \
1917  We use getTypeAsWritten() to distinguish. */ \
1918  if (TypeSourceInfo *TSI = D->getTypeAsWritten()) \
1919  TRY_TO(TraverseTypeLoc(TSI->getTypeLoc())); \
1920  \
1921  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc())); \
1922  if (!getDerived().shouldVisitTemplateInstantiations() && \
1923  D->getTemplateSpecializationKind() != TSK_ExplicitSpecialization) \
1924  /* Returning from here skips traversing the \
1925  declaration context of the *TemplateSpecializationDecl \
1926  (embedded in the DEF_TRAVERSE_DECL() macro) \
1927  which contains the instantiated members of the template. */ \
1928  return true; \
1929  })
1930 
1933 
1934 template <typename Derived>
1935 bool RecursiveASTVisitor<Derived>::TraverseTemplateArgumentLocsHelper(
1936  const TemplateArgumentLoc *TAL, unsigned Count) {
1937  for (unsigned I = 0; I < Count; ++I) {
1938  TRY_TO(TraverseTemplateArgumentLoc(TAL[I]));
1939  }
1940  return true;
1941 }
1942 
1943 #define DEF_TRAVERSE_TMPL_PART_SPEC_DECL(TMPLDECLKIND, DECLKIND) \
1944  DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplatePartialSpecializationDecl, { \
1945  /* The partial specialization. */ \
1946  if (TemplateParameterList *TPL = D->getTemplateParameters()) { \
1947  for (TemplateParameterList::iterator I = TPL->begin(), E = TPL->end(); \
1948  I != E; ++I) { \
1949  TRY_TO(TraverseDecl(*I)); \
1950  } \
1951  } \
1952  /* The args that remains unspecialized. */ \
1953  TRY_TO(TraverseTemplateArgumentLocsHelper( \
1954  D->getTemplateArgsAsWritten()->getTemplateArgs(), \
1955  D->getTemplateArgsAsWritten()->NumTemplateArgs)); \
1956  \
1957  /* Don't need the *TemplatePartialSpecializationHelper, even \
1958  though that's our parent class -- we already visit all the \
1959  template args here. */ \
1960  TRY_TO(Traverse##DECLKIND##Helper(D)); \
1961  \
1962  /* Instantiations will have been visited with the primary template. */ \
1963  })
1964 
1965 DEF_TRAVERSE_TMPL_PART_SPEC_DECL(Class, CXXRecord)
1967 
1968 DEF_TRAVERSE_DECL(EnumConstantDecl, { TRY_TO(TraverseStmt(D->getInitExpr())); })
1969 
1970 DEF_TRAVERSE_DECL(UnresolvedUsingValueDecl, {
1971  // Like UnresolvedUsingTypenameDecl, but without the 'typename':
1972  // template <class T> Class A : public Base<T> { using Base<T>::foo; };
1973  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1974  TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
1975 })
1976 
1977 DEF_TRAVERSE_DECL(IndirectFieldDecl, {})
1978 
1979 template <typename Derived>
1980 bool RecursiveASTVisitor<Derived>::TraverseDeclaratorHelper(DeclaratorDecl *D) {
1981  TRY_TO(TraverseDeclTemplateParameterLists(D));
1982  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1983  if (D->getTypeSourceInfo())
1984  TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1985  else
1986  TRY_TO(TraverseType(D->getType()));
1987  return true;
1988 }
1989 
1990 DEF_TRAVERSE_DECL(DecompositionDecl, {
1991  TRY_TO(TraverseVarHelper(D));
1992  for (auto *Binding : D->bindings()) {
1993  TRY_TO(TraverseDecl(Binding));
1994  }
1995 })
1996 
1997 DEF_TRAVERSE_DECL(BindingDecl, {
1998  if (getDerived().shouldVisitImplicitCode())
1999  TRY_TO(TraverseStmt(D->getBinding()));
2000 })
2001 
2002 DEF_TRAVERSE_DECL(MSPropertyDecl, { TRY_TO(TraverseDeclaratorHelper(D)); })
2003 
2004 DEF_TRAVERSE_DECL(MSGuidDecl, {})
2005 
2006 DEF_TRAVERSE_DECL(TemplateParamObjectDecl, {})
2007 
2008 DEF_TRAVERSE_DECL(FieldDecl, {
2009  TRY_TO(TraverseDeclaratorHelper(D));
2010  if (D->isBitField())
2011  TRY_TO(TraverseStmt(D->getBitWidth()));
2012  else if (D->hasInClassInitializer())
2013  TRY_TO(TraverseStmt(D->getInClassInitializer()));
2014 })
2015 
2016 DEF_TRAVERSE_DECL(ObjCAtDefsFieldDecl, {
2017  TRY_TO(TraverseDeclaratorHelper(D));
2018  if (D->isBitField())
2019  TRY_TO(TraverseStmt(D->getBitWidth()));
2020  // FIXME: implement the rest.
2021 })
2022 
2023 DEF_TRAVERSE_DECL(ObjCIvarDecl, {
2024  TRY_TO(TraverseDeclaratorHelper(D));
2025  if (D->isBitField())
2026  TRY_TO(TraverseStmt(D->getBitWidth()));
2027  // FIXME: implement the rest.
2028 })
2029 
2030 template <typename Derived>
2031 bool RecursiveASTVisitor<Derived>::TraverseFunctionHelper(FunctionDecl *D) {
2032  TRY_TO(TraverseDeclTemplateParameterLists(D));
2033  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
2034  TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
2035 
2036  // If we're an explicit template specialization, iterate over the
2037  // template args that were explicitly specified. If we were doing
2038  // this in typing order, we'd do it between the return type and
2039  // the function args, but both are handled by the FunctionTypeLoc
2040  // above, so we have to choose one side. I've decided to do before.
2041  if (const FunctionTemplateSpecializationInfo *FTSI =
2042  D->getTemplateSpecializationInfo()) {
2043  if (FTSI->getTemplateSpecializationKind() != TSK_Undeclared &&
2044  FTSI->getTemplateSpecializationKind() != TSK_ImplicitInstantiation) {
2045  // A specialization might not have explicit template arguments if it has
2046  // a templated return type and concrete arguments.
2047  if (const ASTTemplateArgumentListInfo *TALI =
2048  FTSI->TemplateArgumentsAsWritten) {
2049  TRY_TO(TraverseTemplateArgumentLocsHelper(TALI->getTemplateArgs(),
2050  TALI->NumTemplateArgs));
2051  }
2052  }
2053  }
2054 
2055  // Visit the function type itself, which can be either
2056  // FunctionNoProtoType or FunctionProtoType, or a typedef. This
2057  // also covers the return type and the function parameters,
2058  // including exception specifications.
2059  if (TypeSourceInfo *TSI = D->getTypeSourceInfo()) {
2060  TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
2061  } else if (getDerived().shouldVisitImplicitCode()) {
2062  // Visit parameter variable declarations of the implicit function
2063  // if the traverser is visiting implicit code. Parameter variable
2064  // declarations do not have valid TypeSourceInfo, so to visit them
2065  // we need to traverse the declarations explicitly.
2066  for (ParmVarDecl *Parameter : D->parameters()) {
2067  TRY_TO(TraverseDecl(Parameter));
2068  }
2069  }
2070 
2071  // Visit the trailing requires clause, if any.
2072  if (Expr *TrailingRequiresClause = D->getTrailingRequiresClause()) {
2073  TRY_TO(TraverseStmt(TrailingRequiresClause));
2074  }
2075 
2076  if (CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(D)) {
2077  // Constructor initializers.
2078  for (auto *I : Ctor->inits()) {
2079  if (I->isWritten() || getDerived().shouldVisitImplicitCode())
2080  TRY_TO(TraverseConstructorInitializer(I));
2081  }
2082  }
2083 
2084  bool VisitBody =
2085  D->isThisDeclarationADefinition() &&
2086  // Don't visit the function body if the function definition is generated
2087  // by clang.
2088  (!D->isDefaulted() || getDerived().shouldVisitImplicitCode());
2089 
2090  if (const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
2091  if (const CXXRecordDecl *RD = MD->getParent()) {
2092  if (RD->isLambda() &&
2093  declaresSameEntity(RD->getLambdaCallOperator(), MD)) {
2094  VisitBody = VisitBody && getDerived().shouldVisitLambdaBody();
2095  }
2096  }
2097  }
2098 
2099  if (VisitBody) {
2100  TRY_TO(TraverseStmt(D->getBody()));
2101  // Body may contain using declarations whose shadows are parented to the
2102  // FunctionDecl itself.
2103  for (auto *Child : D->decls()) {
2104  if (isa<UsingShadowDecl>(Child))
2105  TRY_TO(TraverseDecl(Child));
2106  }
2107  }
2108  return true;
2109 }
2110 
2111 DEF_TRAVERSE_DECL(FunctionDecl, {
2112  // We skip decls_begin/decls_end, which are already covered by
2113  // TraverseFunctionHelper().
2114  ShouldVisitChildren = false;
2115  ReturnValue = TraverseFunctionHelper(D);
2116 })
2117 
2118 DEF_TRAVERSE_DECL(CXXDeductionGuideDecl, {
2119  // We skip decls_begin/decls_end, which are already covered by
2120  // TraverseFunctionHelper().
2121  ShouldVisitChildren = false;
2122  ReturnValue = TraverseFunctionHelper(D);
2123 })
2124 
2125 DEF_TRAVERSE_DECL(CXXMethodDecl, {
2126  // We skip decls_begin/decls_end, which are already covered by
2127  // TraverseFunctionHelper().
2128  ShouldVisitChildren = false;
2129  ReturnValue = TraverseFunctionHelper(D);
2130 })
2131 
2132 DEF_TRAVERSE_DECL(CXXConstructorDecl, {
2133  // We skip decls_begin/decls_end, which are already covered by
2134  // TraverseFunctionHelper().
2135  ShouldVisitChildren = false;
2136  ReturnValue = TraverseFunctionHelper(D);
2137 })
2138 
2139 // CXXConversionDecl is the declaration of a type conversion operator.
2140 // It's not a cast expression.
2141 DEF_TRAVERSE_DECL(CXXConversionDecl, {
2142  // We skip decls_begin/decls_end, which are already covered by
2143  // TraverseFunctionHelper().
2144  ShouldVisitChildren = false;
2145  ReturnValue = TraverseFunctionHelper(D);
2146 })
2147 
2148 DEF_TRAVERSE_DECL(CXXDestructorDecl, {
2149  // We skip decls_begin/decls_end, which are already covered by
2150  // TraverseFunctionHelper().
2151  ShouldVisitChildren = false;
2152  ReturnValue = TraverseFunctionHelper(D);
2153 })
2154 
2155 template <typename Derived>
2156 bool RecursiveASTVisitor<Derived>::TraverseVarHelper(VarDecl *D) {
2157  TRY_TO(TraverseDeclaratorHelper(D));
2158  // Default params are taken care of when we traverse the ParmVarDecl.
2159  if (!isa<ParmVarDecl>(D) &&
2160  (!D->isCXXForRangeDecl() || getDerived().shouldVisitImplicitCode()))
2161  TRY_TO(TraverseStmt(D->getInit()));
2162  return true;
2163 }
2164 
2165 DEF_TRAVERSE_DECL(VarDecl, { TRY_TO(TraverseVarHelper(D)); })
2166 
2167 DEF_TRAVERSE_DECL(ImplicitParamDecl, { TRY_TO(TraverseVarHelper(D)); })
2168 
2169 DEF_TRAVERSE_DECL(NonTypeTemplateParmDecl, {
2170  // A non-type template parameter, e.g. "S" in template<int S> class Foo ...
2171  TRY_TO(TraverseDeclaratorHelper(D));
2172  if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
2173  TRY_TO(TraverseStmt(D->getDefaultArgument()));
2174 })
2175 
2176 DEF_TRAVERSE_DECL(ParmVarDecl, {
2177  TRY_TO(TraverseVarHelper(D));
2178 
2179  if (D->hasDefaultArg() && D->hasUninstantiatedDefaultArg() &&
2180  !D->hasUnparsedDefaultArg())
2181  TRY_TO(TraverseStmt(D->getUninstantiatedDefaultArg()));
2182 
2183  if (D->hasDefaultArg() && !D->hasUninstantiatedDefaultArg() &&
2184  !D->hasUnparsedDefaultArg())
2185  TRY_TO(TraverseStmt(D->getDefaultArg()));
2186 })
2187 
2188 DEF_TRAVERSE_DECL(RequiresExprBodyDecl, {})
2189 
2190 #undef DEF_TRAVERSE_DECL
2191 
2192 // ----------------- Stmt traversal -----------------
2193 //
2194 // For stmts, we automate (in the DEF_TRAVERSE_STMT macro) iterating
2195 // over the children defined in children() (every stmt defines these,
2196 // though sometimes the range is empty). Each individual Traverse*
2197 // method only needs to worry about children other than those. To see
2198 // what children() does for a given class, see, e.g.,
2199 // http://clang.llvm.org/doxygen/Stmt_8cpp_source.html
2200 
2201 // This macro makes available a variable S, the passed-in stmt.
2202 #define DEF_TRAVERSE_STMT(STMT, CODE) \
2203  template <typename Derived> \
2204  bool RecursiveASTVisitor<Derived>::Traverse##STMT( \
2205  STMT *S, DataRecursionQueue *Queue) { \
2206  bool ShouldVisitChildren = true; \
2207  bool ReturnValue = true; \
2208  if (!getDerived().shouldTraversePostOrder()) \
2209  TRY_TO(WalkUpFrom##STMT(S)); \
2210  { CODE; } \
2211  if (ShouldVisitChildren) { \
2212  for (Stmt * SubStmt : getDerived().getStmtChildren(S)) { \
2213  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(SubStmt); \
2214  } \
2215  } \
2216  /* Call WalkUpFrom if TRY_TO_TRAVERSE_OR_ENQUEUE_STMT has traversed the \
2217  * children already. If TRY_TO_TRAVERSE_OR_ENQUEUE_STMT only enqueued the \
2218  * children, PostVisitStmt will call WalkUpFrom after we are done visiting \
2219  * children. */ \
2220  if (!Queue && ReturnValue && getDerived().shouldTraversePostOrder()) { \
2221  TRY_TO(WalkUpFrom##STMT(S)); \
2222  } \
2223  return ReturnValue; \
2224  }
2225 
2226 DEF_TRAVERSE_STMT(GCCAsmStmt, {
2227  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getAsmString());
2228  for (unsigned I = 0, E = S->getNumInputs(); I < E; ++I) {
2229  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getInputConstraintLiteral(I));
2230  }
2231  for (unsigned I = 0, E = S->getNumOutputs(); I < E; ++I) {
2232  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOutputConstraintLiteral(I));
2233  }
2234  for (unsigned I = 0, E = S->getNumClobbers(); I < E; ++I) {
2235  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getClobberStringLiteral(I));
2236  }
2237  // children() iterates over inputExpr and outputExpr.
2238 })
2239 
2241  MSAsmStmt,
2242  {// FIXME: MS Asm doesn't currently parse Constraints, Clobbers, etc. Once
2243  // added this needs to be implemented.
2244  })
2245 
2246 DEF_TRAVERSE_STMT(CXXCatchStmt, {
2247  TRY_TO(TraverseDecl(S->getExceptionDecl()));
2248  // children() iterates over the handler block.
2249 })
2250 
2251 DEF_TRAVERSE_STMT(DeclStmt, {
2252  for (auto *I : S->decls()) {
2253  TRY_TO(TraverseDecl(I));
2254  }
2255  // Suppress the default iteration over children() by
2256  // returning. Here's why: A DeclStmt looks like 'type var [=
2257  // initializer]'. The decls above already traverse over the
2258  // initializers, so we don't have to do it again (which
2259  // children() would do).
2260  ShouldVisitChildren = false;
2261 })
2262 
2263 // These non-expr stmts (most of them), do not need any action except
2264 // iterating over the children.
2265 DEF_TRAVERSE_STMT(BreakStmt, {})
2266 DEF_TRAVERSE_STMT(CXXTryStmt, {})
2267 DEF_TRAVERSE_STMT(CaseStmt, {})
2268 DEF_TRAVERSE_STMT(CompoundStmt, {})
2269 DEF_TRAVERSE_STMT(ContinueStmt, {})
2270 DEF_TRAVERSE_STMT(DefaultStmt, {})
2271 DEF_TRAVERSE_STMT(DoStmt, {})
2272 DEF_TRAVERSE_STMT(ForStmt, {})
2273 DEF_TRAVERSE_STMT(GotoStmt, {})
2274 DEF_TRAVERSE_STMT(IfStmt, {})
2275 DEF_TRAVERSE_STMT(IndirectGotoStmt, {})
2276 DEF_TRAVERSE_STMT(LabelStmt, {})
2277 DEF_TRAVERSE_STMT(AttributedStmt, {})
2278 DEF_TRAVERSE_STMT(NullStmt, {})
2279 DEF_TRAVERSE_STMT(ObjCAtCatchStmt, {})
2280 DEF_TRAVERSE_STMT(ObjCAtFinallyStmt, {})
2281 DEF_TRAVERSE_STMT(ObjCAtSynchronizedStmt, {})
2282 DEF_TRAVERSE_STMT(ObjCAtThrowStmt, {})
2283 DEF_TRAVERSE_STMT(ObjCAtTryStmt, {})
2284 DEF_TRAVERSE_STMT(ObjCForCollectionStmt, {})
2285 DEF_TRAVERSE_STMT(ObjCAutoreleasePoolStmt, {})
2286 
2287 DEF_TRAVERSE_STMT(CXXForRangeStmt, {
2288  if (!getDerived().shouldVisitImplicitCode()) {
2289  if (S->getInit())
2290  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getInit());
2291  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLoopVarStmt());
2292  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRangeInit());
2293  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getBody());
2294  // Visit everything else only if shouldVisitImplicitCode().
2295  ShouldVisitChildren = false;
2296  }
2297 })
2298 
2299 DEF_TRAVERSE_STMT(MSDependentExistsStmt, {
2300  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2301  TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2302 })
2303 
2304 DEF_TRAVERSE_STMT(ReturnStmt, {})
2305 DEF_TRAVERSE_STMT(SwitchStmt, {})
2306 DEF_TRAVERSE_STMT(WhileStmt, {})
2307 
2308 DEF_TRAVERSE_STMT(ConstantExpr, {})
2309 
2310 DEF_TRAVERSE_STMT(CXXDependentScopeMemberExpr, {
2311  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2312  TRY_TO(TraverseDeclarationNameInfo(S->getMemberNameInfo()));
2313  if (S->hasExplicitTemplateArgs()) {
2314  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2315  S->getNumTemplateArgs()));
2316  }
2317 })
2318 
2319 DEF_TRAVERSE_STMT(DeclRefExpr, {
2320  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2321  TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2322  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2323  S->getNumTemplateArgs()));
2324 })
2325 
2326 DEF_TRAVERSE_STMT(DependentScopeDeclRefExpr, {
2327  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2328  TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2329  if (S->hasExplicitTemplateArgs()) {
2330  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2331  S->getNumTemplateArgs()));
2332  }
2333 })
2334 
2335 DEF_TRAVERSE_STMT(MemberExpr, {
2336  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2337  TRY_TO(TraverseDeclarationNameInfo(S->getMemberNameInfo()));
2338  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2339  S->getNumTemplateArgs()));
2340 })
2341 
2343  ImplicitCastExpr,
2344  {// We don't traverse the cast type, as it's not written in the
2345  // source code.
2346  })
2347 
2348 DEF_TRAVERSE_STMT(CStyleCastExpr, {
2349  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2350 })
2351 
2352 DEF_TRAVERSE_STMT(CXXFunctionalCastExpr, {
2353  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2354 })
2355 
2356 DEF_TRAVERSE_STMT(CXXAddrspaceCastExpr, {
2357  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2358 })
2359 
2360 DEF_TRAVERSE_STMT(CXXConstCastExpr, {
2361  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2362 })
2363 
2364 DEF_TRAVERSE_STMT(CXXDynamicCastExpr, {
2365  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2366 })
2367 
2368 DEF_TRAVERSE_STMT(CXXReinterpretCastExpr, {
2369  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2370 })
2371 
2372 DEF_TRAVERSE_STMT(CXXStaticCastExpr, {
2373  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2374 })
2375 
2376 DEF_TRAVERSE_STMT(BuiltinBitCastExpr, {
2377  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2378 })
2379 
2380 template <typename Derived>
2381 bool RecursiveASTVisitor<Derived>::TraverseSynOrSemInitListExpr(
2382  InitListExpr *S, DataRecursionQueue *Queue) {
2383  if (S) {
2384  // Skip this if we traverse postorder. We will visit it later
2385  // in PostVisitStmt.
2386  if (!getDerived().shouldTraversePostOrder())
2387  TRY_TO(WalkUpFromInitListExpr(S));
2388 
2389  // All we need are the default actions. FIXME: use a helper function.
2390  for (Stmt *SubStmt : S->children()) {
2392  }
2393 
2394  if (!Queue && getDerived().shouldTraversePostOrder())
2395  TRY_TO(WalkUpFromInitListExpr(S));
2396  }
2397  return true;
2398 }
2399 
2400 template<typename Derived>
2401 bool RecursiveASTVisitor<Derived>::TraverseConceptReference(
2402  const ConceptReference &C) {
2403  TRY_TO(TraverseNestedNameSpecifierLoc(C.getNestedNameSpecifierLoc()));
2404  TRY_TO(TraverseDeclarationNameInfo(C.getConceptNameInfo()));
2405  if (C.hasExplicitTemplateArgs())
2406  TRY_TO(TraverseTemplateArgumentLocsHelper(
2407  C.getTemplateArgsAsWritten()->getTemplateArgs(),
2408  C.getTemplateArgsAsWritten()->NumTemplateArgs));
2409  return true;
2410 }
2411 
2412 // If shouldVisitImplicitCode() returns false, this method traverses only the
2413 // syntactic form of InitListExpr.
2414 // If shouldVisitImplicitCode() return true, this method is called once for
2415 // each pair of syntactic and semantic InitListExpr, and it traverses the
2416 // subtrees defined by the two forms. This may cause some of the children to be
2417 // visited twice, if they appear both in the syntactic and the semantic form.
2418 //
2419 // There is no guarantee about which form \p S takes when this method is called.
2420 template <typename Derived>
2421 bool RecursiveASTVisitor<Derived>::TraverseInitListExpr(
2422  InitListExpr *S, DataRecursionQueue *Queue) {
2423  if (S->isSemanticForm() && S->isSyntacticForm()) {
2424  // `S` does not have alternative forms, traverse only once.
2425  TRY_TO(TraverseSynOrSemInitListExpr(S, Queue));
2426  return true;
2427  }
2428  TRY_TO(TraverseSynOrSemInitListExpr(
2429  S->isSemanticForm() ? S->getSyntacticForm() : S, Queue));
2430  if (getDerived().shouldVisitImplicitCode()) {
2431  // Only visit the semantic form if the clients are interested in implicit
2432  // compiler-generated.
2433  TRY_TO(TraverseSynOrSemInitListExpr(
2434  S->isSemanticForm() ? S : S->getSemanticForm(), Queue));
2435  }
2436  return true;
2437 }
2438 
2439 // GenericSelectionExpr is a special case because the types and expressions
2440 // are interleaved. We also need to watch out for null types (default
2441 // generic associations).
2442 DEF_TRAVERSE_STMT(GenericSelectionExpr, {
2443  TRY_TO(TraverseStmt(S->getControllingExpr()));
2444  for (const GenericSelectionExpr::Association Assoc : S->associations()) {
2445  if (TypeSourceInfo *TSI = Assoc.getTypeSourceInfo())
2446  TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
2447  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(Assoc.getAssociationExpr());
2448  }
2449  ShouldVisitChildren = false;
2450 })
2451 
2452 // PseudoObjectExpr is a special case because of the weirdness with
2453 // syntactic expressions and opaque values.
2454 DEF_TRAVERSE_STMT(PseudoObjectExpr, {
2455  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSyntacticForm());
2456  for (PseudoObjectExpr::semantics_iterator i = S->semantics_begin(),
2457  e = S->semantics_end();
2458  i != e; ++i) {
2459  Expr *sub = *i;
2460  if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(sub))
2461  sub = OVE->getSourceExpr();
2463  }
2464  ShouldVisitChildren = false;
2465 })
2466 
2467 DEF_TRAVERSE_STMT(CXXScalarValueInitExpr, {
2468  // This is called for code like 'return T()' where T is a built-in
2469  // (i.e. non-class) type.
2470  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2471 })
2472 
2473 DEF_TRAVERSE_STMT(CXXNewExpr, {
2474  // The child-iterator will pick up the other arguments.
2475  TRY_TO(TraverseTypeLoc(S->getAllocatedTypeSourceInfo()->getTypeLoc()));
2476 })
2477 
2478 DEF_TRAVERSE_STMT(OffsetOfExpr, {
2479  // The child-iterator will pick up the expression representing
2480  // the field.
2481  // FIMXE: for code like offsetof(Foo, a.b.c), should we get
2482  // making a MemberExpr callbacks for Foo.a, Foo.a.b, and Foo.a.b.c?
2483  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2484 })
2485 
2486 DEF_TRAVERSE_STMT(UnaryExprOrTypeTraitExpr, {
2487  // The child-iterator will pick up the arg if it's an expression,
2488  // but not if it's a type.
2489  if (S->isArgumentType())
2490  TRY_TO(TraverseTypeLoc(S->getArgumentTypeInfo()->getTypeLoc()));
2491 })
2492 
2493 DEF_TRAVERSE_STMT(CXXTypeidExpr, {
2494  // The child-iterator will pick up the arg if it's an expression,
2495  // but not if it's a type.
2496  if (S->isTypeOperand())
2497  TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
2498 })
2499 
2500 DEF_TRAVERSE_STMT(MSPropertyRefExpr, {
2501  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2502 })
2503 
2504 DEF_TRAVERSE_STMT(MSPropertySubscriptExpr, {})
2505 
2506 DEF_TRAVERSE_STMT(CXXUuidofExpr, {
2507  // The child-iterator will pick up the arg if it's an expression,
2508  // but not if it's a type.
2509  if (S->isTypeOperand())
2510  TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
2511 })
2512 
2513 DEF_TRAVERSE_STMT(TypeTraitExpr, {
2514  for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
2515  TRY_TO(TraverseTypeLoc(S->getArg(I)->getTypeLoc()));
2516 })
2517 
2518 DEF_TRAVERSE_STMT(ArrayTypeTraitExpr, {
2519  TRY_TO(TraverseTypeLoc(S->getQueriedTypeSourceInfo()->getTypeLoc()));
2520 })
2521 
2522 DEF_TRAVERSE_STMT(ExpressionTraitExpr,
2523  { TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getQueriedExpression()); })
2524 
2525 DEF_TRAVERSE_STMT(VAArgExpr, {
2526  // The child-iterator will pick up the expression argument.
2527  TRY_TO(TraverseTypeLoc(S->getWrittenTypeInfo()->getTypeLoc()));
2528 })
2529 
2530 DEF_TRAVERSE_STMT(CXXTemporaryObjectExpr, {
2531  // This is called for code like 'return T()' where T is a class type.
2532  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2533 })
2534 
2535 // Walk only the visible parts of lambda expressions.
2536 DEF_TRAVERSE_STMT(LambdaExpr, {
2537  // Visit the capture list.
2538  for (unsigned I = 0, N = S->capture_size(); I != N; ++I) {
2539  const LambdaCapture *C = S->capture_begin() + I;
2540  if (C->isExplicit() || getDerived().shouldVisitImplicitCode()) {
2541  TRY_TO(TraverseLambdaCapture(S, C, S->capture_init_begin()[I]));
2542  }
2543  }
2544 
2545  if (getDerived().shouldVisitImplicitCode()) {
2546  // The implicit model is simple: everything else is in the lambda class.
2547  TRY_TO(TraverseDecl(S->getLambdaClass()));
2548  } else {
2549  // We need to poke around to find the bits that might be explicitly written.
2550  TypeLoc TL = S->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
2551  FunctionProtoTypeLoc Proto = TL.getAsAdjusted<FunctionProtoTypeLoc>();
2552 
2553  TRY_TO(TraverseTemplateParameterListHelper(S->getTemplateParameterList()));
2554  if (S->hasExplicitParameters()) {
2555  // Visit parameters.
2556  for (unsigned I = 0, N = Proto.getNumParams(); I != N; ++I)
2557  TRY_TO(TraverseDecl(Proto.getParam(I)));
2558  }
2559 
2560  auto *T = Proto.getTypePtr();
2561  for (const auto &E : T->exceptions())
2562  TRY_TO(TraverseType(E));
2563 
2564  if (Expr *NE = T->getNoexceptExpr())
2566 
2567  if (S->hasExplicitResultType())
2568  TRY_TO(TraverseTypeLoc(Proto.getReturnLoc()));
2569  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getTrailingRequiresClause());
2570 
2571  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getBody());
2572  }
2573  ShouldVisitChildren = false;
2574 })
2575 
2576 DEF_TRAVERSE_STMT(CXXUnresolvedConstructExpr, {
2577  // This is called for code like 'T()', where T is a template argument.
2578  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2579 })
2580 
2581 // These expressions all might take explicit template arguments.
2582 // We traverse those if so. FIXME: implement these.
2583 DEF_TRAVERSE_STMT(CXXConstructExpr, {})
2584 DEF_TRAVERSE_STMT(CallExpr, {})
2585 DEF_TRAVERSE_STMT(CXXMemberCallExpr, {})
2586 
2587 // These exprs (most of them), do not need any action except iterating
2588 // over the children.
2589 DEF_TRAVERSE_STMT(AddrLabelExpr, {})
2590 DEF_TRAVERSE_STMT(ArraySubscriptExpr, {})
2591 DEF_TRAVERSE_STMT(MatrixSubscriptExpr, {})
2592 DEF_TRAVERSE_STMT(OMPArraySectionExpr, {})
2593 DEF_TRAVERSE_STMT(OMPArrayShapingExpr, {})
2594 DEF_TRAVERSE_STMT(OMPIteratorExpr, {})
2595 
2596 DEF_TRAVERSE_STMT(BlockExpr, {
2597  TRY_TO(TraverseDecl(S->getBlockDecl()));
2598  return true; // no child statements to loop through.
2599 })
2600 
2601 DEF_TRAVERSE_STMT(ChooseExpr, {})
2602 DEF_TRAVERSE_STMT(CompoundLiteralExpr, {
2603  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2604 })
2605 DEF_TRAVERSE_STMT(CXXBindTemporaryExpr, {})
2606 DEF_TRAVERSE_STMT(CXXBoolLiteralExpr, {})
2607 
2608 DEF_TRAVERSE_STMT(CXXDefaultArgExpr, {
2609  if (getDerived().shouldVisitImplicitCode())
2610  TRY_TO(TraverseStmt(S->getExpr()));
2611 })
2612 
2613 DEF_TRAVERSE_STMT(CXXDefaultInitExpr, {})
2614 DEF_TRAVERSE_STMT(CXXDeleteExpr, {})
2615 DEF_TRAVERSE_STMT(ExprWithCleanups, {})
2616 DEF_TRAVERSE_STMT(CXXInheritedCtorInitExpr, {})
2617 DEF_TRAVERSE_STMT(CXXNullPtrLiteralExpr, {})
2618 DEF_TRAVERSE_STMT(CXXStdInitializerListExpr, {})
2619 
2620 DEF_TRAVERSE_STMT(CXXPseudoDestructorExpr, {
2621  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2622  if (TypeSourceInfo *ScopeInfo = S->getScopeTypeInfo())
2623  TRY_TO(TraverseTypeLoc(ScopeInfo->getTypeLoc()));
2624  if (TypeSourceInfo *DestroyedTypeInfo = S->getDestroyedTypeInfo())
2625  TRY_TO(TraverseTypeLoc(DestroyedTypeInfo->getTypeLoc()));
2626 })
2627 
2628 DEF_TRAVERSE_STMT(CXXThisExpr, {})
2629 DEF_TRAVERSE_STMT(CXXThrowExpr, {})
2630 DEF_TRAVERSE_STMT(UserDefinedLiteral, {})
2631 DEF_TRAVERSE_STMT(DesignatedInitExpr, {})
2632 DEF_TRAVERSE_STMT(DesignatedInitUpdateExpr, {})
2633 DEF_TRAVERSE_STMT(ExtVectorElementExpr, {})
2634 DEF_TRAVERSE_STMT(GNUNullExpr, {})
2635 DEF_TRAVERSE_STMT(ImplicitValueInitExpr, {})
2636 DEF_TRAVERSE_STMT(NoInitExpr, {})
2637 DEF_TRAVERSE_STMT(ArrayInitLoopExpr, {
2638  // FIXME: The source expression of the OVE should be listed as
2639  // a child of the ArrayInitLoopExpr.
2640  if (OpaqueValueExpr *OVE = S->getCommonExpr())
2641  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(OVE->getSourceExpr());
2642 })
2643 DEF_TRAVERSE_STMT(ArrayInitIndexExpr, {})
2644 DEF_TRAVERSE_STMT(ObjCBoolLiteralExpr, {})
2645 
2646 DEF_TRAVERSE_STMT(ObjCEncodeExpr, {
2647  if (TypeSourceInfo *TInfo = S->getEncodedTypeSourceInfo())
2648  TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
2649 })
2650 
2651 DEF_TRAVERSE_STMT(ObjCIsaExpr, {})
2652 DEF_TRAVERSE_STMT(ObjCIvarRefExpr, {})
2653 
2654 DEF_TRAVERSE_STMT(ObjCMessageExpr, {
2655  if (TypeSourceInfo *TInfo = S->getClassReceiverTypeInfo())
2656  TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
2657 })
2658 
2659 DEF_TRAVERSE_STMT(ObjCPropertyRefExpr, {
2660  if (S->isClassReceiver()) {
2661  ObjCInterfaceDecl *IDecl = S->getClassReceiver();
2662  QualType Type = IDecl->getASTContext().getObjCInterfaceType(IDecl);
2663  ObjCInterfaceLocInfo Data;
2664  Data.NameLoc = S->getReceiverLocation();
2665  Data.NameEndLoc = Data.NameLoc;
2666  TRY_TO(TraverseTypeLoc(TypeLoc(Type, &Data)));
2667  }
2668 })
2669 DEF_TRAVERSE_STMT(ObjCSubscriptRefExpr, {})
2670 DEF_TRAVERSE_STMT(ObjCProtocolExpr, {})
2671 DEF_TRAVERSE_STMT(ObjCSelectorExpr, {})
2672 DEF_TRAVERSE_STMT(ObjCIndirectCopyRestoreExpr, {})
2673 
2674 DEF_TRAVERSE_STMT(ObjCBridgedCastExpr, {
2675  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2676 })
2677 
2678 DEF_TRAVERSE_STMT(ObjCAvailabilityCheckExpr, {})
2679 DEF_TRAVERSE_STMT(ParenExpr, {})
2680 DEF_TRAVERSE_STMT(ParenListExpr, {})
2681 DEF_TRAVERSE_STMT(SYCLUniqueStableNameExpr, {
2682  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2683 })
2684 DEF_TRAVERSE_STMT(PredefinedExpr, {})
2685 DEF_TRAVERSE_STMT(ShuffleVectorExpr, {})
2686 DEF_TRAVERSE_STMT(ConvertVectorExpr, {})
2687 DEF_TRAVERSE_STMT(StmtExpr, {})
2688 DEF_TRAVERSE_STMT(SourceLocExpr, {})
2689 
2690 DEF_TRAVERSE_STMT(UnresolvedLookupExpr, {
2691  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2692  if (S->hasExplicitTemplateArgs()) {
2693  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2694  S->getNumTemplateArgs()));
2695  }
2696 })
2697 
2698 DEF_TRAVERSE_STMT(UnresolvedMemberExpr, {
2699  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2700  if (S->hasExplicitTemplateArgs()) {
2701  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2702  S->getNumTemplateArgs()));
2703  }
2704 })
2705 
2706 DEF_TRAVERSE_STMT(SEHTryStmt, {})
2707 DEF_TRAVERSE_STMT(SEHExceptStmt, {})
2708 DEF_TRAVERSE_STMT(SEHFinallyStmt, {})
2709 DEF_TRAVERSE_STMT(SEHLeaveStmt, {})
2710 DEF_TRAVERSE_STMT(CapturedStmt, { TRY_TO(TraverseDecl(S->getCapturedDecl())); })
2711 
2712 DEF_TRAVERSE_STMT(CXXOperatorCallExpr, {})
2713 DEF_TRAVERSE_STMT(CXXRewrittenBinaryOperator, {
2714  if (!getDerived().shouldVisitImplicitCode()) {
2715  CXXRewrittenBinaryOperator::DecomposedForm Decomposed =
2716  S->getDecomposedForm();
2717  TRY_TO(TraverseStmt(const_cast<Expr*>(Decomposed.LHS)));
2718  TRY_TO(TraverseStmt(const_cast<Expr*>(Decomposed.RHS)));
2719  ShouldVisitChildren = false;
2720  }
2721 })
2722 DEF_TRAVERSE_STMT(OpaqueValueExpr, {})
2723 DEF_TRAVERSE_STMT(TypoExpr, {})
2724 DEF_TRAVERSE_STMT(RecoveryExpr, {})
2725 DEF_TRAVERSE_STMT(CUDAKernelCallExpr, {})
2726 
2727 // These operators (all of them) do not need any action except
2728 // iterating over the children.
2729 DEF_TRAVERSE_STMT(BinaryConditionalOperator, {})
2730 DEF_TRAVERSE_STMT(ConditionalOperator, {})
2731 DEF_TRAVERSE_STMT(UnaryOperator, {})
2732 DEF_TRAVERSE_STMT(BinaryOperator, {})
2733 DEF_TRAVERSE_STMT(CompoundAssignOperator, {})
2734 DEF_TRAVERSE_STMT(CXXNoexceptExpr, {})
2735 DEF_TRAVERSE_STMT(PackExpansionExpr, {})
2736 DEF_TRAVERSE_STMT(SizeOfPackExpr, {})
2737 DEF_TRAVERSE_STMT(SubstNonTypeTemplateParmPackExpr, {})
2738 DEF_TRAVERSE_STMT(SubstNonTypeTemplateParmExpr, {})
2739 DEF_TRAVERSE_STMT(FunctionParmPackExpr, {})
2740 DEF_TRAVERSE_STMT(CXXFoldExpr, {})
2741 DEF_TRAVERSE_STMT(AtomicExpr, {})
2742 
2743 DEF_TRAVERSE_STMT(MaterializeTemporaryExpr, {
2744  if (S->getLifetimeExtendedTemporaryDecl()) {
2745  TRY_TO(TraverseLifetimeExtendedTemporaryDecl(
2746  S->getLifetimeExtendedTemporaryDecl()));
2747  ShouldVisitChildren = false;
2748  }
2749 })
2750 // For coroutines expressions, traverse either the operand
2751 // as written or the implied calls, depending on what the
2752 // derived class requests.
2753 DEF_TRAVERSE_STMT(CoroutineBodyStmt, {
2754  if (!getDerived().shouldVisitImplicitCode()) {
2755  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getBody());
2756  ShouldVisitChildren = false;
2757  }
2758 })
2759 DEF_TRAVERSE_STMT(CoreturnStmt, {
2760  if (!getDerived().shouldVisitImplicitCode()) {
2761  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand());
2762  ShouldVisitChildren = false;
2763  }
2764 })
2765 DEF_TRAVERSE_STMT(CoawaitExpr, {
2766  if (!getDerived().shouldVisitImplicitCode()) {
2767  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand());
2768  ShouldVisitChildren = false;
2769  }
2770 })
2771 DEF_TRAVERSE_STMT(DependentCoawaitExpr, {
2772  if (!getDerived().shouldVisitImplicitCode()) {
2773  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand());
2774  ShouldVisitChildren = false;
2775  }
2776 })
2777 DEF_TRAVERSE_STMT(CoyieldExpr, {
2778  if (!getDerived().shouldVisitImplicitCode()) {
2779  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand());
2780  ShouldVisitChildren = false;
2781  }
2782 })
2783 
2784 DEF_TRAVERSE_STMT(ConceptSpecializationExpr, {
2785  TRY_TO(TraverseConceptReference(*S));
2786 })
2787 
2788 DEF_TRAVERSE_STMT(RequiresExpr, {
2789  TRY_TO(TraverseDecl(S->getBody()));
2790  for (ParmVarDecl *Parm : S->getLocalParameters())
2791  TRY_TO(TraverseDecl(Parm));
2792  for (concepts::Requirement *Req : S->getRequirements())
2793  if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req)) {
2794  if (!TypeReq->isSubstitutionFailure())
2795  TRY_TO(TraverseTypeLoc(TypeReq->getType()->getTypeLoc()));
2796  } else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req)) {
2797  if (!ExprReq->isExprSubstitutionFailure())
2798  TRY_TO(TraverseStmt(ExprReq->getExpr()));
2799  auto &RetReq = ExprReq->getReturnTypeRequirement();
2800  if (RetReq.isTypeConstraint())
2801  TRY_TO(TraverseTemplateParameterListHelper(
2802  RetReq.getTypeConstraintTemplateParameterList()));
2803  } else {
2804  auto *NestedReq = cast<concepts::NestedRequirement>(Req);
2805  if (!NestedReq->isSubstitutionFailure())
2806  TRY_TO(TraverseStmt(NestedReq->getConstraintExpr()));
2807  }
2808 })
2809 
2810 // These literals (all of them) do not need any action.
2811 DEF_TRAVERSE_STMT(IntegerLiteral, {})
2812 DEF_TRAVERSE_STMT(FixedPointLiteral, {})
2813 DEF_TRAVERSE_STMT(CharacterLiteral, {})
2814 DEF_TRAVERSE_STMT(FloatingLiteral, {})
2815 DEF_TRAVERSE_STMT(ImaginaryLiteral, {})
2816 DEF_TRAVERSE_STMT(StringLiteral, {})
2817 DEF_TRAVERSE_STMT(ObjCStringLiteral, {})
2818 DEF_TRAVERSE_STMT(ObjCBoxedExpr, {})
2819 DEF_TRAVERSE_STMT(ObjCArrayLiteral, {})
2820 DEF_TRAVERSE_STMT(ObjCDictionaryLiteral, {})
2821 
2822 // Traverse OpenCL: AsType, Convert.
2823 DEF_TRAVERSE_STMT(AsTypeExpr, {})
2824 
2825 // OpenMP directives.
2826 template <typename Derived>
2827 bool RecursiveASTVisitor<Derived>::TraverseOMPExecutableDirective(
2828  OMPExecutableDirective *S) {
2829  for (auto *C : S->clauses()) {
2830  TRY_TO(TraverseOMPClause(C));
2831  }
2832  return true;
2833 }
2834 
2835 DEF_TRAVERSE_STMT(OMPCanonicalLoop, {
2836  if (!getDerived().shouldVisitImplicitCode()) {
2837  // Visit only the syntactical loop.
2838  TRY_TO(TraverseStmt(S->getLoopStmt()));
2839  ShouldVisitChildren = false;
2840  }
2841 })
2842 
2843 template <typename Derived>
2844 bool
2845 RecursiveASTVisitor<Derived>::TraverseOMPLoopDirective(OMPLoopDirective *S) {
2846  return TraverseOMPExecutableDirective(S);
2847 }
2848 
2849 DEF_TRAVERSE_STMT(OMPMetaDirective,
2850  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2851 
2852 DEF_TRAVERSE_STMT(OMPParallelDirective,
2853  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2854 
2855 DEF_TRAVERSE_STMT(OMPSimdDirective,
2856  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2857 
2858 DEF_TRAVERSE_STMT(OMPTileDirective,
2859  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2860 
2861 DEF_TRAVERSE_STMT(OMPUnrollDirective,
2862  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2863 
2864 DEF_TRAVERSE_STMT(OMPForDirective,
2865  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2866 
2867 DEF_TRAVERSE_STMT(OMPForSimdDirective,
2868  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2869 
2870 DEF_TRAVERSE_STMT(OMPSectionsDirective,
2871  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2872 
2873 DEF_TRAVERSE_STMT(OMPSectionDirective,
2874  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2875 
2876 DEF_TRAVERSE_STMT(OMPSingleDirective,
2877  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2878 
2879 DEF_TRAVERSE_STMT(OMPMasterDirective,
2880  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2881 
2882 DEF_TRAVERSE_STMT(OMPCriticalDirective, {
2883  TRY_TO(TraverseDeclarationNameInfo(S->getDirectiveName()));
2884  TRY_TO(TraverseOMPExecutableDirective(S));
2885 })
2886 
2887 DEF_TRAVERSE_STMT(OMPParallelForDirective,
2888  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2889 
2890 DEF_TRAVERSE_STMT(OMPParallelForSimdDirective,
2891  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2892 
2893 DEF_TRAVERSE_STMT(OMPParallelMasterDirective,
2894  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2895 
2896 DEF_TRAVERSE_STMT(OMPParallelSectionsDirective,
2897  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2898 
2899 DEF_TRAVERSE_STMT(OMPTaskDirective,
2900  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2901 
2902 DEF_TRAVERSE_STMT(OMPTaskyieldDirective,
2903  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2904 
2905 DEF_TRAVERSE_STMT(OMPBarrierDirective,
2906  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2907 
2908 DEF_TRAVERSE_STMT(OMPTaskwaitDirective,
2909  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2910 
2911 DEF_TRAVERSE_STMT(OMPTaskgroupDirective,
2912  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2913 
2914 DEF_TRAVERSE_STMT(OMPCancellationPointDirective,
2915  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2916 
2917 DEF_TRAVERSE_STMT(OMPCancelDirective,
2918  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2919 
2920 DEF_TRAVERSE_STMT(OMPFlushDirective,
2921  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2922 
2923 DEF_TRAVERSE_STMT(OMPDepobjDirective,
2924  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2925 
2926 DEF_TRAVERSE_STMT(OMPScanDirective,
2927  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2928 
2929 DEF_TRAVERSE_STMT(OMPOrderedDirective,
2930  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2931 
2932 DEF_TRAVERSE_STMT(OMPAtomicDirective,
2933  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2934 
2935 DEF_TRAVERSE_STMT(OMPTargetDirective,
2936  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2937 
2938 DEF_TRAVERSE_STMT(OMPTargetDataDirective,
2939  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2940 
2941 DEF_TRAVERSE_STMT(OMPTargetEnterDataDirective,
2942  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2943 
2944 DEF_TRAVERSE_STMT(OMPTargetExitDataDirective,
2945  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2946 
2947 DEF_TRAVERSE_STMT(OMPTargetParallelDirective,
2948  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2949 
2950 DEF_TRAVERSE_STMT(OMPTargetParallelForDirective,
2951  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2952 
2953 DEF_TRAVERSE_STMT(OMPTeamsDirective,
2954  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2955 
2956 DEF_TRAVERSE_STMT(OMPTargetUpdateDirective,
2957  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2958 
2959 DEF_TRAVERSE_STMT(OMPTaskLoopDirective,
2960  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2961 
2962 DEF_TRAVERSE_STMT(OMPTaskLoopSimdDirective,
2963  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2964 
2965 DEF_TRAVERSE_STMT(OMPMasterTaskLoopDirective,
2966  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2967 
2968 DEF_TRAVERSE_STMT(OMPMasterTaskLoopSimdDirective,
2969  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2970 
2971 DEF_TRAVERSE_STMT(OMPParallelMasterTaskLoopDirective,
2972  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2973 
2974 DEF_TRAVERSE_STMT(OMPParallelMasterTaskLoopSimdDirective,
2975  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2976 
2977 DEF_TRAVERSE_STMT(OMPDistributeDirective,
2978  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2979 
2980 DEF_TRAVERSE_STMT(OMPDistributeParallelForDirective,
2981  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2982 
2983 DEF_TRAVERSE_STMT(OMPDistributeParallelForSimdDirective,
2984  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2985 
2986 DEF_TRAVERSE_STMT(OMPDistributeSimdDirective,
2987  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2988 
2989 DEF_TRAVERSE_STMT(OMPTargetParallelForSimdDirective,
2990  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2991 
2992 DEF_TRAVERSE_STMT(OMPTargetSimdDirective,
2993  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2994 
2995 DEF_TRAVERSE_STMT(OMPTeamsDistributeDirective,
2996  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2997 
2998 DEF_TRAVERSE_STMT(OMPTeamsDistributeSimdDirective,
2999  { TRY_TO(TraverseOMPExecutableDirective(S)); })
3000 
3001 DEF_TRAVERSE_STMT(OMPTeamsDistributeParallelForSimdDirective,
3002  { TRY_TO(TraverseOMPExecutableDirective(S)); })
3003 
3004 DEF_TRAVERSE_STMT(OMPTeamsDistributeParallelForDirective,
3005  { TRY_TO(TraverseOMPExecutableDirective(S)); })
3006 
3007 DEF_TRAVERSE_STMT(OMPTargetTeamsDirective,
3008  { TRY_TO(TraverseOMPExecutableDirective(S)); })
3009 
3010 DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeDirective,
3011  { TRY_TO(TraverseOMPExecutableDirective(S)); })
3012 
3013 DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeParallelForDirective,
3014  { TRY_TO(TraverseOMPExecutableDirective(S)); })
3015 
3016 DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeParallelForSimdDirective,
3017  { TRY_TO(TraverseOMPExecutableDirective(S)); })
3018 
3019 DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeSimdDirective,
3020  { TRY_TO(TraverseOMPExecutableDirective(S)); })
3021 
3022 DEF_TRAVERSE_STMT(OMPInteropDirective,
3023  { TRY_TO(TraverseOMPExecutableDirective(S)); })
3024 
3025 DEF_TRAVERSE_STMT(OMPDispatchDirective,
3026  { TRY_TO(TraverseOMPExecutableDirective(S)); })
3027 
3028 DEF_TRAVERSE_STMT(OMPMaskedDirective,
3029  { TRY_TO(TraverseOMPExecutableDirective(S)); })
3030 
3031 DEF_TRAVERSE_STMT(OMPGenericLoopDirective,
3032  { TRY_TO(TraverseOMPExecutableDirective(S)); })
3033 
3034 // OpenMP clauses.
3035 template <typename Derived>
3036 bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {
3037  if (!C)
3038  return true;
3039  switch (C->getClauseKind()) {
3040 #define GEN_CLANG_CLAUSE_CLASS
3041 #define CLAUSE_CLASS(Enum, Str, Class) \
3042  case llvm::omp::Clause::Enum: \
3043  TRY_TO(Visit##Class(static_cast<Class *>(C))); \
3044  break;
3045 #define CLAUSE_NO_CLASS(Enum, Str) \
3046  case llvm::omp::Clause::Enum: \
3047  break;
3048 #include "llvm/Frontend/OpenMP/OMP.inc"
3049  }
3050  return true;
3051 }
3052 
3053 template <typename Derived>
3054 bool RecursiveASTVisitor<Derived>::VisitOMPClauseWithPreInit(
3055  OMPClauseWithPreInit *Node) {
3056  TRY_TO(TraverseStmt(Node->getPreInitStmt()));
3057  return true;
3058 }
3059 
3060 template <typename Derived>
3061 bool RecursiveASTVisitor<Derived>::VisitOMPClauseWithPostUpdate(
3062  OMPClauseWithPostUpdate *Node) {
3063  TRY_TO(VisitOMPClauseWithPreInit(Node));
3064  TRY_TO(TraverseStmt(Node->getPostUpdateExpr()));
3065  return true;
3066 }
3067 
3068 template <typename Derived>
3069 bool RecursiveASTVisitor<Derived>::VisitOMPAllocatorClause(
3070  OMPAllocatorClause *C) {
3071  TRY_TO(TraverseStmt(C->getAllocator()));
3072  return true;
3073 }
3074 
3075 template <typename Derived>
3076 bool RecursiveASTVisitor<Derived>::VisitOMPAllocateClause(OMPAllocateClause *C) {
3077  TRY_TO(TraverseStmt(C->getAllocator()));
3078  TRY_TO(VisitOMPClauseList(C));
3079  return true;
3080 }
3081 
3082 template <typename Derived>
3083 bool RecursiveASTVisitor<Derived>::VisitOMPIfClause(OMPIfClause *C) {
3084  TRY_TO(VisitOMPClauseWithPreInit(C));
3085  TRY_TO(TraverseStmt(C->getCondition()));
3086  return true;
3087 }
3088 
3089 template <typename Derived>
3090 bool RecursiveASTVisitor<Derived>::VisitOMPFinalClause(OMPFinalClause *C) {
3091  TRY_TO(VisitOMPClauseWithPreInit(C));
3092  TRY_TO(TraverseStmt(C->getCondition()));
3093  return true;
3094 }
3095 
3096 template <typename Derived>
3097 bool
3098 RecursiveASTVisitor<Derived>::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) {
3099  TRY_TO(VisitOMPClauseWithPreInit(C));
3100  TRY_TO(TraverseStmt(C->getNumThreads()));
3101  return true;
3102 }
3103 
3104 template <typename Derived>
3105 bool RecursiveASTVisitor<Derived>::VisitOMPAlignClause(OMPAlignClause *C) {
3106  TRY_TO(TraverseStmt(C->getAlignment()));
3107  return true;
3108 }
3109 
3110 template <typename Derived>
3111 bool RecursiveASTVisitor<Derived>::VisitOMPSafelenClause(OMPSafelenClause *C) {
3112  TRY_TO(TraverseStmt(C->getSafelen()));
3113  return true;
3114 }
3115 
3116 template <typename Derived>
3117 bool RecursiveASTVisitor<Derived>::VisitOMPSimdlenClause(OMPSimdlenClause *C) {
3118  TRY_TO(TraverseStmt(C->getSimdlen()));
3119  return true;
3120 }
3121 
3122 template <typename Derived>
3123 bool RecursiveASTVisitor<Derived>::VisitOMPSizesClause(OMPSizesClause *C) {
3124  for (Expr *E : C->getSizesRefs())
3125  TRY_TO(TraverseStmt(E));
3126  return true;
3127 }
3128 
3129 template <typename Derived>
3130 bool RecursiveASTVisitor<Derived>::VisitOMPFullClause(OMPFullClause *C) {
3131  return true;
3132 }
3133 
3134 template <typename Derived>
3135 bool RecursiveASTVisitor<Derived>::VisitOMPPartialClause(OMPPartialClause *C) {
3136  TRY_TO(TraverseStmt(C->getFactor()));
3137  return true;
3138 }
3139 
3140 template <typename Derived>
3141 bool
3142 RecursiveASTVisitor<Derived>::VisitOMPCollapseClause(OMPCollapseClause *C) {
3143  TRY_TO(TraverseStmt(C->getNumForLoops()));
3144  return true;
3145 }
3146 
3147 template <typename Derived>
3148 bool RecursiveASTVisitor<Derived>::VisitOMPDefaultClause(OMPDefaultClause *) {
3149  return true;
3150 }
3151 
3152 template <typename Derived>
3153 bool RecursiveASTVisitor<Derived>::VisitOMPProcBindClause(OMPProcBindClause *) {
3154  return true;
3155 }
3156 
3157 template <typename Derived>
3158 bool RecursiveASTVisitor<Derived>::VisitOMPUnifiedAddressClause(
3159  OMPUnifiedAddressClause *) {
3160  return true;
3161 }
3162 
3163 template <typename Derived>
3164 bool RecursiveASTVisitor<Derived>::VisitOMPUnifiedSharedMemoryClause(
3165  OMPUnifiedSharedMemoryClause *) {
3166  return true;
3167 }
3168 
3169 template <typename Derived>
3170 bool RecursiveASTVisitor<Derived>::VisitOMPReverseOffloadClause(
3171  OMPReverseOffloadClause *) {
3172  return true;
3173 }
3174 
3175 template <typename Derived>
3176 bool RecursiveASTVisitor<Derived>::VisitOMPDynamicAllocatorsClause(
3177  OMPDynamicAllocatorsClause *) {
3178  return true;
3179 }
3180 
3181 template <typename Derived>
3182 bool RecursiveASTVisitor<Derived>::VisitOMPAtomicDefaultMemOrderClause(
3183  OMPAtomicDefaultMemOrderClause *) {
3184  return true;
3185 }
3186 
3187 template <typename Derived>
3188 bool
3189 RecursiveASTVisitor<Derived>::VisitOMPScheduleClause(OMPScheduleClause *C) {
3190  TRY_TO(VisitOMPClauseWithPreInit(C));
3191  TRY_TO(TraverseStmt(C->getChunkSize()));
3192  return true;
3193 }
3194 
3195 template <typename Derived>
3196 bool RecursiveASTVisitor<Derived>::VisitOMPOrderedClause(OMPOrderedClause *C) {
3197  TRY_TO(TraverseStmt(C->getNumForLoops()));
3198  return true;
3199 }
3200 
3201 template <typename Derived>
3202 bool RecursiveASTVisitor<Derived>::VisitOMPNowaitClause(OMPNowaitClause *) {
3203  return true;
3204 }
3205 
3206 template <typename Derived>
3207 bool RecursiveASTVisitor<Derived>::VisitOMPUntiedClause(OMPUntiedClause *) {
3208  return true;
3209 }
3210 
3211 template <typename Derived>
3212 bool
3213 RecursiveASTVisitor<Derived>::VisitOMPMergeableClause(OMPMergeableClause *) {
3214  return true;
3215 }
3216 
3217 template <typename Derived>
3218 bool RecursiveASTVisitor<Derived>::VisitOMPReadClause(OMPReadClause *) {
3219  return true;
3220 }
3221 
3222 template <typename Derived>
3223 bool RecursiveASTVisitor<Derived>::VisitOMPWriteClause(OMPWriteClause *) {
3224  return true;
3225 }
3226 
3227 template <typename Derived>
3228 bool RecursiveASTVisitor<Derived>::VisitOMPUpdateClause(OMPUpdateClause *) {
3229  return true;
3230 }
3231 
3232 template <typename Derived>
3233 bool RecursiveASTVisitor<Derived>::VisitOMPCaptureClause(OMPCaptureClause *) {
3234  return true;
3235 }
3236 
3237 template <typename Derived>
3238 bool RecursiveASTVisitor<Derived>::VisitOMPCompareClause(OMPCompareClause *) {
3239  return true;
3240 }
3241 
3242 template <typename Derived>
3243 bool RecursiveASTVisitor<Derived>::VisitOMPSeqCstClause(OMPSeqCstClause *) {
3244  return true;
3245 }
3246 
3247 template <typename Derived>
3248 bool RecursiveASTVisitor<Derived>::VisitOMPAcqRelClause(OMPAcqRelClause *) {
3249  return true;
3250 }
3251 
3252 template <typename Derived>
3253 bool RecursiveASTVisitor<Derived>::VisitOMPAcquireClause(OMPAcquireClause *) {
3254  return true;
3255 }
3256 
3257 template <typename Derived>
3258 bool RecursiveASTVisitor<Derived>::VisitOMPReleaseClause(OMPReleaseClause *) {
3259  return true;
3260 }
3261 
3262 template <typename Derived>
3263 bool RecursiveASTVisitor<Derived>::VisitOMPRelaxedClause(OMPRelaxedClause *) {
3264  return true;
3265 }
3266 
3267 template <typename Derived>
3268 bool RecursiveASTVisitor<Derived>::VisitOMPThreadsClause(OMPThreadsClause *) {
3269  return true;
3270 }
3271 
3272 template <typename Derived>
3273 bool RecursiveASTVisitor<Derived>::VisitOMPSIMDClause(OMPSIMDClause *) {
3274  return true;
3275 }
3276 
3277 template <typename Derived>
3278 bool RecursiveASTVisitor<Derived>::VisitOMPNogroupClause(OMPNogroupClause *) {
3279  return true;
3280 }
3281 
3282 template <typename Derived>
3283 bool RecursiveASTVisitor<Derived>::VisitOMPInitClause(OMPInitClause *C) {
3284  TRY_TO(VisitOMPClauseList(C));
3285  return true;
3286 }
3287 
3288 template <typename Derived>
3289 bool RecursiveASTVisitor<Derived>::VisitOMPUseClause(OMPUseClause *C) {
3290  TRY_TO(TraverseStmt(C->getInteropVar()));
3291  return true;
3292 }
3293 
3294 template <typename Derived>
3295 bool RecursiveASTVisitor<Derived>::VisitOMPDestroyClause(OMPDestroyClause *C) {
3296  TRY_TO(TraverseStmt(C->getInteropVar()));
3297  return true;
3298 }
3299 
3300 template <typename Derived>
3301 bool RecursiveASTVisitor<Derived>::VisitOMPNovariantsClause(
3302  OMPNovariantsClause *C) {
3303  TRY_TO(VisitOMPClauseWithPreInit(C));
3304  TRY_TO(TraverseStmt(C->getCondition()));
3305  return true;
3306 }
3307 
3308 template <typename Derived>
3309 bool RecursiveASTVisitor<Derived>::VisitOMPNocontextClause(
3310  OMPNocontextClause *C) {
3311  TRY_TO(VisitOMPClauseWithPreInit(C));
3312  TRY_TO(TraverseStmt(C->getCondition()));
3313  return true;
3314 }
3315 
3316 template <typename Derived>
3317 template <typename T>
3318 bool RecursiveASTVisitor<Derived>::VisitOMPClauseList(T *Node) {
3319  for (auto *E : Node->varlists()) {
3320  TRY_TO(TraverseStmt(E));
3321  }
3322  return true;
3323 }
3324 
3325 template <typename Derived>
3326 bool RecursiveASTVisitor<Derived>::VisitOMPInclusiveClause(
3327  OMPInclusiveClause *C) {
3328  TRY_TO(VisitOMPClauseList(C));
3329  return true;
3330 }
3331 
3332 template <typename Derived>
3333 bool RecursiveASTVisitor<Derived>::VisitOMPExclusiveClause(
3334  OMPExclusiveClause *C) {
3335  TRY_TO(VisitOMPClauseList(C));
3336  return true;
3337 }
3338 
3339 template <typename Derived>
3340 bool RecursiveASTVisitor<Derived>::VisitOMPPrivateClause(OMPPrivateClause *C) {
3341  TRY_TO(VisitOMPClauseList(C));
3342  for (auto *E : C->private_copies()) {
3343  TRY_TO(TraverseStmt(E));
3344  }
3345  return true;
3346 }
3347 
3348 template <typename Derived>
3349 bool RecursiveASTVisitor<Derived>::VisitOMPFirstprivateClause(
3350  OMPFirstprivateClause *C) {
3351  TRY_TO(VisitOMPClauseList(C));
3352  TRY_TO(VisitOMPClauseWithPreInit(C));
3353  for (auto *E : C->private_copies()) {
3354  TRY_TO(TraverseStmt(E));
3355  }
3356  for (auto *E : C->inits()) {
3357  TRY_TO(TraverseStmt(E));
3358  }
3359  return true;
3360 }
3361 
3362 template <typename Derived>
3363 bool RecursiveASTVisitor<Derived>::VisitOMPLastprivateClause(
3364  OMPLastprivateClause *C) {
3365  TRY_TO(VisitOMPClauseList(C));
3366  TRY_TO(VisitOMPClauseWithPostUpdate(C));
3367  for (auto *E : C->private_copies()) {
3368  TRY_TO(TraverseStmt(E));
3369  }
3370  for (auto *E : C->source_exprs()) {
3371  TRY_TO(TraverseStmt(E));
3372  }
3373  for (auto *E : C->destination_exprs()) {
3374  TRY_TO(TraverseStmt(E));
3375  }
3376  for (auto *E : C->assignment_ops()) {
3377  TRY_TO(TraverseStmt(E));
3378  }
3379  return true;
3380 }
3381 
3382 template <typename Derived>
3383 bool RecursiveASTVisitor<Derived>::VisitOMPSharedClause(OMPSharedClause *C) {
3384  TRY_TO(VisitOMPClauseList(C));
3385  return true;
3386 }
3387 
3388 template <typename Derived>
3389 bool RecursiveASTVisitor<Derived>::VisitOMPLinearClause(OMPLinearClause *C) {
3390  TRY_TO(TraverseStmt(C->getStep()));
3391  TRY_TO(TraverseStmt(C->getCalcStep()));
3392  TRY_TO(VisitOMPClauseList(C));
3393  TRY_TO(VisitOMPClauseWithPostUpdate(C));
3394  for (auto *E : C->privates()) {
3395  TRY_TO(TraverseStmt(E));
3396  }
3397  for (auto *E : C->inits()) {
3398  TRY_TO(TraverseStmt(E));
3399  }
3400  for (auto *E : C->updates()) {
3401  TRY_TO(TraverseStmt(E));
3402  }
3403  for (auto *E : C->finals()) {
3404  TRY_TO(TraverseStmt(E));
3405  }
3406  return true;
3407 }
3408 
3409 template <typename Derived>
3410 bool RecursiveASTVisitor<Derived>::VisitOMPAlignedClause(OMPAlignedClause *C) {
3411  TRY_TO(TraverseStmt(C->getAlignment()));
3412  TRY_TO(VisitOMPClauseList(C));
3413  return true;
3414 }
3415 
3416 template <typename Derived>
3417 bool RecursiveASTVisitor<Derived>::VisitOMPCopyinClause(OMPCopyinClause *C) {
3418  TRY_TO(VisitOMPClauseList(C));
3419  for (auto *E : C->source_exprs()) {
3420  TRY_TO(TraverseStmt(E));
3421  }
3422  for (auto *E : C->destination_exprs()) {
3423  TRY_TO(TraverseStmt(E));
3424  }
3425  for (auto *E : C->assignment_ops()) {
3426  TRY_TO(TraverseStmt(E));
3427  }
3428  return true;
3429 }
3430 
3431 template <typename Derived>
3432 bool RecursiveASTVisitor<Derived>::VisitOMPCopyprivateClause(
3433  OMPCopyprivateClause *C) {
3434  TRY_TO(VisitOMPClauseList(C));
3435  for (auto *E : C->source_exprs()) {
3436  TRY_TO(TraverseStmt(E));
3437  }
3438  for (auto *E : C->destination_exprs()) {
3439  TRY_TO(TraverseStmt(E));
3440  }
3441  for (auto *E : C->assignment_ops()) {
3442  TRY_TO(TraverseStmt(E));
3443  }
3444  return true;
3445 }
3446 
3447 template <typename Derived>
3448 bool
3449 RecursiveASTVisitor<Derived>::VisitOMPReductionClause(OMPReductionClause *C) {
3450  TRY_TO(TraverseNestedNameSpecifierLoc(C->getQualifierLoc()));
3451  TRY_TO(TraverseDeclarationNameInfo(C->getNameInfo()));
3452  TRY_TO(VisitOMPClauseList(C));
3453  TRY_TO(VisitOMPClauseWithPostUpdate(C));
3454  for (auto *E : C->privates()) {
3455  TRY_TO(TraverseStmt(E));
3456  }
3457  for (auto *E : C->lhs_exprs()) {
3458  TRY_TO(TraverseStmt(E));
3459  }
3460  for (auto *E : C->rhs_exprs()) {
3461  TRY_TO(TraverseStmt(E));
3462  }
3463  for (auto *E : C->reduction_ops()) {
3464  TRY_TO(TraverseStmt(E));
3465  }
3466  if (C->getModifier() == OMPC_REDUCTION_inscan) {
3467  for (auto *E : C->copy_ops()) {
3468  TRY_TO(TraverseStmt(E));
3469  }
3470  for (auto *E : C->copy_array_temps()) {
3471  TRY_TO(TraverseStmt(E));
3472  }
3473  for (auto *E : C->copy_array_elems()) {
3474  TRY_TO(TraverseStmt(E));
3475  }
3476  }
3477  return true;
3478 }
3479 
3480 template <typename Derived>
3481 bool RecursiveASTVisitor<Derived>::VisitOMPTaskReductionClause(
3482  OMPTaskReductionClause *C) {
3483  TRY_TO(TraverseNestedNameSpecifierLoc(C->getQualifierLoc()));
3484  TRY_TO(TraverseDeclarationNameInfo(C->getNameInfo()));
3485  TRY_TO(VisitOMPClauseList(C));
3486  TRY_TO(VisitOMPClauseWithPostUpdate(C));
3487  for (auto *E : C->privates()) {
3488  TRY_TO(TraverseStmt(E));
3489  }
3490  for (auto *E : C->lhs_exprs()) {
3491  TRY_TO(TraverseStmt(E));
3492  }
3493  for (auto *E : C->rhs_exprs()) {
3494  TRY_TO(TraverseStmt(E));
3495  }
3496  for (auto *E : C->reduction_ops()) {
3497  TRY_TO(TraverseStmt(E));
3498  }
3499  return true;
3500 }
3501 
3502 template <typename Derived>
3503 bool RecursiveASTVisitor<Derived>::VisitOMPInReductionClause(
3504  OMPInReductionClause *C) {
3505  TRY_TO(TraverseNestedNameSpecifierLoc(C->getQualifierLoc()));
3506  TRY_TO(TraverseDeclarationNameInfo(C->getNameInfo()));
3507  TRY_TO(VisitOMPClauseList(C));
3508  TRY_TO(VisitOMPClauseWithPostUpdate(C));
3509  for (auto *E : C->privates()) {
3510  TRY_TO(TraverseStmt(E));
3511  }
3512  for (auto *E : C->lhs_exprs()) {
3513  TRY_TO(TraverseStmt(E));
3514  }
3515  for (auto *E : C->rhs_exprs()) {
3516  TRY_TO(TraverseStmt(E));
3517  }
3518  for (auto *E : C->reduction_ops()) {
3519  TRY_TO(TraverseStmt(E));
3520  }
3521  for (auto *E : C->taskgroup_descriptors())
3522  TRY_TO(TraverseStmt(E));
3523  return true;
3524 }
3525 
3526 template <typename Derived>
3527 bool RecursiveASTVisitor<Derived>::VisitOMPFlushClause(OMPFlushClause *C) {
3528  TRY_TO(VisitOMPClauseList(C));
3529  return true;
3530 }
3531 
3532 template <typename Derived>
3533 bool RecursiveASTVisitor<Derived>::VisitOMPDepobjClause(OMPDepobjClause *C) {
3534  TRY_TO(TraverseStmt(C->getDepobj()));
3535  return true;
3536 }
3537 
3538 template <typename Derived>
3539 bool RecursiveASTVisitor<Derived>::VisitOMPDependClause(OMPDependClause *C) {
3540  TRY_TO(VisitOMPClauseList(C));
3541  return true;
3542 }
3543 
3544 template <typename Derived>
3545 bool RecursiveASTVisitor<Derived>::VisitOMPDeviceClause(OMPDeviceClause *C) {
3546  TRY_TO(VisitOMPClauseWithPreInit(C));
3547  TRY_TO(TraverseStmt(C->getDevice()));
3548  return true;
3549 }
3550 
3551 template <typename Derived>
3552 bool RecursiveASTVisitor<Derived>::VisitOMPMapClause(OMPMapClause *C) {
3553  TRY_TO(VisitOMPClauseList(C));
3554  return true;
3555 }
3556 
3557 template <typename Derived>
3558 bool RecursiveASTVisitor<Derived>::VisitOMPNumTeamsClause(
3559  OMPNumTeamsClause *C) {
3560  TRY_TO(VisitOMPClauseWithPreInit(C));
3561  TRY_TO(TraverseStmt(C->getNumTeams()));
3562  return true;
3563 }
3564 
3565 template <typename Derived>
3566 bool RecursiveASTVisitor<Derived>::VisitOMPThreadLimitClause(
3567  OMPThreadLimitClause *C) {
3568  TRY_TO(VisitOMPClauseWithPreInit(C));
3569  TRY_TO(TraverseStmt(C->getThreadLimit()));
3570  return true;
3571 }
3572 
3573 template <typename Derived>
3574 bool RecursiveASTVisitor<Derived>::VisitOMPPriorityClause(
3575  OMPPriorityClause *C) {
3576  TRY_TO(VisitOMPClauseWithPreInit(C));
3577  TRY_TO(TraverseStmt(C->getPriority()));
3578  return true;
3579 }
3580 
3581 template <typename Derived>
3582 bool RecursiveASTVisitor<Derived>::VisitOMPGrainsizeClause(
3583  OMPGrainsizeClause *C) {
3584  TRY_TO(VisitOMPClauseWithPreInit(C));
3585  TRY_TO(TraverseStmt(C->getGrainsize()));
3586  return true;
3587 }
3588 
3589 template <typename Derived>
3590 bool RecursiveASTVisitor<Derived>::VisitOMPNumTasksClause(
3591  OMPNumTasksClause *C) {
3592  TRY_TO(VisitOMPClauseWithPreInit(C));
3593  TRY_TO(TraverseStmt(C->getNumTasks()));
3594  return true;
3595 }
3596 
3597 template <typename Derived>
3598 bool RecursiveASTVisitor<Derived>::VisitOMPHintClause(OMPHintClause *C) {
3599  TRY_TO(TraverseStmt(C->getHint()));
3600  return true;
3601 }
3602 
3603 template <typename Derived>
3604 bool RecursiveASTVisitor<Derived>::VisitOMPDistScheduleClause(
3605  OMPDistScheduleClause *C) {
3606  TRY_TO(VisitOMPClauseWithPreInit(C));
3607  TRY_TO(TraverseStmt(C->getChunkSize()));
3608  return true;
3609 }
3610 
3611 template <typename Derived>
3612 bool
3613 RecursiveASTVisitor<Derived>::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) {
3614  return true;
3615 }
3616 
3617 template <typename Derived>
3618 bool RecursiveASTVisitor<Derived>::VisitOMPToClause(OMPToClause *C) {
3619  TRY_TO(VisitOMPClauseList(C));
3620  return true;
3621 }
3622 
3623 template <typename Derived>
3624 bool RecursiveASTVisitor<Derived>::VisitOMPFromClause(OMPFromClause *C) {
3625  TRY_TO(VisitOMPClauseList(C));
3626  return true;
3627 }
3628 
3629 template <typename Derived>
3630 bool RecursiveASTVisitor<Derived>::VisitOMPUseDevicePtrClause(
3631  OMPUseDevicePtrClause *C) {
3632  TRY_TO(VisitOMPClauseList(C));
3633  return true;
3634 }
3635 
3636 template <typename Derived>
3637 bool RecursiveASTVisitor<Derived>::VisitOMPUseDeviceAddrClause(
3638  OMPUseDeviceAddrClause *C) {
3639  TRY_TO(VisitOMPClauseList(C));
3640  return true;
3641 }
3642 
3643 template <typename Derived>
3644 bool RecursiveASTVisitor<Derived>::VisitOMPIsDevicePtrClause(
3645  OMPIsDevicePtrClause *C) {
3646  TRY_TO(VisitOMPClauseList(C));
3647  return true;
3648 }
3649 
3650 template <typename Derived>
3651 bool RecursiveASTVisitor<Derived>::VisitOMPNontemporalClause(
3652  OMPNontemporalClause *C) {
3653  TRY_TO(VisitOMPClauseList(C));
3654  for (auto *E : C->private_refs()) {
3655  TRY_TO(TraverseStmt(E));
3656  }
3657  return true;
3658 }
3659 
3660 template <typename Derived>
3661 bool RecursiveASTVisitor<Derived>::VisitOMPOrderClause(OMPOrderClause *) {
3662  return true;
3663 }
3664 
3665 template <typename Derived>
3666 bool RecursiveASTVisitor<Derived>::VisitOMPDetachClause(OMPDetachClause *C) {
3667  TRY_TO(TraverseStmt(C->getEventHandler()));
3668  return true;
3669 }
3670 
3671 template <typename Derived>
3672 bool RecursiveASTVisitor<Derived>::VisitOMPUsesAllocatorsClause(
3673  OMPUsesAllocatorsClause *C) {
3674  for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) {
3675  const OMPUsesAllocatorsClause::Data Data = C->getAllocatorData(I);
3676  TRY_TO(TraverseStmt(Data.Allocator));
3677  TRY_TO(TraverseStmt(Data.AllocatorTraits));
3678  }
3679  return true;
3680 }
3681 
3682 template <typename Derived>
3683 bool RecursiveASTVisitor<Derived>::VisitOMPAffinityClause(
3684  OMPAffinityClause *C) {
3685  TRY_TO(TraverseStmt(C->getModifier()));
3686  for (Expr *E : C->varlists())
3687  TRY_TO(TraverseStmt(E));
3688  return true;
3689 }
3690 
3691 template <typename Derived>
3692 bool RecursiveASTVisitor<Derived>::VisitOMPFilterClause(OMPFilterClause *C) {
3693  TRY_TO(VisitOMPClauseWithPreInit(C));
3694  TRY_TO(TraverseStmt(C->getThreadID()));
3695  return true;
3696 }
3697 
3698 template <typename Derived>
3699 bool RecursiveASTVisitor<Derived>::VisitOMPBindClause(OMPBindClause *C) {
3700  return true;
3701 }
3702 
3703 // FIXME: look at the following tricky-seeming exprs to see if we
3704 // need to recurse on anything. These are ones that have methods
3705 // returning decls or qualtypes or nestednamespecifier -- though I'm
3706 // not sure if they own them -- or just seemed very complicated, or
3707 // had lots of sub-types to explore.
3708 //
3709 // VisitOverloadExpr and its children: recurse on template args? etc?
3710 
3711 // FIXME: go through all the stmts and exprs again, and see which of them
3712 // create new types, and recurse on the types (TypeLocs?) of those.
3713 // Candidates:
3714 //
3715 // http://clang.llvm.org/doxygen/classclang_1_1CXXTypeidExpr.html
3716 // http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html
3717 // http://clang.llvm.org/doxygen/classclang_1_1TypesCompatibleExpr.html
3718 // Every class that has getQualifier.
3719 
3720 #undef DEF_TRAVERSE_STMT
3721 #undef TRAVERSE_STMT
3722 #undef TRAVERSE_STMT_BASE
3723 
3724 #undef TRY_TO
3725 
3726 } // end namespace clang
3727 
3728 #endif // LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
clang::NestedNameSpecifier::Identifier
@ Identifier
An identifier, stored as an IdentifierInfo*.
Definition: NestedNameSpecifier.h:81
clang::NestedNameSpecifier::Super
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
Definition: NestedNameSpecifier.h:101
Specifiers.h
clang::DeclarationName::Identifier
@ Identifier
Definition: DeclarationName.h:201
clang::DeclarationName::CXXLiteralOperatorName
@ CXXLiteralOperatorName
Definition: DeclarationName.h:210
clang::LambdaCapture
Describes the capture of a variable or of this, or of a C++1y init-capture.
Definition: LambdaCapture.h:25
clang::TemplateArgument::getAsTemplateOrTemplatePattern
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
Definition: TemplateBase.h:299
clang::RecursiveASTVisitor::TraverseConstructorInitializer
bool TraverseConstructorInitializer(CXXCtorInitializer *Init)
Recursively visit a constructor initializer.
Definition: RecursiveASTVisitor.h:853
clang::TemplateArgument::pack_begin
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
Definition: TemplateBase.h:351
clang::TemplateArgument::Null
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
Definition: TemplateBase.h:67
TRY_TO_TRAVERSE_OR_ENQUEUE_STMT
#define TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S)
Definition: RecursiveASTVisitor.h:362
clang::TemplateArgumentLoc::getSourceExpression
Expr * getSourceExpression() const
Definition: TemplateBase.h:520
clang::DeclarationName::CXXConstructorName
@ CXXConstructorName
Definition: DeclarationName.h:204
llvm::SmallVector
Definition: LLVM.h:38
clang::NestedNameSpecifier::NamespaceAlias
@ NamespaceAlias
A namespace alias, stored as a NamespaceAliasDecl*.
Definition: NestedNameSpecifier.h:87
clang::RecursiveASTVisitor::shouldVisitTemplateInstantiations
bool shouldVisitTemplateInstantiations() const
Return whether this visitor should recurse into template instantiations.
Definition: RecursiveASTVisitor.h:179
clang::detail::is_same_method_impl::isSameMethod
static bool isSameMethod(FirstMethodPtrTy FirstMethodPtr, SecondMethodPtrTy SecondMethodPtr)
Definition: RecursiveASTVisitor.h:73
clang::RecursiveASTVisitor::TraverseType
bool TraverseType(QualType T)
Recursively visit a type, by dispatching to Traverse*Type() based on the argument's getTypeClass() pr...
Definition: RecursiveASTVisitor.h:617
clang::RecursiveASTVisitor::WalkUpFromQualifiedTypeLoc
bool WalkUpFromQualifiedTypeLoc(QualifiedTypeLoc TL)
Definition: RecursiveASTVisitor.h:424
clang::RecursiveASTVisitor::canIgnoreChildDeclWhileTraversingDeclContext
bool canIgnoreChildDeclWhileTraversingDeclContext(const Decl *Child)
clang::TSK_Undeclared
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
Definition: Specifiers.h:176
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:674
Attr.h
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:54
clang::NestedNameSpecifier
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Definition: NestedNameSpecifier.h:50
clang::RecursiveASTVisitor::VisitQualifiedTypeLoc
bool VisitQualifiedTypeLoc(QualifiedTypeLoc TL)
Definition: RecursiveASTVisitor.h:427
clang::RecursiveASTVisitor::TraverseLambdaCapture
bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C, Expr *Init)
Recursively visit a lambda capture.
Definition: RecursiveASTVisitor.h:866
DeclCXX.h
clang::RecursiveASTVisitor::shouldVisitImplicitCode
bool shouldVisitImplicitCode() const
Return whether this visitor should recurse into implicit code, e.g., implicit constructors and destru...
Definition: RecursiveASTVisitor.h:187
clang::RecursiveASTVisitor::TraverseTemplateArgument
bool TraverseTemplateArgument(const TemplateArgument &Arg)
Recursively visit a template argument and dispatch to the appropriate method for the argument type.
Definition: RecursiveASTVisitor.h:773
clang::TemplateArgument::Declaration
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
Definition: TemplateBase.h:74
clang::DeclarationName::CXXDeductionGuideName
@ CXXDeductionGuideName
Definition: DeclarationName.h:208
DeclOpenMP.h
clang::InitListExpr
Describes an C or C++ initializer list.
Definition: Expr.h:4792
clang::RecursiveASTVisitor::WalkUpFromUnqualTypeLoc
bool WalkUpFromUnqualTypeLoc(UnqualTypeLoc TL)
Definition: RecursiveASTVisitor.h:428
clang::detail::isSameMethod
bool isSameMethod(FirstMethodPtrTy FirstMethodPtr, SecondMethodPtrTy SecondMethodPtr)
Returns true if and only if FirstMethodPtr and SecondMethodPtr are pointers to the same non-static me...
Definition: RecursiveASTVisitor.h:90
ExprOpenMP.h
clang::RecursiveASTVisitor::TraverseStmt
bool TraverseStmt(Stmt *S, DataRecursionQueue *Queue=nullptr)
Recursively visit a statement or expression, by dispatching to Traverse*() based on the argument's dy...
Definition: RecursiveASTVisitor.h:576
clang::detail::is_same_method_impl< true >::isSameMethod
static bool isSameMethod(FirstMethodPtrTy FirstMethodPtr, SecondMethodPtrTy SecondMethodPtr)
Definition: RecursiveASTVisitor.h:81
clang::TemplateArgument::getAsExpr
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:341
TemplateName.h
clang::DeclarationName::getCXXDeductionGuideTemplate
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
Definition: DeclarationName.h:449
clang::ASTContext::getTranslationUnitDecl
TranslationUnitDecl * getTranslationUnitDecl() const
Definition: ASTContext.h:1055
clang::RecursiveASTVisitor::TraverseTemplateArguments
bool TraverseTemplateArguments(const TemplateArgument *Args, unsigned NumArgs)
Recursively visit a set of template arguments.
Definition: RecursiveASTVisitor.h:843
clang::TemplateArgumentLoc::getTypeSourceInfo
TypeSourceInfo * getTypeSourceInfo() const
Definition: TemplateBase.h:514
clang::TemplateArgument::Expression
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
Definition: TemplateBase.h:96
clang::RecursiveASTVisitor::VisitDecl
bool VisitDecl(Decl *D)
Definition: RecursiveASTVisitor.h:453
clang::UnqualTypeLoc
Wrapper of type source information for a type with no direct qualifiers.
Definition: TypeLoc.h:251
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1491
Decl.h
clang::Stmt::NoStmtClass
@ NoStmtClass
Definition: Stmt.h:72
DeclObjC.h
clang::TemplateArgument::Integral
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Definition: TemplateBase.h:82
ExprConcepts.h
clang::TemplateArgument::NullPtr
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Definition: TemplateBase.h:78
U
clang::TRY_TO
TRY_TO(TraverseType(T->getPointeeType()))
clang::RecursiveASTVisitor::dataTraverseStmtPost
bool dataTraverseStmtPost(Stmt *S)
Invoked after visiting a statement or expression via data recursion.
Definition: RecursiveASTVisitor.h:220
TemplateBase.h
clang::TSK_ExplicitInstantiationDeclaration
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
Definition: Specifiers.h:187
clang::NestedNameSpecifier::Namespace
@ Namespace
A namespace, stored as a NamespaceDecl*.
Definition: NestedNameSpecifier.h:84
clang::TemplateArgument::getKind
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:244
DEF_TRAVERSE_TMPL_DECL
#define DEF_TRAVERSE_TMPL_DECL(TMPLDECLKIND)
DeclTemplate.h
clang::QualifiedTypeLoc
Wrapper of type source information for a type with non-trivial direct qualifiers.
Definition: TypeLoc.h:277
StmtOpenMP.h
Node
DynTypedNode Node
Definition: ASTMatchFinder.cpp:67
DeclFriend.h
clang::Decl::getKind
Kind getKind() const
Definition: DeclBase.h:427
clang::interp::ReturnValue
bool ReturnValue(const T &V, APValue &R)
Convert a value to an APValue.
Definition: Interp.h:42
DeclBase.h
clang::RecursiveASTVisitor::TraverseNestedNameSpecifier
bool TraverseNestedNameSpecifier(NestedNameSpecifier *NNS)
Recursively visit a C++ nested-name-specifier.
Definition: RecursiveASTVisitor.h:683
clang::LambdaExpr
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1865
DEF_TRAVERSE_STMT
#define DEF_TRAVERSE_STMT(STMT, CODE)
clang::interp::LE
bool LE(InterpState &S, CodePtr OpPC)
Definition: Interp.h:239
clang::DeclarationName::CXXDestructorName
@ CXXDestructorName
Definition: DeclarationName.h:205
clang::RecursiveASTVisitor::TraverseCXXBaseSpecifier
bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier &Base)
Recursively visit a base specifier.
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:209
clang::RecursiveASTVisitor::shouldWalkTypesOfTypeLocs
bool shouldWalkTypesOfTypeLocs() const
Return whether this visitor should recurse into the types of TypeLocs.
Definition: RecursiveASTVisitor.h:183
NestedNameSpecifier.h
clang::RecursiveASTVisitor
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
Definition: RecursiveASTVisitor.h:164
clang::RecursiveASTVisitor::TraverseAttr
bool TraverseAttr(Attr *At)
Recursively visit an attribute, by dispatching to Traverse*Attr() based on the argument's dynamic typ...
clang::TemplateArgument
Represents a template argument.
Definition: TemplateBase.h:61
OpenMPKinds.h
clang::RecursiveASTVisitor::TraverseTemplateArgumentLoc
bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc)
Recursively visit a template argument location and dispatch to the appropriate method for the argumen...
Definition: RecursiveASTVisitor.h:804
clang::DeclarationName::CXXOperatorName
@ CXXOperatorName
Definition: DeclarationName.h:207
clang::DeclarationNameInfo::getNamedTypeInfo
TypeSourceInfo * getNamedTypeInfo() const
getNamedTypeInfo - Returns the source type info associated to the name.
Definition: DeclarationName.h:795
DEF_TRAVERSE_TMPL_INST
#define DEF_TRAVERSE_TMPL_INST(TMPLDECLKIND)
Definition: RecursiveASTVisitor.h:465
clang::TemplateArgumentLoc
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:457
Type.h
clang::RecursiveASTVisitor::VisitTypeLoc
bool VisitTypeLoc(TypeLoc TL)
Definition: RecursiveASTVisitor.h:420
Expr.h
clang::TemplateArgumentLoc::getArgument
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:506
TRY_TO
#define TRY_TO(CALL_EXPR)
Definition: RecursiveASTVisitor.h:57
clang::TSK_ExplicitInstantiationDefinition
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
Definition: Specifiers.h:191
clang::NestedNameSpecifier::Global
@ Global
The global specifier '::'. There is no stored value.
Definition: NestedNameSpecifier.h:97
clang::RecursiveASTVisitor::TraverseTemplateName
bool TraverseTemplateName(TemplateName Template)
Recursively visit a template name and dispatch to the appropriate method.
Definition: RecursiveASTVisitor.h:763
clang::DeclarationName::CXXUsingDirective
@ CXXUsingDirective
Definition: DeclarationName.h:213
clang::RecursiveASTVisitor::dataTraverseNode
bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue)
Definition: RecursiveASTVisitor.h:509
ExprObjC.h
clang::RecursiveASTVisitor::VisitUnqualTypeLoc
bool VisitUnqualTypeLoc(UnqualTypeLoc TL)
Definition: RecursiveASTVisitor.h:431
clang::NestedNameSpecifierLoc
A C++ nested-name-specifier augmented with source location information.
Definition: NestedNameSpecifier.h:243
clang::TypeLoc::isNull
bool isNull() const
Definition: TypeLoc.h:120
clang::for
for(auto typeArg :T->getTypeArgsAsWritten())
Definition: RecursiveASTVisitor.h:1064
ExprCXX.h
Base
clang::Stmt::child_range
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:1252
clang::RecursiveASTVisitor::VisitStmt
bool VisitStmt(Stmt *S)
Definition: RecursiveASTVisitor.h:378
clang::detail::has_same_member_pointer_type
Definition: RecursiveASTVisitor.h:66
clang::RecursiveASTVisitor::shouldTraversePostOrder
bool shouldTraversePostOrder() const
Return whether this visitor should traverse post-order.
Definition: RecursiveASTVisitor.h:193
clang::Type::getTypeClass
TypeClass getTypeClass() const
Definition: Type.h:1859
clang::NestedNameSpecifier::TypeSpecWithTemplate
@ TypeSpecWithTemplate
A type that was preceded by the 'template' keyword, stored as a Type*.
Definition: NestedNameSpecifier.h:94
clang::Decl::isImplicit
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:557
clang::RecursiveASTVisitor::getDerived
Derived & getDerived()
Return a reference to the derived class.
Definition: RecursiveASTVisitor.h:175
StmtObjC.h
clang::DeclarationNameInfo::getName
DeclarationName getName() const
getName - Returns the embedded declaration name.
Definition: DeclarationName.h:779
clang::DeclarationName::CXXConversionFunctionName
@ CXXConversionFunctionName
Definition: DeclarationName.h:206
clang::DependentTemplateName
Represents a dependent template name that cannot be resolved prior to template instantiation.
Definition: TemplateName.h:446
clang::TemplateArgument::TemplateExpansion
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:90
clang::TemplateName::getAsQualifiedTemplateName
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
Definition: TemplateName.cpp:148
P
StringRef P
Definition: ASTMatchersInternal.cpp:563
clang::RecursiveASTVisitor::dataTraverseStmtPre
bool dataTraverseStmtPre(Stmt *S)
Invoked before visiting a statement or expression via data recursion.
Definition: RecursiveASTVisitor.h:213
clang::TypeLoc::getUnqualifiedLoc
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
Definition: TypeLoc.h:326
clang::ConceptReference
Common data class for constructs that reference concepts with template arguments.
Definition: ASTConcept.h:99
clang::TemplateName
Represents a C++ template name within the type system.
Definition: TemplateName.h:190
clang::QualType::isNull
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:739
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
OpenMPClause.h
clang::TypeLoc
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:58
clang::RecursiveASTVisitor::TraverseDeclarationNameInfo
bool TraverseDeclarationNameInfo(DeclarationNameInfo NameInfo)
Recursively visit a name with its location information.
Definition: RecursiveASTVisitor.h:734
clang::DeclarationName::ObjCZeroArgSelector
@ ObjCZeroArgSelector
Definition: DeclarationName.h:202
clang::QualifiedTemplateName
Represents a template name that was expressed as a qualified name.
Definition: TemplateName.h:390
clang::DeclarationName::ObjCOneArgSelector
@ ObjCOneArgSelector
Definition: DeclarationName.h:203
LLVM.h
clang::TSK_ExplicitSpecialization
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
Definition: Specifiers.h:183
clang::NestedNameSpecifierLoc::getPrefix
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
Definition: NestedNameSpecifier.h:327
STMT
#define STMT(CLASS, PARENT)
Definition: RecursiveASTVisitor.h:379
DEF_TRAVERSE_TMPL_PART_SPEC_DECL
#define DEF_TRAVERSE_TMPL_PART_SPEC_DECL(TMPLDECLKIND, DECLKIND)
clang::RecursiveASTVisitor::DataRecursionQueue
SmallVectorImpl< llvm::PointerIntPair< Stmt *, 1, bool > > DataRecursionQueue
A queue used for performing data recursion over statements.
Definition: RecursiveASTVisitor.h:172
DeclarationName.h
clang::interp::NE
bool NE(InterpState &S, CodePtr OpPC)
Definition: Interp.h:225
clang::TypeLoc::getTypeLocClass
TypeLocClass getTypeLocClass() const
Definition: TypeLoc.h:115
clang::DeclarationName::getNameKind
NameKind getNameKind() const
Determine what kind of name this is.
Definition: DeclarationName.h:382
clang::DEF_TRAVERSE_TYPELOC
DEF_TRAVERSE_TYPELOC(ComplexType, { TRY_TO(TraverseType(TL.getTypePtr() ->getElementType()));}) DEF_TRAVERSE_TYPELOC(PointerType
clang::TemplateArgument::Type
@ Type
The template argument is a type.
Definition: TemplateBase.h:70
clang
Definition: CalledOnceCheck.h:17
clang::NestedNameSpecifier::getAsType
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
Definition: NestedNameSpecifier.h:196
clang::TemplateArgument::Template
@ Template
The template argument is a template name that was provided for a template template parameter.
Definition: TemplateBase.h:86
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:69
clang::RecursiveASTVisitor::VisitType
bool VisitType(Type *T)
Definition: RecursiveASTVisitor.h:399
clang::detail::is_same_method_impl
Definition: RecursiveASTVisitor.h:71
clang::NestedNameSpecifierLoc::getNestedNameSpecifier
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
Definition: NestedNameSpecifier.h:274
clang::CXXBaseSpecifier
Represents a base class of a C++ class.
Definition: DeclCXX.h:146
clang::Attr
Attr - This represents one attribute.
Definition: Attr.h:41
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6421
clang::RecursiveASTVisitor::VisitAttr
bool VisitAttr(Attr *A)
Definition: RecursiveASTVisitor.h:330
clang::RecursiveASTVisitor::WalkUpFromDecl
bool WalkUpFromDecl(Decl *D)
Definition: RecursiveASTVisitor.h:452
clang::RecursiveASTVisitor::WalkUpFromStmt
bool WalkUpFromStmt(Stmt *S)
Definition: RecursiveASTVisitor.h:377
clang::NestedNameSpecifier::getPrefix
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
Definition: NestedNameSpecifier.h:169
clang::RecursiveASTVisitor::TraverseDecl
bool TraverseDecl(Decl *D)
Recursively visit a declaration, by dispatching to Traverse*Decl() based on the argument's dynamic ty...
Definition: RecursiveASTVisitor.h:655
clang::DEF_TRAVERSE_TYPE
DEF_TRAVERSE_TYPE(ComplexType, { TRY_TO(TraverseType(T->getElementType()));}) DEF_TRAVERSE_TYPE(PointerType
clang::TemplateName::getAsDependentTemplateName
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
Definition: TemplateName.cpp:152
clang::RecursiveASTVisitor::getStmtChildren
Stmt::child_range getStmtChildren(Stmt *S)
Definition: RecursiveASTVisitor.h:339
DEF_TRAVERSE_TMPL_SPEC_DECL
#define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND)
LambdaCapture.h
clang::QualifiedTypeLoc::getUnqualifiedLoc
UnqualTypeLoc getUnqualifiedLoc() const
Definition: TypeLoc.h:281
clang::NestedNameSpecifier::TypeSpec
@ TypeSpec
A type, stored as a Type*.
Definition: NestedNameSpecifier.h:90
DEF_TRAVERSE_DECL
#define DEF_TRAVERSE_DECL(DECL, CODE)
clang::TemplateArgument::pack_size
unsigned pack_size() const
The number of template arguments in the given template argument pack.
Definition: TemplateBase.h:371
Stmt.h
clang::NestedNameSpecifierLoc::getTypeLoc
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
Definition: NestedNameSpecifier.cpp:453
llvm::SmallVectorImpl
Definition: LLVM.h:39
clang::DeclarationName::ObjCMultiArgSelector
@ ObjCMultiArgSelector
Definition: DeclarationName.h:215
true
#define true
Definition: stdbool.h:16
clang::TemplateArgumentLoc::getTemplateQualifierLoc
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Definition: TemplateBase.h:540
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::RecursiveASTVisitor::shouldVisitLambdaBody
bool shouldVisitLambdaBody() const
Return whether this visitor should recurse into lambda body.
Definition: RecursiveASTVisitor.h:190
clang::RecursiveASTVisitor::TraverseConceptReference
bool TraverseConceptReference(const ConceptReference &C)
Recursively visit a reference to a concept with potential arguments.
clang::NestedNameSpecifier::getKind
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
Definition: NestedNameSpecifier.cpp:143
clang::CXXCtorInitializer
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2171
clang::TSK_ImplicitInstantiation
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
Definition: Specifiers.h:179
clang::RecursiveASTVisitor::TraverseSynOrSemInitListExpr
bool TraverseSynOrSemInitListExpr(InitListExpr *S, DataRecursionQueue *Queue=nullptr)
Recursively visit the syntactic or semantic form of an initialization list.
clang::DeclarationNameInfo
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Definition: DeclarationName.h:756
clang::RecursiveASTVisitor::WalkUpFromTypeLoc
bool WalkUpFromTypeLoc(TypeLoc TL)
Definition: RecursiveASTVisitor.h:419
StmtCXX.h
clang::RecursiveASTVisitor::TraverseNestedNameSpecifierLoc
bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Recursively visit a C++ nested-name-specifier with location information.
Definition: RecursiveASTVisitor.h:708
clang::RecursiveASTVisitor::TraverseAST
bool TraverseAST(ASTContext &AST)
Recursively visits an entire AST, starting from the TranslationUnitDecl.
Definition: RecursiveASTVisitor.h:197
clang::RecursiveASTVisitor::TraverseTypeLoc
bool TraverseTypeLoc(TypeLoc TL)
Recursively visit a type with location, by dispatching to Traverse*TypeLoc() based on the argument ty...
Definition: RecursiveASTVisitor.h:634
TypeLoc.h
clang::declaresSameEntity
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
Definition: DeclBase.h:1192
clang::RecursiveASTVisitor::WalkUpFromType
bool WalkUpFromType(Type *T)
Definition: RecursiveASTVisitor.h:398
TYPE
#define TYPE(CLASS, BASE)
Definition: RecursiveASTVisitor.h:434
clang::TemplateArgument::getAsType
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:268
clang::TemplateArgument::Pack
@ Pack
The template argument is actually a parameter pack.
Definition: TemplateBase.h:100
Type
MatchType Type
Definition: ASTMatchFinder.cpp:70