clang  8.0.0svn
RecursiveASTVisitor.h
Go to the documentation of this file.
1 //===--- RecursiveASTVisitor.h - Recursive AST Visitor ----------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the RecursiveASTVisitor interface, which recursively
11 // traverses the entire AST.
12 //
13 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
15 #define LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
16 
17 #include "clang/AST/Attr.h"
18 #include "clang/AST/Decl.h"
20 #include "clang/AST/DeclBase.h"
21 #include "clang/AST/DeclCXX.h"
22 #include "clang/AST/DeclFriend.h"
23 #include "clang/AST/DeclObjC.h"
24 #include "clang/AST/DeclOpenMP.h"
25 #include "clang/AST/DeclTemplate.h"
26 #include "clang/AST/Expr.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 // The following three macros are used for meta programming. The code
52 // using them is responsible for defining macro OPERATOR().
53 
54 // All unary operators.
55 #define UNARYOP_LIST() \
56  OPERATOR(PostInc) OPERATOR(PostDec) OPERATOR(PreInc) OPERATOR(PreDec) \
57  OPERATOR(AddrOf) OPERATOR(Deref) OPERATOR(Plus) OPERATOR(Minus) \
58  OPERATOR(Not) OPERATOR(LNot) OPERATOR(Real) OPERATOR(Imag) \
59  OPERATOR(Extension) OPERATOR(Coawait)
60 
61 // All binary operators (excluding compound assign operators).
62 #define BINOP_LIST() \
63  OPERATOR(PtrMemD) OPERATOR(PtrMemI) OPERATOR(Mul) OPERATOR(Div) \
64  OPERATOR(Rem) OPERATOR(Add) OPERATOR(Sub) OPERATOR(Shl) OPERATOR(Shr) \
65  OPERATOR(LT) OPERATOR(GT) OPERATOR(LE) OPERATOR(GE) OPERATOR(EQ) \
66  OPERATOR(NE) OPERATOR(Cmp) OPERATOR(And) OPERATOR(Xor) OPERATOR(Or) \
67  OPERATOR(LAnd) OPERATOR(LOr) OPERATOR(Assign) OPERATOR(Comma)
68 
69 // All compound assign operators.
70 #define CAO_LIST() \
71  OPERATOR(Mul) OPERATOR(Div) OPERATOR(Rem) OPERATOR(Add) OPERATOR(Sub) \
72  OPERATOR(Shl) OPERATOR(Shr) OPERATOR(And) OPERATOR(Or) OPERATOR(Xor)
73 
74 namespace clang {
75 
76 // A helper macro to implement short-circuiting when recursing. It
77 // invokes CALL_EXPR, which must be a method call, on the derived
78 // object (s.t. a user of RecursiveASTVisitor can override the method
79 // in CALL_EXPR).
80 #define TRY_TO(CALL_EXPR) \
81  do { \
82  if (!getDerived().CALL_EXPR) \
83  return false; \
84  } while (false)
85 
86 /// A class that does preorder or postorder
87 /// depth-first traversal on the entire Clang AST and visits each node.
88 ///
89 /// This class performs three distinct tasks:
90 /// 1. traverse the AST (i.e. go to each node);
91 /// 2. at a given node, walk up the class hierarchy, starting from
92 /// the node's dynamic type, until the top-most class (e.g. Stmt,
93 /// Decl, or Type) is reached.
94 /// 3. given a (node, class) combination, where 'class' is some base
95 /// class of the dynamic type of 'node', call a user-overridable
96 /// function to actually visit the node.
97 ///
98 /// These tasks are done by three groups of methods, respectively:
99 /// 1. TraverseDecl(Decl *x) does task #1. It is the entry point
100 /// for traversing an AST rooted at x. This method simply
101 /// dispatches (i.e. forwards) to TraverseFoo(Foo *x) where Foo
102 /// is the dynamic type of *x, which calls WalkUpFromFoo(x) and
103 /// then recursively visits the child nodes of x.
104 /// TraverseStmt(Stmt *x) and TraverseType(QualType x) work
105 /// similarly.
106 /// 2. WalkUpFromFoo(Foo *x) does task #2. It does not try to visit
107 /// any child node of x. Instead, it first calls WalkUpFromBar(x)
108 /// where Bar is the direct parent class of Foo (unless Foo has
109 /// no parent), and then calls VisitFoo(x) (see the next list item).
110 /// 3. VisitFoo(Foo *x) does task #3.
111 ///
112 /// These three method groups are tiered (Traverse* > WalkUpFrom* >
113 /// Visit*). A method (e.g. Traverse*) may call methods from the same
114 /// tier (e.g. other Traverse*) or one tier lower (e.g. WalkUpFrom*).
115 /// It may not call methods from a higher tier.
116 ///
117 /// Note that since WalkUpFromFoo() calls WalkUpFromBar() (where Bar
118 /// is Foo's super class) before calling VisitFoo(), the result is
119 /// that the Visit*() methods for a given node are called in the
120 /// top-down order (e.g. for a node of type NamespaceDecl, the order will
121 /// be VisitDecl(), VisitNamedDecl(), and then VisitNamespaceDecl()).
122 ///
123 /// This scheme guarantees that all Visit*() calls for the same AST
124 /// node are grouped together. In other words, Visit*() methods for
125 /// different nodes are never interleaved.
126 ///
127 /// Clients of this visitor should subclass the visitor (providing
128 /// themselves as the template argument, using the curiously recurring
129 /// template pattern) and override any of the Traverse*, WalkUpFrom*,
130 /// and Visit* methods for declarations, types, statements,
131 /// expressions, or other AST nodes where the visitor should customize
132 /// behavior. Most users only need to override Visit*. Advanced
133 /// users may override Traverse* and WalkUpFrom* to implement custom
134 /// traversal strategies. Returning false from one of these overridden
135 /// functions will abort the entire traversal.
136 ///
137 /// By default, this visitor tries to visit every part of the explicit
138 /// source code exactly once. The default policy towards templates
139 /// is to descend into the 'pattern' class or function body, not any
140 /// explicit or implicit instantiations. Explicit specializations
141 /// are still visited, and the patterns of partial specializations
142 /// are visited separately. This behavior can be changed by
143 /// overriding shouldVisitTemplateInstantiations() in the derived class
144 /// to return true, in which case all known implicit and explicit
145 /// instantiations will be visited at the same time as the pattern
146 /// from which they were produced.
147 ///
148 /// By default, this visitor preorder traverses the AST. If postorder traversal
149 /// is needed, the \c shouldTraversePostOrder method needs to be overridden
150 /// to return \c true.
151 template <typename Derived> class RecursiveASTVisitor {
152 public:
153  /// A queue used for performing data recursion over statements.
154  /// Parameters involving this type are used to implement data
155  /// recursion over Stmts and Exprs within this class, and should
156  /// typically not be explicitly specified by derived classes.
157  /// The bool bit indicates whether the statement has been traversed or not.
160 
161  /// Return a reference to the derived class.
162  Derived &getDerived() { return *static_cast<Derived *>(this); }
163 
164  /// Return whether this visitor should recurse into
165  /// template instantiations.
166  bool shouldVisitTemplateInstantiations() const { return false; }
167 
168  /// Return whether this visitor should recurse into the types of
169  /// TypeLocs.
170  bool shouldWalkTypesOfTypeLocs() const { return true; }
171 
172  /// Return whether this visitor should recurse into implicit
173  /// code, e.g., implicit constructors and destructors.
174  bool shouldVisitImplicitCode() const { return false; }
175 
176  /// Return whether this visitor should traverse post-order.
177  bool shouldTraversePostOrder() const { return false; }
178 
179  /// Recursively visits an entire AST, starting from the top-level Decls
180  /// in the AST traversal scope (by default, the TranslationUnitDecl).
181  /// \returns false if visitation was terminated early.
182  bool TraverseAST(ASTContext &AST) {
183  for (Decl *D : AST.getTraversalScope())
184  if (!getDerived().TraverseDecl(D))
185  return false;
186  return true;
187  }
188 
189  /// Recursively visit a statement or expression, by
190  /// dispatching to Traverse*() based on the argument's dynamic type.
191  ///
192  /// \returns false if the visitation was terminated early, true
193  /// otherwise (including when the argument is nullptr).
194  bool TraverseStmt(Stmt *S, DataRecursionQueue *Queue = nullptr);
195 
196  /// Invoked before visiting a statement or expression via data recursion.
197  ///
198  /// \returns false to skip visiting the node, true otherwise.
199  bool dataTraverseStmtPre(Stmt *S) { return true; }
200 
201  /// Invoked after visiting a statement or expression via data recursion.
202  /// This is not invoked if the previously invoked \c dataTraverseStmtPre
203  /// returned false.
204  ///
205  /// \returns false if the visitation was terminated early, true otherwise.
206  bool dataTraverseStmtPost(Stmt *S) { return true; }
207 
208  /// Recursively visit a type, by dispatching to
209  /// Traverse*Type() based on the argument's getTypeClass() property.
210  ///
211  /// \returns false if the visitation was terminated early, true
212  /// otherwise (including when the argument is a Null type).
213  bool TraverseType(QualType T);
214 
215  /// Recursively visit a type with location, by dispatching to
216  /// Traverse*TypeLoc() based on the argument type's getTypeClass() property.
217  ///
218  /// \returns false if the visitation was terminated early, true
219  /// otherwise (including when the argument is a Null type location).
220  bool TraverseTypeLoc(TypeLoc TL);
221 
222  /// Recursively visit an attribute, by dispatching to
223  /// Traverse*Attr() based on the argument's dynamic type.
224  ///
225  /// \returns false if the visitation was terminated early, true
226  /// otherwise (including when the argument is a Null type location).
227  bool TraverseAttr(Attr *At);
228 
229  /// Recursively visit a declaration, by dispatching to
230  /// Traverse*Decl() based on the argument's dynamic type.
231  ///
232  /// \returns false if the visitation was terminated early, true
233  /// otherwise (including when the argument is NULL).
234  bool TraverseDecl(Decl *D);
235 
236  /// Recursively visit a C++ nested-name-specifier.
237  ///
238  /// \returns false if the visitation was terminated early, true otherwise.
240 
241  /// Recursively visit a C++ nested-name-specifier with location
242  /// information.
243  ///
244  /// \returns false if the visitation was terminated early, true otherwise.
246 
247  /// Recursively visit a name with its location information.
248  ///
249  /// \returns false if the visitation was terminated early, true otherwise.
251 
252  /// Recursively visit a template name and dispatch to the
253  /// appropriate method.
254  ///
255  /// \returns false if the visitation was terminated early, true otherwise.
256  bool TraverseTemplateName(TemplateName Template);
257 
258  /// Recursively visit a template argument and dispatch to the
259  /// appropriate method for the argument type.
260  ///
261  /// \returns false if the visitation was terminated early, true otherwise.
262  // FIXME: migrate callers to TemplateArgumentLoc instead.
264 
265  /// Recursively visit a template argument location and dispatch to the
266  /// appropriate method for the argument type.
267  ///
268  /// \returns false if the visitation was terminated early, true otherwise.
270 
271  /// Recursively visit a set of template arguments.
272  /// This can be overridden by a subclass, but it's not expected that
273  /// will be needed -- this visitor always dispatches to another.
274  ///
275  /// \returns false if the visitation was terminated early, true otherwise.
276  // FIXME: take a TemplateArgumentLoc* (or TemplateArgumentListInfo) instead.
278  unsigned NumArgs);
279 
280  /// Recursively visit a base specifier. This can be overridden by a
281  /// subclass.
282  ///
283  /// \returns false if the visitation was terminated early, true otherwise.
285 
286  /// Recursively visit a constructor initializer. This
287  /// automatically dispatches to another visitor for the initializer
288  /// expression, but not for the name of the initializer, so may
289  /// be overridden for clients that need access to the name.
290  ///
291  /// \returns false if the visitation was terminated early, true otherwise.
293 
294  /// Recursively visit a lambda capture. \c Init is the expression that
295  /// will be used to initialize the capture.
296  ///
297  /// \returns false if the visitation was terminated early, true otherwise.
299  Expr *Init);
300 
301  /// Recursively visit the body of a lambda expression.
302  ///
303  /// This provides a hook for visitors that need more context when visiting
304  /// \c LE->getBody().
305  ///
306  /// \returns false if the visitation was terminated early, true otherwise.
307  bool TraverseLambdaBody(LambdaExpr *LE, DataRecursionQueue *Queue = nullptr);
308 
309  /// Recursively visit the syntactic or semantic form of an
310  /// initialization list.
311  ///
312  /// \returns false if the visitation was terminated early, true otherwise.
314  DataRecursionQueue *Queue = nullptr);
315 
316  // ---- Methods on Attrs ----
317 
318  // Visit an attribute.
319  bool VisitAttr(Attr *A) { return true; }
320 
321 // Declare Traverse* and empty Visit* for all Attr classes.
322 #define ATTR_VISITOR_DECLS_ONLY
323 #include "clang/AST/AttrVisitor.inc"
324 #undef ATTR_VISITOR_DECLS_ONLY
325 
326 // ---- Methods on Stmts ----
327 
329 
330 private:
331  template<typename T, typename U>
332  struct has_same_member_pointer_type : std::false_type {};
333  template<typename T, typename U, typename R, typename... P>
334  struct has_same_member_pointer_type<R (T::*)(P...), R (U::*)(P...)>
335  : std::true_type {};
336 
337  // Traverse the given statement. If the most-derived traverse function takes a
338  // data recursion queue, pass it on; otherwise, discard it. Note that the
339  // first branch of this conditional must compile whether or not the derived
340  // class can take a queue, so if we're taking the second arm, make the first
341  // arm call our function rather than the derived class version.
342 #define TRAVERSE_STMT_BASE(NAME, CLASS, VAR, QUEUE) \
343  (has_same_member_pointer_type<decltype( \
344  &RecursiveASTVisitor::Traverse##NAME), \
345  decltype(&Derived::Traverse##NAME)>::value \
346  ? static_cast<typename std::conditional< \
347  has_same_member_pointer_type< \
348  decltype(&RecursiveASTVisitor::Traverse##NAME), \
349  decltype(&Derived::Traverse##NAME)>::value, \
350  Derived &, RecursiveASTVisitor &>::type>(*this) \
351  .Traverse##NAME(static_cast<CLASS *>(VAR), QUEUE) \
352  : getDerived().Traverse##NAME(static_cast<CLASS *>(VAR)))
353 
354 // Try to traverse the given statement, or enqueue it if we're performing data
355 // recursion in the middle of traversing another statement. Can only be called
356 // from within a DEF_TRAVERSE_STMT body or similar context.
357 #define TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S) \
358  do { \
359  if (!TRAVERSE_STMT_BASE(Stmt, Stmt, S, Queue)) \
360  return false; \
361  } while (false)
362 
363 public:
364 // Declare Traverse*() for all concrete Stmt classes.
365 #define ABSTRACT_STMT(STMT)
366 #define STMT(CLASS, PARENT) \
367  bool Traverse##CLASS(CLASS *S, DataRecursionQueue *Queue = nullptr);
368 #include "clang/AST/StmtNodes.inc"
369  // The above header #undefs ABSTRACT_STMT and STMT upon exit.
370 
371  // Define WalkUpFrom*() and empty Visit*() for all Stmt classes.
372  bool WalkUpFromStmt(Stmt *S) { return getDerived().VisitStmt(S); }
373  bool VisitStmt(Stmt *S) { return true; }
374 #define STMT(CLASS, PARENT) \
375  bool WalkUpFrom##CLASS(CLASS *S) { \
376  TRY_TO(WalkUpFrom##PARENT(S)); \
377  TRY_TO(Visit##CLASS(S)); \
378  return true; \
379  } \
380  bool Visit##CLASS(CLASS *S) { return true; }
381 #include "clang/AST/StmtNodes.inc"
382 
383 // Define Traverse*(), WalkUpFrom*(), and Visit*() for unary
384 // operator methods. Unary operators are not classes in themselves
385 // (they're all opcodes in UnaryOperator) but do have visitors.
386 #define OPERATOR(NAME) \
387  bool TraverseUnary##NAME(UnaryOperator *S, \
388  DataRecursionQueue *Queue = nullptr) { \
389  if (!getDerived().shouldTraversePostOrder()) \
390  TRY_TO(WalkUpFromUnary##NAME(S)); \
391  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr()); \
392  return true; \
393  } \
394  bool WalkUpFromUnary##NAME(UnaryOperator *S) { \
395  TRY_TO(WalkUpFromUnaryOperator(S)); \
396  TRY_TO(VisitUnary##NAME(S)); \
397  return true; \
398  } \
399  bool VisitUnary##NAME(UnaryOperator *S) { return true; }
400 
401  UNARYOP_LIST()
402 #undef OPERATOR
403 
404 // Define Traverse*(), WalkUpFrom*(), and Visit*() for binary
405 // operator methods. Binary operators are not classes in themselves
406 // (they're all opcodes in BinaryOperator) but do have visitors.
407 #define GENERAL_BINOP_FALLBACK(NAME, BINOP_TYPE) \
408  bool TraverseBin##NAME(BINOP_TYPE *S, DataRecursionQueue *Queue = nullptr) { \
409  if (!getDerived().shouldTraversePostOrder()) \
410  TRY_TO(WalkUpFromBin##NAME(S)); \
411  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLHS()); \
412  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRHS()); \
413  return true; \
414  } \
415  bool WalkUpFromBin##NAME(BINOP_TYPE *S) { \
416  TRY_TO(WalkUpFrom##BINOP_TYPE(S)); \
417  TRY_TO(VisitBin##NAME(S)); \
418  return true; \
419  } \
420  bool VisitBin##NAME(BINOP_TYPE *S) { return true; }
421 
422 #define OPERATOR(NAME) GENERAL_BINOP_FALLBACK(NAME, BinaryOperator)
423  BINOP_LIST()
424 #undef OPERATOR
425 
426 // Define Traverse*(), WalkUpFrom*(), and Visit*() for compound
427 // assignment methods. Compound assignment operators are not
428 // classes in themselves (they're all opcodes in
429 // CompoundAssignOperator) but do have visitors.
430 #define OPERATOR(NAME) \
431  GENERAL_BINOP_FALLBACK(NAME##Assign, CompoundAssignOperator)
432 
433  CAO_LIST()
434 #undef OPERATOR
435 #undef GENERAL_BINOP_FALLBACK
436 
437 // ---- Methods on Types ----
438 // FIXME: revamp to take TypeLoc's rather than Types.
439 
440 // Declare Traverse*() for all concrete Type classes.
441 #define ABSTRACT_TYPE(CLASS, BASE)
442 #define TYPE(CLASS, BASE) bool Traverse##CLASS##Type(CLASS##Type *T);
443 #include "clang/AST/TypeNodes.def"
444  // The above header #undefs ABSTRACT_TYPE and TYPE upon exit.
445 
446  // Define WalkUpFrom*() and empty Visit*() for all Type classes.
447  bool WalkUpFromType(Type *T) { return getDerived().VisitType(T); }
448  bool VisitType(Type *T) { return true; }
449 #define TYPE(CLASS, BASE) \
450  bool WalkUpFrom##CLASS##Type(CLASS##Type *T) { \
451  TRY_TO(WalkUpFrom##BASE(T)); \
452  TRY_TO(Visit##CLASS##Type(T)); \
453  return true; \
454  } \
455  bool Visit##CLASS##Type(CLASS##Type *T) { return true; }
456 #include "clang/AST/TypeNodes.def"
457 
458 // ---- Methods on TypeLocs ----
459 // FIXME: this currently just calls the matching Type methods
460 
461 // Declare Traverse*() for all concrete TypeLoc classes.
462 #define ABSTRACT_TYPELOC(CLASS, BASE)
463 #define TYPELOC(CLASS, BASE) bool Traverse##CLASS##TypeLoc(CLASS##TypeLoc TL);
464 #include "clang/AST/TypeLocNodes.def"
465  // The above header #undefs ABSTRACT_TYPELOC and TYPELOC upon exit.
466 
467  // Define WalkUpFrom*() and empty Visit*() for all TypeLoc classes.
468  bool WalkUpFromTypeLoc(TypeLoc TL) { return getDerived().VisitTypeLoc(TL); }
469  bool VisitTypeLoc(TypeLoc TL) { return true; }
470 
471  // QualifiedTypeLoc and UnqualTypeLoc are not declared in
472  // TypeNodes.def and thus need to be handled specially.
474  return getDerived().VisitUnqualTypeLoc(TL.getUnqualifiedLoc());
475  }
476  bool VisitQualifiedTypeLoc(QualifiedTypeLoc TL) { return true; }
478  return getDerived().VisitUnqualTypeLoc(TL.getUnqualifiedLoc());
479  }
480  bool VisitUnqualTypeLoc(UnqualTypeLoc TL) { return true; }
481 
482 // Note that BASE includes trailing 'Type' which CLASS doesn't.
483 #define TYPE(CLASS, BASE) \
484  bool WalkUpFrom##CLASS##TypeLoc(CLASS##TypeLoc TL) { \
485  TRY_TO(WalkUpFrom##BASE##Loc(TL)); \
486  TRY_TO(Visit##CLASS##TypeLoc(TL)); \
487  return true; \
488  } \
489  bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TL) { return true; }
490 #include "clang/AST/TypeNodes.def"
491 
492 // ---- Methods on Decls ----
493 
494 // Declare Traverse*() for all concrete Decl classes.
495 #define ABSTRACT_DECL(DECL)
496 #define DECL(CLASS, BASE) bool Traverse##CLASS##Decl(CLASS##Decl *D);
497 #include "clang/AST/DeclNodes.inc"
498  // The above header #undefs ABSTRACT_DECL and DECL upon exit.
499 
500  // Define WalkUpFrom*() and empty Visit*() for all Decl classes.
501  bool WalkUpFromDecl(Decl *D) { return getDerived().VisitDecl(D); }
502  bool VisitDecl(Decl *D) { return true; }
503 #define DECL(CLASS, BASE) \
504  bool WalkUpFrom##CLASS##Decl(CLASS##Decl *D) { \
505  TRY_TO(WalkUpFrom##BASE(D)); \
506  TRY_TO(Visit##CLASS##Decl(D)); \
507  return true; \
508  } \
509  bool Visit##CLASS##Decl(CLASS##Decl *D) { return true; }
510 #include "clang/AST/DeclNodes.inc"
511 
512  bool canIgnoreChildDeclWhileTraversingDeclContext(const Decl *Child);
513 
514 private:
515  // These are helper methods used by more than one Traverse* method.
516  bool TraverseTemplateParameterListHelper(TemplateParameterList *TPL);
517 
518  // Traverses template parameter lists of either a DeclaratorDecl or TagDecl.
519  template <typename T>
520  bool TraverseDeclTemplateParameterLists(T *D);
521 
522 #define DEF_TRAVERSE_TMPL_INST(TMPLDECLKIND) \
523  bool TraverseTemplateInstantiations(TMPLDECLKIND##TemplateDecl *D);
526  DEF_TRAVERSE_TMPL_INST(Function)
527 #undef DEF_TRAVERSE_TMPL_INST
528  bool TraverseTemplateArgumentLocsHelper(const TemplateArgumentLoc *TAL,
529  unsigned Count);
530  bool TraverseArrayTypeLocHelper(ArrayTypeLoc TL);
531  bool TraverseRecordHelper(RecordDecl *D);
532  bool TraverseCXXRecordHelper(CXXRecordDecl *D);
533  bool TraverseDeclaratorHelper(DeclaratorDecl *D);
534  bool TraverseDeclContextHelper(DeclContext *DC);
535  bool TraverseFunctionHelper(FunctionDecl *D);
536  bool TraverseVarHelper(VarDecl *D);
537  bool TraverseOMPExecutableDirective(OMPExecutableDirective *S);
538  bool TraverseOMPLoopDirective(OMPLoopDirective *S);
539  bool TraverseOMPClause(OMPClause *C);
540 #define OPENMP_CLAUSE(Name, Class) bool Visit##Class(Class *C);
541 #include "clang/Basic/OpenMPKinds.def"
542  /// Process clauses with list of variables.
543  template <typename T> bool VisitOMPClauseList(T *Node);
544  /// Process clauses with pre-initis.
545  bool VisitOMPClauseWithPreInit(OMPClauseWithPreInit *Node);
546  bool VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *Node);
547 
548  bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue);
549  bool PostVisitStmt(Stmt *S);
550 };
551 
552 template <typename Derived>
553 bool RecursiveASTVisitor<Derived>::dataTraverseNode(Stmt *S,
554  DataRecursionQueue *Queue) {
555 #define DISPATCH_STMT(NAME, CLASS, VAR) \
556  return TRAVERSE_STMT_BASE(NAME, CLASS, VAR, Queue);
557 
558  // If we have a binary expr, dispatch to the subcode of the binop. A smart
559  // optimizer (e.g. LLVM) will fold this comparison into the switch stmt
560  // below.
561  if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(S)) {
562  switch (BinOp->getOpcode()) {
563 #define OPERATOR(NAME) \
564  case BO_##NAME: \
565  DISPATCH_STMT(Bin##NAME, BinaryOperator, S);
566 
567  BINOP_LIST()
568 #undef OPERATOR
569 #undef BINOP_LIST
570 
571 #define OPERATOR(NAME) \
572  case BO_##NAME##Assign: \
573  DISPATCH_STMT(Bin##NAME##Assign, CompoundAssignOperator, S);
574 
575  CAO_LIST()
576 #undef OPERATOR
577 #undef CAO_LIST
578  }
579  } else if (UnaryOperator *UnOp = dyn_cast<UnaryOperator>(S)) {
580  switch (UnOp->getOpcode()) {
581 #define OPERATOR(NAME) \
582  case UO_##NAME: \
583  DISPATCH_STMT(Unary##NAME, UnaryOperator, S);
584 
585  UNARYOP_LIST()
586 #undef OPERATOR
587 #undef UNARYOP_LIST
588  }
589  }
590 
591  // Top switch stmt: dispatch to TraverseFooStmt for each concrete FooStmt.
592  switch (S->getStmtClass()) {
593  case Stmt::NoStmtClass:
594  break;
595 #define ABSTRACT_STMT(STMT)
596 #define STMT(CLASS, PARENT) \
597  case Stmt::CLASS##Class: \
598  DISPATCH_STMT(CLASS, CLASS, S);
599 #include "clang/AST/StmtNodes.inc"
600  }
601 
602  return true;
603 }
604 
605 #undef DISPATCH_STMT
606 
607 template <typename Derived>
608 bool RecursiveASTVisitor<Derived>::PostVisitStmt(Stmt *S) {
609  switch (S->getStmtClass()) {
610  case Stmt::NoStmtClass:
611  break;
612 #define ABSTRACT_STMT(STMT)
613 #define STMT(CLASS, PARENT) \
614  case Stmt::CLASS##Class: \
615  TRY_TO(WalkUpFrom##CLASS(static_cast<CLASS *>(S))); break;
616 #define INITLISTEXPR(CLASS, PARENT) \
617  case Stmt::CLASS##Class: \
618  { \
619  auto ILE = static_cast<CLASS *>(S); \
620  if (auto Syn = ILE->isSemanticForm() ? ILE->getSyntacticForm() : ILE) \
621  TRY_TO(WalkUpFrom##CLASS(Syn)); \
622  if (auto Sem = ILE->isSemanticForm() ? ILE : ILE->getSemanticForm()) \
623  TRY_TO(WalkUpFrom##CLASS(Sem)); \
624  break; \
625  }
626 #include "clang/AST/StmtNodes.inc"
627  }
628 
629  return true;
630 }
631 
632 #undef DISPATCH_STMT
633 
634 template <typename Derived>
636  DataRecursionQueue *Queue) {
637  if (!S)
638  return true;
639 
640  if (Queue) {
641  Queue->push_back({S, false});
642  return true;
643  }
644 
646  LocalQueue.push_back({S, false});
647 
648  while (!LocalQueue.empty()) {
649  auto &CurrSAndVisited = LocalQueue.back();
650  Stmt *CurrS = CurrSAndVisited.getPointer();
651  bool Visited = CurrSAndVisited.getInt();
652  if (Visited) {
653  LocalQueue.pop_back();
656  TRY_TO(PostVisitStmt(CurrS));
657  }
658  continue;
659  }
660 
661  if (getDerived().dataTraverseStmtPre(CurrS)) {
662  CurrSAndVisited.setInt(true);
663  size_t N = LocalQueue.size();
664  TRY_TO(dataTraverseNode(CurrS, &LocalQueue));
665  // Process new children in the order they were added.
666  std::reverse(LocalQueue.begin() + N, LocalQueue.end());
667  } else {
668  LocalQueue.pop_back();
669  }
670  }
671 
672  return true;
673 }
674 
675 #define DISPATCH(NAME, CLASS, VAR) \
676  return getDerived().Traverse##NAME(static_cast<CLASS *>(VAR))
677 
678 template <typename Derived>
680  if (T.isNull())
681  return true;
682 
683  switch (T->getTypeClass()) {
684 #define ABSTRACT_TYPE(CLASS, BASE)
685 #define TYPE(CLASS, BASE) \
686  case Type::CLASS: \
687  DISPATCH(CLASS##Type, CLASS##Type, const_cast<Type *>(T.getTypePtr()));
688 #include "clang/AST/TypeNodes.def"
689  }
690 
691  return true;
692 }
693 
694 template <typename Derived>
696  if (TL.isNull())
697  return true;
698 
699  switch (TL.getTypeLocClass()) {
700 #define ABSTRACT_TYPELOC(CLASS, BASE)
701 #define TYPELOC(CLASS, BASE) \
702  case TypeLoc::CLASS: \
703  return getDerived().Traverse##CLASS##TypeLoc(TL.castAs<CLASS##TypeLoc>());
704 #include "clang/AST/TypeLocNodes.def"
705  }
706 
707  return true;
708 }
709 
710 // Define the Traverse*Attr(Attr* A) methods
711 #define VISITORCLASS RecursiveASTVisitor
712 #include "clang/AST/AttrVisitor.inc"
713 #undef VISITORCLASS
714 
715 template <typename Derived>
717  if (!D)
718  return true;
719 
720  // As a syntax visitor, by default we want to ignore declarations for
721  // implicit declarations (ones not typed explicitly by the user).
723  return true;
724 
725  switch (D->getKind()) {
726 #define ABSTRACT_DECL(DECL)
727 #define DECL(CLASS, BASE) \
728  case Decl::CLASS: \
729  if (!getDerived().Traverse##CLASS##Decl(static_cast<CLASS##Decl *>(D))) \
730  return false; \
731  break;
732 #include "clang/AST/DeclNodes.inc"
733  }
734 
735  // Visit any attributes attached to this declaration.
736  for (auto *I : D->attrs()) {
737  if (!getDerived().TraverseAttr(I))
738  return false;
739  }
740  return true;
741 }
742 
743 #undef DISPATCH
744 
745 template <typename Derived>
747  NestedNameSpecifier *NNS) {
748  if (!NNS)
749  return true;
750 
751  if (NNS->getPrefix())
753 
754  switch (NNS->getKind()) {
760  return true;
761 
764  TRY_TO(TraverseType(QualType(NNS->getAsType(), 0)));
765  }
766 
767  return true;
768 }
769 
770 template <typename Derived>
773  if (!NNS)
774  return true;
775 
776  if (NestedNameSpecifierLoc Prefix = NNS.getPrefix())
778 
779  switch (NNS.getNestedNameSpecifier()->getKind()) {
785  return true;
786 
790  break;
791  }
792 
793  return true;
794 }
795 
796 template <typename Derived>
798  DeclarationNameInfo NameInfo) {
799  switch (NameInfo.getName().getNameKind()) {
803  if (TypeSourceInfo *TSInfo = NameInfo.getNamedTypeInfo())
804  TRY_TO(TraverseTypeLoc(TSInfo->getTypeLoc()));
805  break;
806 
810  break;
811 
819  break;
820  }
821 
822  return true;
823 }
824 
825 template <typename Derived>
828  TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier()));
829  else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
830  TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
831 
832  return true;
833 }
834 
835 template <typename Derived>
837  const TemplateArgument &Arg) {
838  switch (Arg.getKind()) {
843  return true;
844 
846  return getDerived().TraverseType(Arg.getAsType());
847 
850  return getDerived().TraverseTemplateName(
852 
854  return getDerived().TraverseStmt(Arg.getAsExpr());
855 
857  return getDerived().TraverseTemplateArguments(Arg.pack_begin(),
858  Arg.pack_size());
859  }
860 
861  return true;
862 }
863 
864 // FIXME: no template name location?
865 // FIXME: no source locations for a template argument pack?
866 template <typename Derived>
868  const TemplateArgumentLoc &ArgLoc) {
869  const TemplateArgument &Arg = ArgLoc.getArgument();
870 
871  switch (Arg.getKind()) {
876  return true;
877 
878  case TemplateArgument::Type: {
879  // FIXME: how can TSI ever be NULL?
880  if (TypeSourceInfo *TSI = ArgLoc.getTypeSourceInfo())
881  return getDerived().TraverseTypeLoc(TSI->getTypeLoc());
882  else
883  return getDerived().TraverseType(Arg.getAsType());
884  }
885 
888  if (ArgLoc.getTemplateQualifierLoc())
889  TRY_TO(getDerived().TraverseNestedNameSpecifierLoc(
890  ArgLoc.getTemplateQualifierLoc()));
891  return getDerived().TraverseTemplateName(
893 
895  return getDerived().TraverseStmt(ArgLoc.getSourceExpression());
896 
898  return getDerived().TraverseTemplateArguments(Arg.pack_begin(),
899  Arg.pack_size());
900  }
901 
902  return true;
903 }
904 
905 template <typename Derived>
907  const TemplateArgument *Args, unsigned NumArgs) {
908  for (unsigned I = 0; I != NumArgs; ++I) {
910  }
911 
912  return true;
913 }
914 
915 template <typename Derived>
917  CXXCtorInitializer *Init) {
918  if (TypeSourceInfo *TInfo = Init->getTypeSourceInfo())
919  TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
920 
921  if (Init->isWritten() || getDerived().shouldVisitImplicitCode())
922  TRY_TO(TraverseStmt(Init->getInit()));
923 
924  return true;
925 }
926 
927 template <typename Derived>
928 bool
930  const LambdaCapture *C,
931  Expr *Init) {
932  if (LE->isInitCapture(C))
934  else
935  TRY_TO(TraverseStmt(Init));
936  return true;
937 }
938 
939 template <typename Derived>
941  LambdaExpr *LE, DataRecursionQueue *Queue) {
943  return true;
944 }
945 
946 // ----------------- Type traversal -----------------
947 
948 // This macro makes available a variable T, the passed-in type.
949 #define DEF_TRAVERSE_TYPE(TYPE, CODE) \
950  template <typename Derived> \
951  bool RecursiveASTVisitor<Derived>::Traverse##TYPE(TYPE *T) { \
952  if (!getDerived().shouldTraversePostOrder()) \
953  TRY_TO(WalkUpFrom##TYPE(T)); \
954  { CODE; } \
955  if (getDerived().shouldTraversePostOrder()) \
956  TRY_TO(WalkUpFrom##TYPE(T)); \
957  return true; \
958  }
959 
960 DEF_TRAVERSE_TYPE(BuiltinType, {})
961 
962 DEF_TRAVERSE_TYPE(ComplexType, { TRY_TO(TraverseType(T->getElementType())); })
963 
964 DEF_TRAVERSE_TYPE(PointerType, { TRY_TO(TraverseType(T->getPointeeType())); })
965 
966 DEF_TRAVERSE_TYPE(BlockPointerType,
967  { TRY_TO(TraverseType(T->getPointeeType())); })
968 
969 DEF_TRAVERSE_TYPE(LValueReferenceType,
970  { TRY_TO(TraverseType(T->getPointeeType())); })
971 
972 DEF_TRAVERSE_TYPE(RValueReferenceType,
973  { TRY_TO(TraverseType(T->getPointeeType())); })
974 
975 DEF_TRAVERSE_TYPE(MemberPointerType, {
976  TRY_TO(TraverseType(QualType(T->getClass(), 0)));
977  TRY_TO(TraverseType(T->getPointeeType()));
978 })
979 
980 DEF_TRAVERSE_TYPE(AdjustedType, { TRY_TO(TraverseType(T->getOriginalType())); })
981 
982 DEF_TRAVERSE_TYPE(DecayedType, { TRY_TO(TraverseType(T->getOriginalType())); })
983 
984 DEF_TRAVERSE_TYPE(ConstantArrayType,
985  { TRY_TO(TraverseType(T->getElementType())); })
986 
987 DEF_TRAVERSE_TYPE(IncompleteArrayType,
988  { TRY_TO(TraverseType(T->getElementType())); })
989 
990 DEF_TRAVERSE_TYPE(VariableArrayType, {
991  TRY_TO(TraverseType(T->getElementType()));
992  TRY_TO(TraverseStmt(T->getSizeExpr()));
993 })
994 
995 DEF_TRAVERSE_TYPE(DependentSizedArrayType, {
996  TRY_TO(TraverseType(T->getElementType()));
997  if (T->getSizeExpr())
998  TRY_TO(TraverseStmt(T->getSizeExpr()));
999 })
1000 
1001 DEF_TRAVERSE_TYPE(DependentAddressSpaceType, {
1002  TRY_TO(TraverseStmt(T->getAddrSpaceExpr()));
1003  TRY_TO(TraverseType(T->getPointeeType()));
1004 })
1005 
1006 DEF_TRAVERSE_TYPE(DependentVectorType, {
1007  if (T->getSizeExpr())
1008  TRY_TO(TraverseStmt(T->getSizeExpr()));
1009  TRY_TO(TraverseType(T->getElementType()));
1010 })
1011 
1012 DEF_TRAVERSE_TYPE(DependentSizedExtVectorType, {
1013  if (T->getSizeExpr())
1014  TRY_TO(TraverseStmt(T->getSizeExpr()));
1015  TRY_TO(TraverseType(T->getElementType()));
1016 })
1017 
1018 DEF_TRAVERSE_TYPE(VectorType, { TRY_TO(TraverseType(T->getElementType())); })
1019 
1020 DEF_TRAVERSE_TYPE(ExtVectorType, { TRY_TO(TraverseType(T->getElementType())); })
1021 
1022 DEF_TRAVERSE_TYPE(FunctionNoProtoType,
1023  { TRY_TO(TraverseType(T->getReturnType())); })
1024 
1025 DEF_TRAVERSE_TYPE(FunctionProtoType, {
1026  TRY_TO(TraverseType(T->getReturnType()));
1027 
1028  for (const auto &A : T->param_types()) {
1029  TRY_TO(TraverseType(A));
1030  }
1031 
1032  for (const auto &E : T->exceptions()) {
1033  TRY_TO(TraverseType(E));
1034  }
1035 
1036  if (Expr *NE = T->getNoexceptExpr())
1037  TRY_TO(TraverseStmt(NE));
1038 })
1039 
1040 DEF_TRAVERSE_TYPE(UnresolvedUsingType, {})
1041 DEF_TRAVERSE_TYPE(TypedefType, {})
1042 
1043 DEF_TRAVERSE_TYPE(TypeOfExprType,
1044  { TRY_TO(TraverseStmt(T->getUnderlyingExpr())); })
1045 
1046 DEF_TRAVERSE_TYPE(TypeOfType, { TRY_TO(TraverseType(T->getUnderlyingType())); })
1047 
1048 DEF_TRAVERSE_TYPE(DecltypeType,
1049  { TRY_TO(TraverseStmt(T->getUnderlyingExpr())); })
1050 
1051 DEF_TRAVERSE_TYPE(UnaryTransformType, {
1052  TRY_TO(TraverseType(T->getBaseType()));
1053  TRY_TO(TraverseType(T->getUnderlyingType()));
1054 })
1055 
1056 DEF_TRAVERSE_TYPE(AutoType, { TRY_TO(TraverseType(T->getDeducedType())); })
1057 DEF_TRAVERSE_TYPE(DeducedTemplateSpecializationType, {
1058  TRY_TO(TraverseTemplateName(T->getTemplateName()));
1059  TRY_TO(TraverseType(T->getDeducedType()));
1060 })
1061 
1062 DEF_TRAVERSE_TYPE(RecordType, {})
1063 DEF_TRAVERSE_TYPE(EnumType, {})
1064 DEF_TRAVERSE_TYPE(TemplateTypeParmType, {})
1065 DEF_TRAVERSE_TYPE(SubstTemplateTypeParmType, {
1066  TRY_TO(TraverseType(T->getReplacementType()));
1067 })
1068 DEF_TRAVERSE_TYPE(SubstTemplateTypeParmPackType, {
1069  TRY_TO(TraverseTemplateArgument(T->getArgumentPack()));
1070 })
1071 
1072 DEF_TRAVERSE_TYPE(TemplateSpecializationType, {
1073  TRY_TO(TraverseTemplateName(T->getTemplateName()));
1074  TRY_TO(TraverseTemplateArguments(T->getArgs(), T->getNumArgs()));
1075 })
1076 
1077 DEF_TRAVERSE_TYPE(InjectedClassNameType, {})
1078 
1079 DEF_TRAVERSE_TYPE(AttributedType,
1080  { TRY_TO(TraverseType(T->getModifiedType())); })
1081 
1082 DEF_TRAVERSE_TYPE(ParenType, { TRY_TO(TraverseType(T->getInnerType())); })
1083 
1084 DEF_TRAVERSE_TYPE(ElaboratedType, {
1085  if (T->getQualifier()) {
1086  TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
1087  }
1088  TRY_TO(TraverseType(T->getNamedType()));
1089 })
1090 
1091 DEF_TRAVERSE_TYPE(DependentNameType,
1092  { TRY_TO(TraverseNestedNameSpecifier(T->getQualifier())); })
1093 
1094 DEF_TRAVERSE_TYPE(DependentTemplateSpecializationType, {
1095  TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
1096  TRY_TO(TraverseTemplateArguments(T->getArgs(), T->getNumArgs()));
1097 })
1098 
1099 DEF_TRAVERSE_TYPE(PackExpansionType, { TRY_TO(TraverseType(T->getPattern())); })
1100 
1101 DEF_TRAVERSE_TYPE(ObjCTypeParamType, {})
1102 
1103 DEF_TRAVERSE_TYPE(ObjCInterfaceType, {})
1104 
1105 DEF_TRAVERSE_TYPE(ObjCObjectType, {
1106  // We have to watch out here because an ObjCInterfaceType's base
1107  // type is itself.
1108  if (T->getBaseType().getTypePtr() != T)
1109  TRY_TO(TraverseType(T->getBaseType()));
1110  for (auto typeArg : T->getTypeArgsAsWritten()) {
1111  TRY_TO(TraverseType(typeArg));
1112  }
1113 })
1114 
1115 DEF_TRAVERSE_TYPE(ObjCObjectPointerType,
1116  { TRY_TO(TraverseType(T->getPointeeType())); })
1117 
1118 DEF_TRAVERSE_TYPE(AtomicType, { TRY_TO(TraverseType(T->getValueType())); })
1119 
1120 DEF_TRAVERSE_TYPE(PipeType, { TRY_TO(TraverseType(T->getElementType())); })
1121 
1122 #undef DEF_TRAVERSE_TYPE
1123 
1124 // ----------------- TypeLoc traversal -----------------
1125 
1126 // This macro makes available a variable TL, the passed-in TypeLoc.
1127 // If requested, it calls WalkUpFrom* for the Type in the given TypeLoc,
1128 // in addition to WalkUpFrom* for the TypeLoc itself, such that existing
1129 // clients that override the WalkUpFrom*Type() and/or Visit*Type() methods
1130 // continue to work.
1131 #define DEF_TRAVERSE_TYPELOC(TYPE, CODE) \
1132  template <typename Derived> \
1133  bool RecursiveASTVisitor<Derived>::Traverse##TYPE##Loc(TYPE##Loc TL) { \
1135  TRY_TO(WalkUpFrom##TYPE(const_cast<TYPE *>(TL.getTypePtr()))); \
1136  TRY_TO(WalkUpFrom##TYPE##Loc(TL)); \
1137  { CODE; } \
1138  return true; \
1139  }
1140 
1141 template <typename Derived>
1142 bool
1143 RecursiveASTVisitor<Derived>::TraverseQualifiedTypeLoc(QualifiedTypeLoc TL) {
1144  // Move this over to the 'main' typeloc tree. Note that this is a
1145  // move -- we pretend that we were really looking at the unqualified
1146  // typeloc all along -- rather than a recursion, so we don't follow
1147  // the normal CRTP plan of going through
1148  // getDerived().TraverseTypeLoc. If we did, we'd be traversing
1149  // twice for the same type (once as a QualifiedTypeLoc version of
1150  // the type, once as an UnqualifiedTypeLoc version of the type),
1151  // which in effect means we'd call VisitTypeLoc twice with the
1152  // 'same' type. This solves that problem, at the cost of never
1153  // seeing the qualified version of the type (unless the client
1154  // subclasses TraverseQualifiedTypeLoc themselves). It's not a
1155  // perfect solution. A perfect solution probably requires making
1156  // QualifiedTypeLoc a wrapper around TypeLoc -- like QualType is a
1157  // wrapper around Type* -- rather than being its own class in the
1158  // type hierarchy.
1159  return TraverseTypeLoc(TL.getUnqualifiedLoc());
1160 }
1161 
1162 DEF_TRAVERSE_TYPELOC(BuiltinType, {})
1163 
1164 // FIXME: ComplexTypeLoc is unfinished
1165 DEF_TRAVERSE_TYPELOC(ComplexType, {
1166  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1167 })
1168 
1169 DEF_TRAVERSE_TYPELOC(PointerType,
1170  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1171 
1172 DEF_TRAVERSE_TYPELOC(BlockPointerType,
1173  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1174 
1175 DEF_TRAVERSE_TYPELOC(LValueReferenceType,
1176  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1177 
1178 DEF_TRAVERSE_TYPELOC(RValueReferenceType,
1179  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1180 
1181 // FIXME: location of base class?
1182 // We traverse this in the type case as well, but how is it not reached through
1183 // the pointee type?
1184 DEF_TRAVERSE_TYPELOC(MemberPointerType, {
1185  TRY_TO(TraverseType(QualType(TL.getTypePtr()->getClass(), 0)));
1186  TRY_TO(TraverseTypeLoc(TL.getPointeeLoc()));
1187 })
1188 
1189 DEF_TRAVERSE_TYPELOC(AdjustedType,
1190  { TRY_TO(TraverseTypeLoc(TL.getOriginalLoc())); })
1191 
1192 DEF_TRAVERSE_TYPELOC(DecayedType,
1193  { TRY_TO(TraverseTypeLoc(TL.getOriginalLoc())); })
1194 
1195 template <typename Derived>
1196 bool RecursiveASTVisitor<Derived>::TraverseArrayTypeLocHelper(ArrayTypeLoc TL) {
1197  // This isn't available for ArrayType, but is for the ArrayTypeLoc.
1198  TRY_TO(TraverseStmt(TL.getSizeExpr()));
1199  return true;
1200 }
1201 
1202 DEF_TRAVERSE_TYPELOC(ConstantArrayType, {
1203  TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1204  return TraverseArrayTypeLocHelper(TL);
1205 })
1206 
1207 DEF_TRAVERSE_TYPELOC(IncompleteArrayType, {
1208  TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1209  return TraverseArrayTypeLocHelper(TL);
1210 })
1211 
1212 DEF_TRAVERSE_TYPELOC(VariableArrayType, {
1213  TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1214  return TraverseArrayTypeLocHelper(TL);
1215 })
1216 
1217 DEF_TRAVERSE_TYPELOC(DependentSizedArrayType, {
1218  TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1219  return TraverseArrayTypeLocHelper(TL);
1220 })
1221 
1222 DEF_TRAVERSE_TYPELOC(DependentAddressSpaceType, {
1223  TRY_TO(TraverseStmt(TL.getTypePtr()->getAddrSpaceExpr()));
1224  TRY_TO(TraverseType(TL.getTypePtr()->getPointeeType()));
1225 })
1226 
1227 // FIXME: order? why not size expr first?
1228 // FIXME: base VectorTypeLoc is unfinished
1229 DEF_TRAVERSE_TYPELOC(DependentSizedExtVectorType, {
1230  if (TL.getTypePtr()->getSizeExpr())
1231  TRY_TO(TraverseStmt(TL.getTypePtr()->getSizeExpr()));
1232  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1233 })
1234 
1235 // FIXME: VectorTypeLoc is unfinished
1236 DEF_TRAVERSE_TYPELOC(VectorType, {
1237  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1238 })
1239 
1240 DEF_TRAVERSE_TYPELOC(DependentVectorType, {
1241  if (TL.getTypePtr()->getSizeExpr())
1242  TRY_TO(TraverseStmt(TL.getTypePtr()->getSizeExpr()));
1243  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1244 })
1245 
1246 // FIXME: size and attributes
1247 // FIXME: base VectorTypeLoc is unfinished
1248 DEF_TRAVERSE_TYPELOC(ExtVectorType, {
1249  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1250 })
1251 
1252 DEF_TRAVERSE_TYPELOC(FunctionNoProtoType,
1253  { TRY_TO(TraverseTypeLoc(TL.getReturnLoc())); })
1254 
1255 // FIXME: location of exception specifications (attributes?)
1256 DEF_TRAVERSE_TYPELOC(FunctionProtoType, {
1257  TRY_TO(TraverseTypeLoc(TL.getReturnLoc()));
1258 
1259  const FunctionProtoType *T = TL.getTypePtr();
1260 
1261  for (unsigned I = 0, E = TL.getNumParams(); I != E; ++I) {
1262  if (TL.getParam(I)) {
1263  TRY_TO(TraverseDecl(TL.getParam(I)));
1264  } else if (I < T->getNumParams()) {
1265  TRY_TO(TraverseType(T->getParamType(I)));
1266  }
1267  }
1268 
1269  for (const auto &E : T->exceptions()) {
1270  TRY_TO(TraverseType(E));
1271  }
1272 
1273  if (Expr *NE = T->getNoexceptExpr())
1274  TRY_TO(TraverseStmt(NE));
1275 })
1276 
1277 DEF_TRAVERSE_TYPELOC(UnresolvedUsingType, {})
1278 DEF_TRAVERSE_TYPELOC(TypedefType, {})
1279 
1280 DEF_TRAVERSE_TYPELOC(TypeOfExprType,
1281  { TRY_TO(TraverseStmt(TL.getUnderlyingExpr())); })
1282 
1283 DEF_TRAVERSE_TYPELOC(TypeOfType, {
1284  TRY_TO(TraverseTypeLoc(TL.getUnderlyingTInfo()->getTypeLoc()));
1285 })
1286 
1287 // FIXME: location of underlying expr
1288 DEF_TRAVERSE_TYPELOC(DecltypeType, {
1289  TRY_TO(TraverseStmt(TL.getTypePtr()->getUnderlyingExpr()));
1290 })
1291 
1292 DEF_TRAVERSE_TYPELOC(UnaryTransformType, {
1293  TRY_TO(TraverseTypeLoc(TL.getUnderlyingTInfo()->getTypeLoc()));
1294 })
1295 
1296 DEF_TRAVERSE_TYPELOC(AutoType, {
1297  TRY_TO(TraverseType(TL.getTypePtr()->getDeducedType()));
1298 })
1299 
1300 DEF_TRAVERSE_TYPELOC(DeducedTemplateSpecializationType, {
1301  TRY_TO(TraverseTemplateName(TL.getTypePtr()->getTemplateName()));
1302  TRY_TO(TraverseType(TL.getTypePtr()->getDeducedType()));
1303 })
1304 
1305 DEF_TRAVERSE_TYPELOC(RecordType, {})
1306 DEF_TRAVERSE_TYPELOC(EnumType, {})
1307 DEF_TRAVERSE_TYPELOC(TemplateTypeParmType, {})
1308 DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmType, {
1309  TRY_TO(TraverseType(TL.getTypePtr()->getReplacementType()));
1310 })
1311 DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmPackType, {
1312  TRY_TO(TraverseTemplateArgument(TL.getTypePtr()->getArgumentPack()));
1313 })
1314 
1315 // FIXME: use the loc for the template name?
1316 DEF_TRAVERSE_TYPELOC(TemplateSpecializationType, {
1317  TRY_TO(TraverseTemplateName(TL.getTypePtr()->getTemplateName()));
1318  for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) {
1319  TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(I)));
1320  }
1321 })
1322 
1324 
1325 DEF_TRAVERSE_TYPELOC(ParenType, { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
1326 
1328  { TRY_TO(TraverseTypeLoc(TL.getModifiedLoc())); })
1329 
1331  if (TL.getQualifierLoc()) {
1332  TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1333  }
1334  TRY_TO(TraverseTypeLoc(TL.getNamedTypeLoc()));
1335 })
1336 
1338  TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1339 })
1340 
1342  if (TL.getQualifierLoc()) {
1343  TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1344  }
1345 
1346  for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) {
1347  TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(I)));
1348  }
1349 })
1350 
1352  { TRY_TO(TraverseTypeLoc(TL.getPatternLoc())); })
1353 
1355 
1357 
1359  // We have to watch out here because an ObjCInterfaceType's base
1360  // type is itself.
1361  if (TL.getTypePtr()->getBaseType().getTypePtr() != TL.getTypePtr())
1362  TRY_TO(TraverseTypeLoc(TL.getBaseLoc()));
1363  for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
1364  TRY_TO(TraverseTypeLoc(TL.getTypeArgTInfo(i)->getTypeLoc()));
1365 })
1366 
1368  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1369 
1370 DEF_TRAVERSE_TYPELOC(AtomicType, { TRY_TO(TraverseTypeLoc(TL.getValueLoc())); })
1371 
1372 DEF_TRAVERSE_TYPELOC(PipeType, { TRY_TO(TraverseTypeLoc(TL.getValueLoc())); })
1373 
1374 #undef DEF_TRAVERSE_TYPELOC
1375 
1376 // ----------------- Decl traversal -----------------
1377 //
1378 // For a Decl, we automate (in the DEF_TRAVERSE_DECL macro) traversing
1379 // the children that come from the DeclContext associated with it.
1380 // Therefore each Traverse* only needs to worry about children other
1381 // than those.
1382 
1383 template <typename Derived>
1385  const Decl *Child) {
1386  // BlockDecls and CapturedDecls are traversed through BlockExprs and
1387  // CapturedStmts respectively.
1388  return isa<BlockDecl>(Child) || isa<CapturedDecl>(Child);
1389 }
1390 
1391 template <typename Derived>
1393  if (!DC)
1394  return true;
1395 
1396  for (auto *Child : DC->decls()) {
1398  TRY_TO(TraverseDecl(Child));
1399  }
1400 
1401  return true;
1402 }
1403 
1404 // This macro makes available a variable D, the passed-in decl.
1405 #define DEF_TRAVERSE_DECL(DECL, CODE) \
1406  template <typename Derived> \
1407  bool RecursiveASTVisitor<Derived>::Traverse##DECL(DECL *D) { \
1408  bool ShouldVisitChildren = true; \
1409  bool ReturnValue = true; \
1410  if (!getDerived().shouldTraversePostOrder()) \
1411  TRY_TO(WalkUpFrom##DECL(D)); \
1412  { CODE; } \
1413  if (ReturnValue && ShouldVisitChildren) \
1414  TRY_TO(TraverseDeclContextHelper(dyn_cast<DeclContext>(D))); \
1415  if (ReturnValue && getDerived().shouldTraversePostOrder()) \
1416  TRY_TO(WalkUpFrom##DECL(D)); \
1417  return ReturnValue; \
1418  }
1419 
1420 DEF_TRAVERSE_DECL(AccessSpecDecl, {})
1421 
1422 DEF_TRAVERSE_DECL(BlockDecl, {
1423  if (TypeSourceInfo *TInfo = D->getSignatureAsWritten())
1424  TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
1425  TRY_TO(TraverseStmt(D->getBody()));
1426  for (const auto &I : D->captures()) {
1427  if (I.hasCopyExpr()) {
1428  TRY_TO(TraverseStmt(I.getCopyExpr()));
1429  }
1430  }
1431  ShouldVisitChildren = false;
1432 })
1433 
1434 DEF_TRAVERSE_DECL(CapturedDecl, {
1435  TRY_TO(TraverseStmt(D->getBody()));
1437 })
1438 
1440 
1442  { TRY_TO(TraverseStmt(D->getAsmString())); })
1443 
1445 
1447  // Friend is either decl or a type.
1448  if (D->getFriendType())
1449  TRY_TO(TraverseTypeLoc(D->getFriendType()->getTypeLoc()));
1450  else
1451  TRY_TO(TraverseDecl(D->getFriendDecl()));
1452 })
1453 
1455  if (D->getFriendType())
1456  TRY_TO(TraverseTypeLoc(D->getFriendType()->getTypeLoc()));
1457  else
1458  TRY_TO(TraverseDecl(D->getFriendDecl()));
1459  for (unsigned I = 0, E = D->getNumTemplateParameters(); I < E; ++I) {
1460  TemplateParameterList *TPL = D->getTemplateParameterList(I);
1461  for (TemplateParameterList::iterator ITPL = TPL->begin(), ETPL = TPL->end();
1462  ITPL != ETPL; ++ITPL) {
1463  TRY_TO(TraverseDecl(*ITPL));
1464  }
1465  }
1466 })
1467 
1469  TRY_TO(TraverseDecl(D->getSpecialization()));
1470 
1471  if (D->hasExplicitTemplateArgs()) {
1472  const TemplateArgumentListInfo &args = D->templateArgs();
1473  TRY_TO(TraverseTemplateArgumentLocsHelper(args.getArgumentArray(),
1474  args.size()));
1475  }
1476 })
1477 
1479 
1481 
1482 DEF_TRAVERSE_DECL(ObjCPropertyImplDecl, {// FIXME: implement this
1483  })
1484 
1486  TRY_TO(TraverseStmt(D->getAssertExpr()));
1487  TRY_TO(TraverseStmt(D->getMessage()));
1488 })
1489 
1492  {// Code in an unnamed namespace shows up automatically in
1493  // decls_begin()/decls_end(). Thus we don't need to recurse on
1494  // D->getAnonymousNamespace().
1495  })
1496 
1498 
1500 
1502 
1504  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1505 
1506  // We shouldn't traverse an aliased namespace, since it will be
1507  // defined (and, therefore, traversed) somewhere else.
1508  ShouldVisitChildren = false;
1509 })
1510 
1511 DEF_TRAVERSE_DECL(LabelDecl, {// There is no code in a LabelDecl.
1512  })
1513 
1515  NamespaceDecl,
1516  {// Code in an unnamed namespace shows up automatically in
1517  // decls_begin()/decls_end(). Thus we don't need to recurse on
1518  // D->getAnonymousNamespace().
1519  })
1520 
1521 DEF_TRAVERSE_DECL(ObjCCompatibleAliasDecl, {// FIXME: implement
1522  })
1523 
1524 DEF_TRAVERSE_DECL(ObjCCategoryDecl, {// FIXME: implement
1525  if (ObjCTypeParamList *typeParamList = D->getTypeParamList()) {
1526  for (auto typeParam : *typeParamList) {
1527  TRY_TO(TraverseObjCTypeParamDecl(typeParam));
1528  }
1529  }
1530 })
1531 
1532 DEF_TRAVERSE_DECL(ObjCCategoryImplDecl, {// FIXME: implement
1533  })
1534 
1535 DEF_TRAVERSE_DECL(ObjCImplementationDecl, {// FIXME: implement
1536  })
1537 
1538 DEF_TRAVERSE_DECL(ObjCInterfaceDecl, {// FIXME: implement
1539  if (ObjCTypeParamList *typeParamList = D->getTypeParamListAsWritten()) {
1540  for (auto typeParam : *typeParamList) {
1541  TRY_TO(TraverseObjCTypeParamDecl(typeParam));
1542  }
1543  }
1544 
1545  if (TypeSourceInfo *superTInfo = D->getSuperClassTInfo()) {
1546  TRY_TO(TraverseTypeLoc(superTInfo->getTypeLoc()));
1547  }
1548 })
1549 
1550 DEF_TRAVERSE_DECL(ObjCProtocolDecl, {// FIXME: implement
1551  })
1552 
1554  if (D->getReturnTypeSourceInfo()) {
1555  TRY_TO(TraverseTypeLoc(D->getReturnTypeSourceInfo()->getTypeLoc()));
1556  }
1557  for (ParmVarDecl *Parameter : D->parameters()) {
1559  }
1560  if (D->isThisDeclarationADefinition()) {
1561  TRY_TO(TraverseStmt(D->getBody()));
1562  }
1563  ShouldVisitChildren = false;
1564 })
1565 
1567  if (D->hasExplicitBound()) {
1568  TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1569  // We shouldn't traverse D->getTypeForDecl(); it's a result of
1570  // declaring the type alias, not something that was written in the
1571  // source.
1572  }
1573 })
1574 
1576  if (D->getTypeSourceInfo())
1577  TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1578  else
1579  TRY_TO(TraverseType(D->getType()));
1580  ShouldVisitChildren = false;
1581 })
1582 
1584  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1585  TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
1586 })
1587 
1589 
1591  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1592 })
1593 
1595 
1597 
1599  for (auto *I : D->varlists()) {
1600  TRY_TO(TraverseStmt(I));
1601  }
1602  })
1603 
1605  for (auto *C : D->clauselists()) {
1606  TRY_TO(TraverseOMPClause(C));
1607  }
1608 })
1609 
1611  TRY_TO(TraverseStmt(D->getCombiner()));
1612  if (auto *Initializer = D->getInitializer())
1613  TRY_TO(TraverseStmt(Initializer));
1614  TRY_TO(TraverseType(D->getType()));
1615  return true;
1616 })
1617 
1618 DEF_TRAVERSE_DECL(OMPCapturedExprDecl, { TRY_TO(TraverseVarHelper(D)); })
1619 
1620 // A helper method for TemplateDecl's children.
1621 template <typename Derived>
1623  TemplateParameterList *TPL) {
1624  if (TPL) {
1625  for (TemplateParameterList::iterator I = TPL->begin(), E = TPL->end();
1626  I != E; ++I) {
1627  TRY_TO(TraverseDecl(*I));
1628  }
1629  }
1630  return true;
1631 }
1632 
1633 template <typename Derived>
1634 template <typename T>
1636  for (unsigned i = 0; i < D->getNumTemplateParameterLists(); i++) {
1637  TemplateParameterList *TPL = D->getTemplateParameterList(i);
1638  TraverseTemplateParameterListHelper(TPL);
1639  }
1640  return true;
1641 }
1642 
1643 template <typename Derived>
1645  ClassTemplateDecl *D) {
1646  for (auto *SD : D->specializations()) {
1647  for (auto *RD : SD->redecls()) {
1648  // We don't want to visit injected-class-names in this traversal.
1649  if (cast<CXXRecordDecl>(RD)->isInjectedClassName())
1650  continue;
1651 
1652  switch (
1653  cast<ClassTemplateSpecializationDecl>(RD)->getSpecializationKind()) {
1654  // Visit the implicit instantiations with the requested pattern.
1655  case TSK_Undeclared:
1657  TRY_TO(TraverseDecl(RD));
1658  break;
1659 
1660  // We don't need to do anything on an explicit instantiation
1661  // or explicit specialization because there will be an explicit
1662  // node for it elsewhere.
1666  break;
1667  }
1668  }
1669  }
1670 
1671  return true;
1672 }
1673 
1674 template <typename Derived>
1676  VarTemplateDecl *D) {
1677  for (auto *SD : D->specializations()) {
1678  for (auto *RD : SD->redecls()) {
1679  switch (
1680  cast<VarTemplateSpecializationDecl>(RD)->getSpecializationKind()) {
1681  case TSK_Undeclared:
1683  TRY_TO(TraverseDecl(RD));
1684  break;
1685 
1689  break;
1690  }
1691  }
1692  }
1693 
1694  return true;
1695 }
1696 
1697 // A helper method for traversing the instantiations of a
1698 // function while skipping its specializations.
1699 template <typename Derived>
1701  FunctionTemplateDecl *D) {
1702  for (auto *FD : D->specializations()) {
1703  for (auto *RD : FD->redecls()) {
1704  switch (RD->getTemplateSpecializationKind()) {
1705  case TSK_Undeclared:
1707  // We don't know what kind of FunctionDecl this is.
1708  TRY_TO(TraverseDecl(RD));
1709  break;
1710 
1711  // FIXME: For now traverse explicit instantiations here. Change that
1712  // once they are represented as dedicated nodes in the AST.
1715  TRY_TO(TraverseDecl(RD));
1716  break;
1717 
1719  break;
1720  }
1721  }
1722  }
1723 
1724  return true;
1725 }
1726 
1727 // This macro unifies the traversal of class, variable and function
1728 // template declarations.
1729 #define DEF_TRAVERSE_TMPL_DECL(TMPLDECLKIND) \
1730  DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateDecl, { \
1731  TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \
1732  TRY_TO(TraverseDecl(D->getTemplatedDecl())); \
1733  \
1734  /* By default, we do not traverse the instantiations of \
1735  class templates since they do not appear in the user code. The \
1736  following code optionally traverses them. \
1737  \
1738  We only traverse the class instantiations when we see the canonical \
1739  declaration of the template, to ensure we only visit them once. */ \
1740  if (getDerived().shouldVisitTemplateInstantiations() && \
1741  D == D->getCanonicalDecl()) \
1742  TRY_TO(TraverseTemplateInstantiations(D)); \
1743  \
1744  /* Note that getInstantiatedFromMemberTemplate() is just a link \
1745  from a template instantiation back to the template from which \
1746  it was instantiated, and thus should not be traversed. */ \
1747  })
1748 
1751 DEF_TRAVERSE_TMPL_DECL(Function)
1752 
1754  // D is the "T" in something like
1755  // template <template <typename> class T> class container { };
1757  if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) {
1758  TRY_TO(TraverseTemplateArgumentLoc(D->getDefaultArgument()));
1759  }
1760  TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1761 })
1762 
1764  TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1765 })
1766 
1768  // D is the "T" in something like "template<typename T> class vector;"
1769  if (D->getTypeForDecl())
1770  TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
1771  if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
1772  TRY_TO(TraverseTypeLoc(D->getDefaultArgumentInfo()->getTypeLoc()));
1773 })
1774 
1776  TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1777  // We shouldn't traverse D->getTypeForDecl(); it's a result of
1778  // declaring the typedef, not something that was written in the
1779  // source.
1780 })
1781 
1783  TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1784  // We shouldn't traverse D->getTypeForDecl(); it's a result of
1785  // declaring the type alias, not something that was written in the
1786  // source.
1787 })
1788 
1791  TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1792 })
1793 
1795  // A dependent using declaration which was marked with 'typename'.
1796  // template<class T> class A : public B<T> { using typename B<T>::foo; };
1797  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1798  // We shouldn't traverse D->getTypeForDecl(); it's a result of
1799  // declaring the type, not something that was written in the
1800  // source.
1801 })
1802 
1804  TRY_TO(TraverseDeclTemplateParameterLists(D));
1805 
1806  if (D->getTypeForDecl())
1807  TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
1808 
1809  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1810  // The enumerators are already traversed by
1811  // decls_begin()/decls_end().
1812 })
1813 
1814 // Helper methods for RecordDecl and its children.
1815 template <typename Derived>
1817  // We shouldn't traverse D->getTypeForDecl(); it's a result of
1818  // declaring the type, not something that was written in the source.
1819 
1820  TRY_TO(TraverseDeclTemplateParameterLists(D));
1822  return true;
1823 }
1824 
1825 template <typename Derived>
1827  const CXXBaseSpecifier &Base) {
1829  return true;
1830 }
1831 
1832 template <typename Derived>
1834  if (!TraverseRecordHelper(D))
1835  return false;
1836  if (D->isCompleteDefinition()) {
1837  for (const auto &I : D->bases()) {
1839  }
1840  // We don't traverse the friends or the conversions, as they are
1841  // already in decls_begin()/decls_end().
1842  }
1843  return true;
1844 }
1845 
1846 DEF_TRAVERSE_DECL(RecordDecl, { TRY_TO(TraverseRecordHelper(D)); })
1847 
1848 DEF_TRAVERSE_DECL(CXXRecordDecl, { TRY_TO(TraverseCXXRecordHelper(D)); })
1849 
1850 #define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND) \
1851  DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateSpecializationDecl, { \
1852  /* For implicit instantiations ("set<int> x;"), we don't want to \
1853  recurse at all, since the instatiated template isn't written in \
1854  the source code anywhere. (Note the instatiated *type* -- \
1855  set<int> -- is written, and will still get a callback of \
1856  TemplateSpecializationType). For explicit instantiations \
1857  ("template set<int>;"), we do need a callback, since this \
1858  is the only callback that's made for this instantiation. \
1859  We use getTypeAsWritten() to distinguish. */ \
1860  if (TypeSourceInfo *TSI = D->getTypeAsWritten()) \
1861  TRY_TO(TraverseTypeLoc(TSI->getTypeLoc())); \
1862  \
1866  /* Returning from here skips traversing the \
1867  declaration context of the *TemplateSpecializationDecl \
1868  (embedded in the DEF_TRAVERSE_DECL() macro) \
1869  which contains the instantiated members of the template. */ \
1870  return true; \
1871  })
1872 
1875 
1876 template <typename Derived>
1878  const TemplateArgumentLoc *TAL, unsigned Count) {
1879  for (unsigned I = 0; I < Count; ++I) {
1881  }
1882  return true;
1883 }
1884 
1885 #define DEF_TRAVERSE_TMPL_PART_SPEC_DECL(TMPLDECLKIND, DECLKIND) \
1886  DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplatePartialSpecializationDecl, { \
1887  /* The partial specialization. */ \
1888  if (TemplateParameterList *TPL = D->getTemplateParameters()) { \
1889  for (TemplateParameterList::iterator I = TPL->begin(), E = TPL->end(); \
1890  I != E; ++I) { \
1891  TRY_TO(TraverseDecl(*I)); \
1892  } \
1893  } \
1894  /* The args that remains unspecialized. */ \
1895  TRY_TO(TraverseTemplateArgumentLocsHelper( \
1896  D->getTemplateArgsAsWritten()->getTemplateArgs(), \
1897  D->getTemplateArgsAsWritten()->NumTemplateArgs)); \
1898  \
1899  /* Don't need the *TemplatePartialSpecializationHelper, even \
1900  though that's our parent class -- we already visit all the \
1901  template args here. */ \
1902  TRY_TO(Traverse##DECLKIND##Helper(D)); \
1903  \
1904  /* Instantiations will have been visited with the primary template. */ \
1905  })
1906 
1907 DEF_TRAVERSE_TMPL_PART_SPEC_DECL(Class, CXXRecord)
1909 
1910 DEF_TRAVERSE_DECL(EnumConstantDecl, { TRY_TO(TraverseStmt(D->getInitExpr())); })
1911 
1913  // Like UnresolvedUsingTypenameDecl, but without the 'typename':
1914  // template <class T> Class A : public Base<T> { using Base<T>::foo; };
1916  TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
1917 })
1918 
1920 
1921 template <typename Derived>
1923  TRY_TO(TraverseDeclTemplateParameterLists(D));
1925  if (D->getTypeSourceInfo())
1927  else
1928  TRY_TO(TraverseType(D->getType()));
1929  return true;
1930 }
1931 
1933  TRY_TO(TraverseVarHelper(D));
1934  for (auto *Binding : D->bindings()) {
1935  TRY_TO(TraverseDecl(Binding));
1936  }
1937 })
1938 
1941  TRY_TO(TraverseStmt(D->getBinding()));
1942 })
1943 
1944 DEF_TRAVERSE_DECL(MSPropertyDecl, { TRY_TO(TraverseDeclaratorHelper(D)); })
1945 
1947  TRY_TO(TraverseDeclaratorHelper(D));
1948  if (D->isBitField())
1949  TRY_TO(TraverseStmt(D->getBitWidth()));
1950  else if (D->hasInClassInitializer())
1951  TRY_TO(TraverseStmt(D->getInClassInitializer()));
1952 })
1953 
1955  TRY_TO(TraverseDeclaratorHelper(D));
1956  if (D->isBitField())
1957  TRY_TO(TraverseStmt(D->getBitWidth()));
1958  // FIXME: implement the rest.
1959 })
1960 
1962  TRY_TO(TraverseDeclaratorHelper(D));
1963  if (D->isBitField())
1964  TRY_TO(TraverseStmt(D->getBitWidth()));
1965  // FIXME: implement the rest.
1966 })
1967 
1968 template <typename Derived>
1970  TRY_TO(TraverseDeclTemplateParameterLists(D));
1973 
1974  // If we're an explicit template specialization, iterate over the
1975  // template args that were explicitly specified. If we were doing
1976  // this in typing order, we'd do it between the return type and
1977  // the function args, but both are handled by the FunctionTypeLoc
1978  // above, so we have to choose one side. I've decided to do before.
1979  if (const FunctionTemplateSpecializationInfo *FTSI =
1981  if (FTSI->getTemplateSpecializationKind() != TSK_Undeclared &&
1982  FTSI->getTemplateSpecializationKind() != TSK_ImplicitInstantiation) {
1983  // A specialization might not have explicit template arguments if it has
1984  // a templated return type and concrete arguments.
1985  if (const ASTTemplateArgumentListInfo *TALI =
1986  FTSI->TemplateArgumentsAsWritten) {
1987  TRY_TO(TraverseTemplateArgumentLocsHelper(TALI->getTemplateArgs(),
1988  TALI->NumTemplateArgs));
1989  }
1990  }
1991  }
1992 
1993  // Visit the function type itself, which can be either
1994  // FunctionNoProtoType or FunctionProtoType, or a typedef. This
1995  // also covers the return type and the function parameters,
1996  // including exception specifications.
1997  if (TypeSourceInfo *TSI = D->getTypeSourceInfo()) {
1998  TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
1999  } else if (getDerived().shouldVisitImplicitCode()) {
2000  // Visit parameter variable declarations of the implicit function
2001  // if the traverser is visiting implicit code. Parameter variable
2002  // declarations do not have valid TypeSourceInfo, so to visit them
2003  // we need to traverse the declarations explicitly.
2004  for (ParmVarDecl *Parameter : D->parameters()) {
2006  }
2007  }
2008 
2009  if (CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(D)) {
2010  // Constructor initializers.
2011  for (auto *I : Ctor->inits()) {
2013  }
2014  }
2015 
2016  if (D->isThisDeclarationADefinition()) {
2017  TRY_TO(TraverseStmt(D->getBody())); // Function body.
2018  }
2019  return true;
2020 }
2021 
2023  // We skip decls_begin/decls_end, which are already covered by
2024  // TraverseFunctionHelper().
2025  ShouldVisitChildren = false;
2026  ReturnValue = TraverseFunctionHelper(D);
2027 })
2028 
2030  // We skip decls_begin/decls_end, which are already covered by
2031  // TraverseFunctionHelper().
2032  ShouldVisitChildren = false;
2033  ReturnValue = TraverseFunctionHelper(D);
2034 })
2035 
2037  // We skip decls_begin/decls_end, which are already covered by
2038  // TraverseFunctionHelper().
2039  ShouldVisitChildren = false;
2040  ReturnValue = TraverseFunctionHelper(D);
2041 })
2042 
2044  // We skip decls_begin/decls_end, which are already covered by
2045  // TraverseFunctionHelper().
2046  ShouldVisitChildren = false;
2047  ReturnValue = TraverseFunctionHelper(D);
2048 })
2049 
2050 // CXXConversionDecl is the declaration of a type conversion operator.
2051 // It's not a cast expression.
2053  // We skip decls_begin/decls_end, which are already covered by
2054  // TraverseFunctionHelper().
2055  ShouldVisitChildren = false;
2056  ReturnValue = TraverseFunctionHelper(D);
2057 })
2058 
2060  // We skip decls_begin/decls_end, which are already covered by
2061  // TraverseFunctionHelper().
2062  ShouldVisitChildren = false;
2063  ReturnValue = TraverseFunctionHelper(D);
2064 })
2065 
2066 template <typename Derived>
2068  TRY_TO(TraverseDeclaratorHelper(D));
2069  // Default params are taken care of when we traverse the ParmVarDecl.
2070  if (!isa<ParmVarDecl>(D) &&
2071  (!D->isCXXForRangeDecl() || getDerived().shouldVisitImplicitCode()))
2072  TRY_TO(TraverseStmt(D->getInit()));
2073  return true;
2074 }
2075 
2076 DEF_TRAVERSE_DECL(VarDecl, { TRY_TO(TraverseVarHelper(D)); })
2077 
2078 DEF_TRAVERSE_DECL(ImplicitParamDecl, { TRY_TO(TraverseVarHelper(D)); })
2079 
2081  // A non-type template parameter, e.g. "S" in template<int S> class Foo ...
2082  TRY_TO(TraverseDeclaratorHelper(D));
2083  if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
2084  TRY_TO(TraverseStmt(D->getDefaultArgument()));
2085 })
2086 
2088  TRY_TO(TraverseVarHelper(D));
2089 
2090  if (D->hasDefaultArg() && D->hasUninstantiatedDefaultArg() &&
2091  !D->hasUnparsedDefaultArg())
2092  TRY_TO(TraverseStmt(D->getUninstantiatedDefaultArg()));
2093 
2094  if (D->hasDefaultArg() && !D->hasUninstantiatedDefaultArg() &&
2095  !D->hasUnparsedDefaultArg())
2096  TRY_TO(TraverseStmt(D->getDefaultArg()));
2097 })
2098 
2099 #undef DEF_TRAVERSE_DECL
2100 
2101 // ----------------- Stmt traversal -----------------
2102 //
2103 // For stmts, we automate (in the DEF_TRAVERSE_STMT macro) iterating
2104 // over the children defined in children() (every stmt defines these,
2105 // though sometimes the range is empty). Each individual Traverse*
2106 // method only needs to worry about children other than those. To see
2107 // what children() does for a given class, see, e.g.,
2108 // http://clang.llvm.org/doxygen/Stmt_8cpp_source.html
2109 
2110 // This macro makes available a variable S, the passed-in stmt.
2111 #define DEF_TRAVERSE_STMT(STMT, CODE) \
2112  template <typename Derived> \
2114  STMT *S, DataRecursionQueue *Queue) { \
2115  bool ShouldVisitChildren = true; \
2116  bool ReturnValue = true; \
2118  TRY_TO(WalkUpFrom##STMT(S)); \
2119  { CODE; } \
2120  if (ShouldVisitChildren) { \
2121  for (Stmt * SubStmt : getDerived().getStmtChildren(S)) { \
2122  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(SubStmt); \
2123  } \
2124  } \
2125  if (!Queue && ReturnValue && getDerived().shouldTraversePostOrder()) \
2126  TRY_TO(WalkUpFrom##STMT(S)); \
2127  return ReturnValue; \
2128  }
2129 
2131  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getAsmString());
2132  for (unsigned I = 0, E = S->getNumInputs(); I < E; ++I) {
2133  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getInputConstraintLiteral(I));
2134  }
2135  for (unsigned I = 0, E = S->getNumOutputs(); I < E; ++I) {
2136  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOutputConstraintLiteral(I));
2137  }
2138  for (unsigned I = 0, E = S->getNumClobbers(); I < E; ++I) {
2139  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getClobberStringLiteral(I));
2140  }
2141  // children() iterates over inputExpr and outputExpr.
2142 })
2143 
2145  MSAsmStmt,
2146  {// FIXME: MS Asm doesn't currently parse Constraints, Clobbers, etc. Once
2147  // added this needs to be implemented.
2148  })
2149 
2151  TRY_TO(TraverseDecl(S->getExceptionDecl()));
2152  // children() iterates over the handler block.
2153 })
2154 
2156  for (auto *I : S->decls()) {
2157  TRY_TO(TraverseDecl(I));
2158  }
2159  // Suppress the default iteration over children() by
2160  // returning. Here's why: A DeclStmt looks like 'type var [=
2161  // initializer]'. The decls above already traverse over the
2162  // initializers, so we don't have to do it again (which
2163  // children() would do).
2164  ShouldVisitChildren = false;
2165 })
2166 
2167 // These non-expr stmts (most of them), do not need any action except
2168 // iterating over the children.
2190 
2193  if (S->getInit())
2194  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getInit());
2195  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLoopVarStmt());
2196  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRangeInit());
2197  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getBody());
2198  // Visit everything else only if shouldVisitImplicitCode().
2199  ShouldVisitChildren = false;
2200  }
2201 })
2202 
2204  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2205  TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2206 })
2207 
2211 
2213 
2215  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2216  TRY_TO(TraverseDeclarationNameInfo(S->getMemberNameInfo()));
2217  if (S->hasExplicitTemplateArgs()) {
2218  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2219  S->getNumTemplateArgs()));
2220  }
2221 })
2222 
2224  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2225  TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2226  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2227  S->getNumTemplateArgs()));
2228 })
2229 
2231  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2232  TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2233  if (S->hasExplicitTemplateArgs()) {
2234  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2235  S->getNumTemplateArgs()));
2236  }
2237 })
2238 
2240  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2241  TRY_TO(TraverseDeclarationNameInfo(S->getMemberNameInfo()));
2242  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2243  S->getNumTemplateArgs()));
2244 })
2245 
2248  {// We don't traverse the cast type, as it's not written in the
2249  // source code.
2250  })
2251 
2253  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2254 })
2255 
2257  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2258 })
2259 
2261  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2262 })
2263 
2265  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2266 })
2267 
2269  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2270 })
2271 
2273  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2274 })
2275 
2276 template <typename Derived>
2278  InitListExpr *S, DataRecursionQueue *Queue) {
2279  if (S) {
2280  // Skip this if we traverse postorder. We will visit it later
2281  // in PostVisitStmt.
2282  if (!getDerived().shouldTraversePostOrder())
2283  TRY_TO(WalkUpFromInitListExpr(S));
2284 
2285  // All we need are the default actions. FIXME: use a helper function.
2286  for (Stmt *SubStmt : S->children()) {
2288  }
2289  }
2290  return true;
2291 }
2292 
2293 // This method is called once for each pair of syntactic and semantic
2294 // InitListExpr, and it traverses the subtrees defined by the two forms. This
2295 // may cause some of the children to be visited twice, if they appear both in
2296 // the syntactic and the semantic form.
2297 //
2298 // There is no guarantee about which form \p S takes when this method is called.
2299 template <typename Derived>
2301  InitListExpr *S, DataRecursionQueue *Queue) {
2303  S->isSemanticForm() ? S->getSyntacticForm() : S, Queue));
2305  S->isSemanticForm() ? S : S->getSemanticForm(), Queue));
2306  return true;
2307 }
2308 
2309 // GenericSelectionExpr is a special case because the types and expressions
2310 // are interleaved. We also need to watch out for null types (default
2311 // generic associations).
2313  TRY_TO(TraverseStmt(S->getControllingExpr()));
2314  for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
2315  if (TypeSourceInfo *TS = S->getAssocTypeSourceInfo(i))
2316  TRY_TO(TraverseTypeLoc(TS->getTypeLoc()));
2317  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getAssocExpr(i));
2318  }
2319  ShouldVisitChildren = false;
2320 })
2321 
2322 // PseudoObjectExpr is a special case because of the weirdness with
2323 // syntactic expressions and opaque values.
2326  for (PseudoObjectExpr::semantics_iterator i = S->semantics_begin(),
2327  e = S->semantics_end();
2328  i != e; ++i) {
2329  Expr *sub = *i;
2330  if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(sub))
2331  sub = OVE->getSourceExpr();
2333  }
2334  ShouldVisitChildren = false;
2335 })
2336 
2338  // This is called for code like 'return T()' where T is a built-in
2339  // (i.e. non-class) type.
2340  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2341 })
2342 
2344  // The child-iterator will pick up the other arguments.
2345  TRY_TO(TraverseTypeLoc(S->getAllocatedTypeSourceInfo()->getTypeLoc()));
2346 })
2347 
2349  // The child-iterator will pick up the expression representing
2350  // the field.
2351  // FIMXE: for code like offsetof(Foo, a.b.c), should we get
2352  // making a MemberExpr callbacks for Foo.a, Foo.a.b, and Foo.a.b.c?
2353  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2354 })
2355 
2357  // The child-iterator will pick up the arg if it's an expression,
2358  // but not if it's a type.
2359  if (S->isArgumentType())
2360  TRY_TO(TraverseTypeLoc(S->getArgumentTypeInfo()->getTypeLoc()));
2361 })
2362 
2364  // The child-iterator will pick up the arg if it's an expression,
2365  // but not if it's a type.
2366  if (S->isTypeOperand())
2367  TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
2368 })
2369 
2371  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2372 })
2373 
2375 
2377  // The child-iterator will pick up the arg if it's an expression,
2378  // but not if it's a type.
2379  if (S->isTypeOperand())
2380  TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
2381 })
2382 
2384  for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
2385  TRY_TO(TraverseTypeLoc(S->getArg(I)->getTypeLoc()));
2386 })
2387 
2389  TRY_TO(TraverseTypeLoc(S->getQueriedTypeSourceInfo()->getTypeLoc()));
2390 })
2391 
2393  { TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getQueriedExpression()); })
2394 
2396  // The child-iterator will pick up the expression argument.
2397  TRY_TO(TraverseTypeLoc(S->getWrittenTypeInfo()->getTypeLoc()));
2398 })
2399 
2401  // This is called for code like 'return T()' where T is a class type.
2402  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2403 })
2404 
2405 // Walk only the visible parts of lambda expressions.
2407  for (unsigned I = 0, N = S->capture_size(); I != N; ++I) {
2408  const LambdaCapture *C = S->capture_begin() + I;
2409  if (C->isExplicit() || getDerived().shouldVisitImplicitCode()) {
2410  TRY_TO(TraverseLambdaCapture(S, C, S->capture_init_begin()[I]));
2411  }
2412  }
2413 
2414  TypeLoc TL = S->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
2416 
2417  if (S->hasExplicitParameters() && S->hasExplicitResultType()) {
2418  // Visit the whole type.
2419  TRY_TO(TraverseTypeLoc(TL));
2420  } else {
2421  if (S->hasExplicitParameters()) {
2422  // Visit parameters.
2423  for (unsigned I = 0, N = Proto.getNumParams(); I != N; ++I) {
2424  TRY_TO(TraverseDecl(Proto.getParam(I)));
2425  }
2426  } else if (S->hasExplicitResultType()) {
2428  }
2429 
2430  auto *T = Proto.getTypePtr();
2431  for (const auto &E : T->exceptions()) {
2432  TRY_TO(TraverseType(E));
2433  }
2434 
2435  if (Expr *NE = T->getNoexceptExpr())
2437  }
2438 
2439  ReturnValue = TRAVERSE_STMT_BASE(LambdaBody, LambdaExpr, S, Queue);
2440  ShouldVisitChildren = false;
2441 })
2442 
2444  // This is called for code like 'T()', where T is a template argument.
2445  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2446 })
2447 
2448 // These expressions all might take explicit template arguments.
2449 // We traverse those if so. FIXME: implement these.
2453 
2454 // These exprs (most of them), do not need any action except iterating
2455 // over the children.
2459 
2461  TRY_TO(TraverseDecl(S->getBlockDecl()));
2462  return true; // no child statements to loop through.
2463 })
2464 
2467  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2468 })
2471 
2474  TRY_TO(TraverseStmt(S->getExpr()));
2475 })
2476 
2483 
2485  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2486  if (TypeSourceInfo *ScopeInfo = S->getScopeTypeInfo())
2487  TRY_TO(TraverseTypeLoc(ScopeInfo->getTypeLoc()));
2488  if (TypeSourceInfo *DestroyedTypeInfo = S->getDestroyedTypeInfo())
2489  TRY_TO(TraverseTypeLoc(DestroyedTypeInfo->getTypeLoc()));
2490 })
2491 
2502  // FIXME: The source expression of the OVE should be listed as
2503  // a child of the ArrayInitLoopExpr.
2504  if (OpaqueValueExpr *OVE = S->getCommonExpr())
2505  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(OVE->getSourceExpr());
2506 })
2509 
2511  if (TypeSourceInfo *TInfo = S->getEncodedTypeSourceInfo())
2512  TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
2513 })
2514 
2517 
2519  if (TypeSourceInfo *TInfo = S->getClassReceiverTypeInfo())
2520  TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
2521 })
2522 
2528 
2530  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2531 })
2532 
2541  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2542  if (S->hasExplicitTemplateArgs()) {
2543  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2544  S->getNumTemplateArgs()));
2545  }
2546 })
2547 
2549  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2550  if (S->hasExplicitTemplateArgs()) {
2551  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2552  S->getNumTemplateArgs()));
2553  }
2554 })
2555 
2560 DEF_TRAVERSE_STMT(CapturedStmt, { TRY_TO(TraverseDecl(S->getCapturedDecl())); })
2561 
2566 
2567 // These operators (all of them) do not need any action except
2568 // iterating over the children.
2583 
2584 // For coroutines expressions, traverse either the operand
2585 // as written or the implied calls, depending on what the
2586 // derived class requests.
2589  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getBody());
2590  ShouldVisitChildren = false;
2591  }
2592 })
2594  if (!getDerived().shouldVisitImplicitCode()) {
2595  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand());
2596  ShouldVisitChildren = false;
2597  }
2598 })
2600  if (!getDerived().shouldVisitImplicitCode()) {
2601  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand());
2602  ShouldVisitChildren = false;
2603  }
2604 })
2606  if (!getDerived().shouldVisitImplicitCode()) {
2607  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand());
2608  ShouldVisitChildren = false;
2609  }
2610 })
2612  if (!getDerived().shouldVisitImplicitCode()) {
2613  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand());
2614  ShouldVisitChildren = false;
2615  }
2616 })
2617 
2618 // These literals (all of them) do not need any action.
2629 
2630 // Traverse OpenCL: AsType, Convert.
2632 
2633 // OpenMP directives.
2634 template <typename Derived>
2637  for (auto *C : S->clauses()) {
2638  TRY_TO(TraverseOMPClause(C));
2639  }
2640  return true;
2641 }
2642 
2643 template <typename Derived>
2644 bool
2646  return TraverseOMPExecutableDirective(S);
2647 }
2648 
2650  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2651 
2653  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2654 
2656  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2657 
2659  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2660 
2662  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2663 
2665  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2666 
2668  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2669 
2671  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2672 
2674  TRY_TO(TraverseDeclarationNameInfo(S->getDirectiveName()));
2675  TRY_TO(TraverseOMPExecutableDirective(S));
2676 })
2677 
2679  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2680 
2682  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2683 
2685  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2686 
2688  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2689 
2691  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2692 
2694  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2695 
2697  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2698 
2700  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2701 
2703  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2704 
2706  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2707 
2709  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2710 
2712  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2713 
2715  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2716 
2718  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2719 
2721  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2722 
2724  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2725 
2727  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2728 
2730  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2731 
2733  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2734 
2736  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2737 
2739  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2740 
2742  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2743 
2745  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2746 
2748  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2749 
2751  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2752 
2754  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2755 
2757  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2758 
2760  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2761 
2763  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2764 
2766  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2767 
2769  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2770 
2772  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2773 
2775  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2776 
2778  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2779 
2781  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2782 
2784  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2785 
2787  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2788 
2790  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2791 
2792 // OpenMP clauses.
2793 template <typename Derived>
2795  if (!C)
2796  return true;
2797  switch (C->getClauseKind()) {
2798 #define OPENMP_CLAUSE(Name, Class) \
2799  case OMPC_##Name: \
2800  TRY_TO(Visit##Class(static_cast<Class *>(C))); \
2801  break;
2802 #include "clang/Basic/OpenMPKinds.def"
2803  case OMPC_threadprivate:
2804  case OMPC_uniform:
2805  case OMPC_unknown:
2806  break;
2807  }
2808  return true;
2809 }
2810 
2811 template <typename Derived>
2815  return true;
2816 }
2817 
2818 template <typename Derived>
2820  OMPClauseWithPostUpdate *Node) {
2821  TRY_TO(VisitOMPClauseWithPreInit(Node));
2823  return true;
2824 }
2825 
2826 template <typename Derived>
2828  TRY_TO(VisitOMPClauseWithPreInit(C));
2830  return true;
2831 }
2832 
2833 template <typename Derived>
2836  return true;
2837 }
2838 
2839 template <typename Derived>
2840 bool
2842  TRY_TO(VisitOMPClauseWithPreInit(C));
2844  return true;
2845 }
2846 
2847 template <typename Derived>
2850  return true;
2851 }
2852 
2853 template <typename Derived>
2856  return true;
2857 }
2858 
2859 template <typename Derived>
2860 bool
2863  return true;
2864 }
2865 
2866 template <typename Derived>
2868  return true;
2869 }
2870 
2871 template <typename Derived>
2873  return true;
2874 }
2875 
2876 template <typename Derived>
2879  return true;
2880 }
2881 
2882 template <typename Derived>
2885  return true;
2886 }
2887 
2888 template <typename Derived>
2891  return true;
2892 }
2893 
2894 template <typename Derived>
2897  return true;
2898 }
2899 
2900 template <typename Derived>
2903  return true;
2904 }
2905 
2906 template <typename Derived>
2907 bool
2909  TRY_TO(VisitOMPClauseWithPreInit(C));
2911  return true;
2912 }
2913 
2914 template <typename Derived>
2917  return true;
2918 }
2919 
2920 template <typename Derived>
2922  return true;
2923 }
2924 
2925 template <typename Derived>
2927  return true;
2928 }
2929 
2930 template <typename Derived>
2931 bool
2933  return true;
2934 }
2935 
2936 template <typename Derived>
2938  return true;
2939 }
2940 
2941 template <typename Derived>
2943  return true;
2944 }
2945 
2946 template <typename Derived>
2948  return true;
2949 }
2950 
2951 template <typename Derived>
2953  return true;
2954 }
2955 
2956 template <typename Derived>
2958  return true;
2959 }
2960 
2961 template <typename Derived>
2963  return true;
2964 }
2965 
2966 template <typename Derived>
2968  return true;
2969 }
2970 
2971 template <typename Derived>
2973  return true;
2974 }
2975 
2976 template <typename Derived>
2977 template <typename T>
2979  for (auto *E : Node->varlists()) {
2980  TRY_TO(TraverseStmt(E));
2981  }
2982  return true;
2983 }
2984 
2985 template <typename Derived>
2987  TRY_TO(VisitOMPClauseList(C));
2988  for (auto *E : C->private_copies()) {
2989  TRY_TO(TraverseStmt(E));
2990  }
2991  return true;
2992 }
2993 
2994 template <typename Derived>
2996  OMPFirstprivateClause *C) {
2997  TRY_TO(VisitOMPClauseList(C));
2998  TRY_TO(VisitOMPClauseWithPreInit(C));
2999  for (auto *E : C->private_copies()) {
3000  TRY_TO(TraverseStmt(E));
3001  }
3002  for (auto *E : C->inits()) {
3003  TRY_TO(TraverseStmt(E));
3004  }
3005  return true;
3006 }
3007 
3008 template <typename Derived>
3010  OMPLastprivateClause *C) {
3011  TRY_TO(VisitOMPClauseList(C));
3012  TRY_TO(VisitOMPClauseWithPostUpdate(C));
3013  for (auto *E : C->private_copies()) {
3014  TRY_TO(TraverseStmt(E));
3015  }
3016  for (auto *E : C->source_exprs()) {
3017  TRY_TO(TraverseStmt(E));
3018  }
3019  for (auto *E : C->destination_exprs()) {
3020  TRY_TO(TraverseStmt(E));
3021  }
3022  for (auto *E : C->assignment_ops()) {
3023  TRY_TO(TraverseStmt(E));
3024  }
3025  return true;
3026 }
3027 
3028 template <typename Derived>
3030  TRY_TO(VisitOMPClauseList(C));
3031  return true;
3032 }
3033 
3034 template <typename Derived>
3036  TRY_TO(TraverseStmt(C->getStep()));
3037  TRY_TO(TraverseStmt(C->getCalcStep()));
3038  TRY_TO(VisitOMPClauseList(C));
3039  TRY_TO(VisitOMPClauseWithPostUpdate(C));
3040  for (auto *E : C->privates()) {
3041  TRY_TO(TraverseStmt(E));
3042  }
3043  for (auto *E : C->inits()) {
3044  TRY_TO(TraverseStmt(E));
3045  }
3046  for (auto *E : C->updates()) {
3047  TRY_TO(TraverseStmt(E));
3048  }
3049  for (auto *E : C->finals()) {
3050  TRY_TO(TraverseStmt(E));
3051  }
3052  return true;
3053 }
3054 
3055 template <typename Derived>
3058  TRY_TO(VisitOMPClauseList(C));
3059  return true;
3060 }
3061 
3062 template <typename Derived>
3064  TRY_TO(VisitOMPClauseList(C));
3065  for (auto *E : C->source_exprs()) {
3066  TRY_TO(TraverseStmt(E));
3067  }
3068  for (auto *E : C->destination_exprs()) {
3069  TRY_TO(TraverseStmt(E));
3070  }
3071  for (auto *E : C->assignment_ops()) {
3072  TRY_TO(TraverseStmt(E));
3073  }
3074  return true;
3075 }
3076 
3077 template <typename Derived>
3079  OMPCopyprivateClause *C) {
3080  TRY_TO(VisitOMPClauseList(C));
3081  for (auto *E : C->source_exprs()) {
3082  TRY_TO(TraverseStmt(E));
3083  }
3084  for (auto *E : C->destination_exprs()) {
3085  TRY_TO(TraverseStmt(E));
3086  }
3087  for (auto *E : C->assignment_ops()) {
3088  TRY_TO(TraverseStmt(E));
3089  }
3090  return true;
3091 }
3092 
3093 template <typename Derived>
3094 bool
3098  TRY_TO(VisitOMPClauseList(C));
3099  TRY_TO(VisitOMPClauseWithPostUpdate(C));
3100  for (auto *E : C->privates()) {
3101  TRY_TO(TraverseStmt(E));
3102  }
3103  for (auto *E : C->lhs_exprs()) {
3104  TRY_TO(TraverseStmt(E));
3105  }
3106  for (auto *E : C->rhs_exprs()) {
3107  TRY_TO(TraverseStmt(E));
3108  }
3109  for (auto *E : C->reduction_ops()) {
3110  TRY_TO(TraverseStmt(E));
3111  }
3112  return true;
3113 }
3114 
3115 template <typename Derived>
3120  TRY_TO(VisitOMPClauseList(C));
3121  TRY_TO(VisitOMPClauseWithPostUpdate(C));
3122  for (auto *E : C->privates()) {
3123  TRY_TO(TraverseStmt(E));
3124  }
3125  for (auto *E : C->lhs_exprs()) {
3126  TRY_TO(TraverseStmt(E));
3127  }
3128  for (auto *E : C->rhs_exprs()) {
3129  TRY_TO(TraverseStmt(E));
3130  }
3131  for (auto *E : C->reduction_ops()) {
3132  TRY_TO(TraverseStmt(E));
3133  }
3134  return true;
3135 }
3136 
3137 template <typename Derived>
3139  OMPInReductionClause *C) {
3142  TRY_TO(VisitOMPClauseList(C));
3143  TRY_TO(VisitOMPClauseWithPostUpdate(C));
3144  for (auto *E : C->privates()) {
3145  TRY_TO(TraverseStmt(E));
3146  }
3147  for (auto *E : C->lhs_exprs()) {
3148  TRY_TO(TraverseStmt(E));
3149  }
3150  for (auto *E : C->rhs_exprs()) {
3151  TRY_TO(TraverseStmt(E));
3152  }
3153  for (auto *E : C->reduction_ops()) {
3154  TRY_TO(TraverseStmt(E));
3155  }
3156  for (auto *E : C->taskgroup_descriptors())
3157  TRY_TO(TraverseStmt(E));
3158  return true;
3159 }
3160 
3161 template <typename Derived>
3163  TRY_TO(VisitOMPClauseList(C));
3164  return true;
3165 }
3166 
3167 template <typename Derived>
3169  TRY_TO(VisitOMPClauseList(C));
3170  return true;
3171 }
3172 
3173 template <typename Derived>
3175  TRY_TO(VisitOMPClauseWithPreInit(C));
3176  TRY_TO(TraverseStmt(C->getDevice()));
3177  return true;
3178 }
3179 
3180 template <typename Derived>
3182  TRY_TO(VisitOMPClauseList(C));
3183  return true;
3184 }
3185 
3186 template <typename Derived>
3188  OMPNumTeamsClause *C) {
3189  TRY_TO(VisitOMPClauseWithPreInit(C));
3191  return true;
3192 }
3193 
3194 template <typename Derived>
3196  OMPThreadLimitClause *C) {
3197  TRY_TO(VisitOMPClauseWithPreInit(C));
3199  return true;
3200 }
3201 
3202 template <typename Derived>
3204  OMPPriorityClause *C) {
3206  return true;
3207 }
3208 
3209 template <typename Derived>
3211  OMPGrainsizeClause *C) {
3213  return true;
3214 }
3215 
3216 template <typename Derived>
3218  OMPNumTasksClause *C) {
3220  return true;
3221 }
3222 
3223 template <typename Derived>
3225  TRY_TO(TraverseStmt(C->getHint()));
3226  return true;
3227 }
3228 
3229 template <typename Derived>
3231  OMPDistScheduleClause *C) {
3232  TRY_TO(VisitOMPClauseWithPreInit(C));
3234  return true;
3235 }
3236 
3237 template <typename Derived>
3238 bool
3240  return true;
3241 }
3242 
3243 template <typename Derived>
3245  TRY_TO(VisitOMPClauseList(C));
3246  return true;
3247 }
3248 
3249 template <typename Derived>
3251  TRY_TO(VisitOMPClauseList(C));
3252  return true;
3253 }
3254 
3255 template <typename Derived>
3257  OMPUseDevicePtrClause *C) {
3258  TRY_TO(VisitOMPClauseList(C));
3259  return true;
3260 }
3261 
3262 template <typename Derived>
3264  OMPIsDevicePtrClause *C) {
3265  TRY_TO(VisitOMPClauseList(C));
3266  return true;
3267 }
3268 
3269 // FIXME: look at the following tricky-seeming exprs to see if we
3270 // need to recurse on anything. These are ones that have methods
3271 // returning decls or qualtypes or nestednamespecifier -- though I'm
3272 // not sure if they own them -- or just seemed very complicated, or
3273 // had lots of sub-types to explore.
3274 //
3275 // VisitOverloadExpr and its children: recurse on template args? etc?
3276 
3277 // FIXME: go through all the stmts and exprs again, and see which of them
3278 // create new types, and recurse on the types (TypeLocs?) of those.
3279 // Candidates:
3280 //
3281 // http://clang.llvm.org/doxygen/classclang_1_1CXXTypeidExpr.html
3282 // http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html
3283 // http://clang.llvm.org/doxygen/classclang_1_1TypesCompatibleExpr.html
3284 // Every class that has getQualifier.
3285 
3286 #undef DEF_TRAVERSE_STMT
3287 #undef TRAVERSE_STMT
3288 #undef TRAVERSE_STMT_BASE
3289 
3290 #undef TRY_TO
3291 
3292 } // end namespace clang
3293 
3294 #endif // LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:577
A call to an overloaded operator written using operator syntax.
Definition: ExprCXX.h:78
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition: ExprObjC.h:1518
This represents &#39;#pragma omp distribute simd&#39; composite directive.
Definition: StmtOpenMP.h:3248
This represents &#39;#pragma omp master&#39; directive.
Definition: StmtOpenMP.h:1431
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
Definition: Type.h:5115
VarDecl * getCapturedVar() const
Retrieve the declaration of the local variable being captured.
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:591
This represents &#39;#pragma omp task&#39; directive.
Definition: StmtOpenMP.h:1771
This represents a GCC inline-assembly statement extension.
Definition: Stmt.h:2455
Represents a function declaration or definition.
Definition: Decl.h:1739
Represents a &#39;co_await&#39; expression while the type of the promise is dependent.
Definition: ExprCXX.h:4346
helper_expr_const_range reduction_ops() const
This represents &#39;thread_limit&#39; clause in the &#39;#pragma omp ...&#39; directive.
Expr * getInit() const
Get the initializer.
Definition: DeclCXX.h:2451
bool TraverseLambdaBody(LambdaExpr *LE, DataRecursionQueue *Queue=nullptr)
Recursively visit the body of a lambda expression.
bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier &Base)
Recursively visit a base specifier.
helper_expr_const_range lhs_exprs() const
This represents clause &#39;copyin&#39; in the &#39;#pragma omp ...&#39; directives.
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:496
A (possibly-)qualified type.
Definition: Type.h:642
base_class_range bases()
Definition: DeclCXX.h:823
#define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND)
ArrayRef< OMPClause * > clauses()
Definition: StmtOpenMP.h:260
bool shouldWalkTypesOfTypeLocs() const
Return whether this visitor should recurse into the types of TypeLocs.
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2355
This represents &#39;atomic_default_mem_order&#39; clause in the &#39;#pragma omp requires&#39; directive.
Definition: OpenMPClause.h:870
DEF_TRAVERSE_TYPE(ComplexType, { TRY_TO(TraverseType(T->getElementType()));}) DEF_TRAVERSE_TYPE(PointerType
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Definition: TemplateBase.h:532
virtual Stmt * getBody() const
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition: DeclBase.h:979
helper_expr_const_range rhs_exprs() const
private_copies_range private_copies()
Expr *const * semantics_iterator
Definition: Expr.h:5311
Represents a &#39;co_return&#39; statement in the C++ Coroutines TS.
Definition: StmtCXX.h:435
Stmt - This represents one statement.
Definition: Stmt.h:66
This represents clause &#39;in_reduction&#39; in the &#39;#pragma omp task&#39; directives.
IfStmt - This represents an if/then/else.
Definition: Stmt.h:1467
#define UNARYOP_LIST()
Class that handles pre-initialization statement for some clauses, like &#39;shedule&#39;, &#39;firstprivate&#39; etc...
Definition: OpenMPClause.h:99
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:2795
Represents the declaration of a typedef-name via the &#39;typedef&#39; type specifier.
Definition: Decl.h:3027
C Language Family Type Representation.
Microsoft&#39;s &#39;__super&#39; specifier, stored as a CXXRecordDecl* of the class it appeared in...
Represents a qualified type name for which the type name is dependent.
Definition: Type.h:5198
This represents &#39;#pragma omp for simd&#39; directive.
Definition: StmtOpenMP.h:1181
spec_range specializations() const
The template argument is an expression, and we&#39;ve not resolved it to one of the other forms yet...
Definition: TemplateBase.h:87
#define TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S)
helper_expr_const_range rhs_exprs() const
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:87
This represents &#39;grainsize&#39; clause in the &#39;#pragma omp ...&#39; directive.
bool shouldTraversePostOrder() const
Return whether this visitor should traverse post-order.
This represents &#39;#pragma omp teams distribute parallel for&#39; composite directive.
Definition: StmtOpenMP.h:3659
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition: Expr.h:4804
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:2748
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
This represents &#39;if&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:240
Defines the C++ template declaration subclasses.
bool isWritten() const
Determine whether this initializer is explicitly written in the source code.
Definition: DeclCXX.h:2421
StringRef P
Represents an attribute applied to a statement.
Definition: Stmt.h:1413
ParenExpr - This represents a parethesized expression, e.g.
Definition: Expr.h:1855
helper_expr_const_range assignment_ops() const
bool isCXXForRangeDecl() const
Determine whether this variable is the for-range-declaration in a C++0x for-range statement...
Definition: Decl.h:1334
This represents &#39;priority&#39; clause in the &#39;#pragma omp ...&#39; directive.
The base class of the type hierarchy.
Definition: Type.h:1415
Represents an empty-declaration.
Definition: Decl.h:4268
helper_expr_const_range lhs_exprs() const
This represents &#39;#pragma omp target teams distribute&#39; combined directive.
Definition: StmtOpenMP.h:3796
Represents Objective-C&#39;s @throw statement.
Definition: StmtObjC.h:313
bool isSemanticForm() const
Definition: Expr.h:4281
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:878
Declaration of a variable template.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Definition: TemplateBase.h:64
Represent a C++ namespace.
Definition: Decl.h:514
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1257
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition: ExprObjC.h:803
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent...
Definition: ExprCXX.h:2439
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:365
A container of type source information.
Definition: Decl.h:86
This represents &#39;update&#39; clause in the &#39;#pragma omp atomic&#39; directive.
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:308
This represents &#39;#pragma omp parallel for&#39; directive.
Definition: StmtOpenMP.h:1552
MS property subscript expression.
Definition: ExprCXX.h:823
DEF_TRAVERSE_DECL(BlockDecl, { if(TypeSourceInfo *TInfo=D->getSignatureAsWritten()) TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));TRY_TO(TraverseStmt(D->getBody()));for(const auto &I :D->captures()) { if(I.hasCopyExpr()) { TRY_TO(TraverseStmt(I.getCopyExpr()));} } ShouldVisitChildren=false;}) DEF_TRAVERSE_DECL(CapturedDecl
This represents &#39;#pragma omp target teams distribute parallel for&#39; combined directive.
Definition: StmtOpenMP.h:3864
bool TraverseTemplateName(TemplateName Template)
Recursively visit a template name and dispatch to the appropriate method.
Describes the capture of a variable or of this, or of a C++1y init-capture.
Definition: LambdaCapture.h:26
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2481
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:4047
Expr * getAlignment()
Returns alignment.
Expr * getNumForLoops() const
Return the number of associated for-loops.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3178
Represents a #pragma comment line.
Definition: Decl.h:139
An identifier, stored as an IdentifierInfo*.
This represents &#39;#pragma omp target exit data&#39; directive.
Definition: StmtOpenMP.h:2463
This represents &#39;read&#39; clause in the &#39;#pragma omp atomic&#39; directive.
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
Definition: DeclFriend.h:54
helper_expr_const_range assignment_ops() const
TRY_TO(TraverseType(T->getPointeeType()))
Represents a variable declaration or definition.
Definition: Decl.h:812
This represents clause &#39;private&#39; in the &#39;#pragma omp ...&#39; directives.
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC &#39;id&#39; type.
Definition: ExprObjC.h:1437
This represents &#39;num_threads&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:382
CompoundLiteralExpr - [C99 6.5.2.5].
Definition: Expr.h:2844
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
Definition: TypeLoc.h:271
Derived & getDerived()
Return a reference to the derived class.
Represents an empty template argument, e.g., one that has not been deduced.
Definition: TemplateBase.h:57
This represents &#39;defaultmap&#39; clause in the &#39;#pragma omp ...&#39; directive.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
Definition: DeclBase.h:1997
Declaration context for names declared as extern "C" in C++.
Definition: Decl.h:221
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:139
bool dataTraverseStmtPre(Stmt *S)
Invoked before visiting a statement or expression via data recursion.
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:601
A namespace, stored as a NamespaceDecl*.
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition: ExprCXX.h:619
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:68
#define BINOP_LIST()
This represents implicit clause &#39;flush&#39; for the &#39;#pragma omp flush&#39; directive.
Defines the Objective-C statement AST node classes.
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:1010
This represents &#39;reverse_offload&#39; clause in the &#39;#pragma omp requires&#39; directive. ...
Definition: OpenMPClause.h:807
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
Definition: ExprCXX.h:3012
Represents a parameter to a function.
Definition: Decl.h:1551
Defines the clang::Expr interface and subclasses for C++ expressions.
SmallVectorImpl< llvm::PointerIntPair< Stmt *, 1, bool > > DataRecursionQueue
A queue used for performing data recursion over statements.
Expr * getGrainsize() const
Return safe iteration space distance.
This represents &#39;nogroup&#39; clause in the &#39;#pragma omp ...&#39; directive.
bool TraverseDecl(Decl *D)
Recursively visit a declaration, by dispatching to Traverse*Decl() based on the argument&#39;s dynamic ty...
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
This represents &#39;safelen&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:447
PipeType - OpenCL20.
Definition: Type.h:5988
A C++ static_cast expression (C++ [expr.static.cast]).
Definition: ExprCXX.h:307
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:57
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:1373
Represents a struct/union/class.
Definition: Decl.h:3602
Represents a C99 designated initializer expression.
Definition: Expr.h:4365
This represents &#39;#pragma omp parallel&#39; directive.
Definition: StmtOpenMP.h:276
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition: Expr.h:3792
Represents a class type in Objective C.
Definition: Type.h:5524
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:330
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:154
A C++ nested-name-specifier augmented with source location information.
Represents a dependent template name that cannot be resolved prior to template instantiation.
Definition: TemplateName.h:422
This represents &#39;simd&#39; clause in the &#39;#pragma omp ...&#39; directive.
TypeSourceInfo * getTypeSourceInfo() const
Definition: TemplateBase.h:507
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Definition: TemplateBase.h:72
#define TYPE(CLASS, BASE)
NameKind getNameKind() const
Determine what kind of name this is.
Represents a member of a struct/union/class.
Definition: Decl.h:2588
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
This represents clause &#39;lastprivate&#39; in the &#39;#pragma omp ...&#39; directives.
TypeSourceInfo * getTypeSourceInfo() const
Returns the declarator information for a base class or delegating initializer.
Definition: DeclCXX.h:2383
Represents a place-holder for an object not to be initialized by anything.
Definition: Expr.h:4659
CompoundStmt * getBody() const
Retrieve the body of the lambda.
Definition: ExprCXX.cpp:1030
Expr * getChunkSize()
Get chunk size.
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Definition: Expr.h:4003
This represents clause &#39;map&#39; in the &#39;#pragma omp ...&#39; directives.
This represents clause &#39;to&#39; in the &#39;#pragma omp ...&#39; directives.
ParmVarDecl * getParam(unsigned i) const
Definition: TypeLoc.h:1408
This represents &#39;#pragma omp target simd&#39; directive.
Definition: StmtOpenMP.h:3384
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
Definition: ExprCXX.h:3450
Defines some OpenMP-specific enums and functions.
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition: Expr.h:5062
Expr * getSafelen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:481
bool TraverseSynOrSemInitListExpr(InitListExpr *S, DataRecursionQueue *Queue=nullptr)
Recursively visit the syntactic or semantic form of an initialization list.
This represents &#39;#pragma omp barrier&#39; directive.
Definition: StmtOpenMP.h:1883
Wrapper of type source information for a type with no direct qualifiers.
Definition: TypeLoc.h:245
Declaration of a function specialization at template class scope.
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
Definition: ExprObjC.h:171
This is a common base class for loop directives (&#39;omp simd&#39;, &#39;omp for&#39;, &#39;omp for simd&#39; etc...
Definition: StmtOpenMP.h:338
Expr * getNumTeams()
Return NumTeams number.
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition: ExprCXX.h:3905
This represents &#39;#pragma omp critical&#39; directive.
Definition: StmtOpenMP.h:1478
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:2263
Represents Objective-C&#39;s @catch statement.
Definition: StmtObjC.h:74
#define TRY_TO(CALL_EXPR)
#define DEF_TRAVERSE_TMPL_DECL(TMPLDECLKIND)
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Definition: DeclTemplate.h:508
Stmt::child_range getStmtChildren(Stmt *S)
This represents clause &#39;copyprivate&#39; in the &#39;#pragma omp ...&#39; directives.
IndirectGotoStmt - This represents an indirect goto.
Definition: Stmt.h:2119
Describes an C or C++ initializer list.
Definition: Expr.h:4131
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition: ExprCXX.h:664
Represents a C++ using-declaration.
Definition: DeclCXX.h:3349
This represents &#39;#pragma omp distribute parallel for&#39; composite directive.
Definition: StmtOpenMP.h:3099
This represents &#39;#pragma omp teams distribute parallel for simd&#39; composite directive.
Definition: StmtOpenMP.h:3588
ForStmt - This represents a &#39;for (init;cond;inc)&#39; stmt.
Definition: Stmt.h:2017
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Definition: Decl.cpp:2731
A convenient class for passing around template argument information.
Definition: TemplateBase.h:552
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
bool TraverseDeclarationNameInfo(DeclarationNameInfo NameInfo)
Recursively visit a name with its location information.
const Stmt * getPreInitStmt() const
Get pre-initialization statement for the clause.
Definition: OpenMPClause.h:121
child_range children()
Definition: Stmt.cpp:237
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3233
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
Definition: Decl.h:752
CXXForRangeStmt - This represents C++0x [stmt.ranged]&#39;s ranged for statement, represented as &#39;for (ra...
Definition: StmtCXX.h:127
bool isNull() const
Definition: TypeLoc.h:119
child_range children()
Definition: Expr.h:4314
Class that handles post-update expression for some clauses, like &#39;lastprivate&#39;, &#39;reduction&#39; etc...
Definition: OpenMPClause.h:135
const TemplateArgumentLoc * getArgumentArray() const
Definition: TemplateBase.h:576
This represents &#39;#pragma omp cancellation point&#39; directive.
Definition: StmtOpenMP.h:2718
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
Definition: Decl.cpp:3483
This represents &#39;default&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:606
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition: ExprObjC.h:51
spec_range specializations() const
CaseStmt - Represent a case statement.
Definition: Stmt.h:1174
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
Definition: Expr.h:5508
This represents &#39;final&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:330
This represents &#39;mergeable&#39; clause in the &#39;#pragma omp ...&#39; directive.
This represents &#39;#pragma omp teams&#39; directive.
Definition: StmtOpenMP.h:2661
This represents clause &#39;reduction&#39; in the &#39;#pragma omp ...&#39; directives.
This represents &#39;#pragma omp teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:3518
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2056
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1212
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1606
helper_expr_const_range source_exprs() const
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3213
This represents clause &#39;is_device_ptr&#39; in the &#39;#pragma omp ...&#39; directives.
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
Represents an ObjC class declaration.
Definition: DeclObjC.h:1164
#define DEF_TRAVERSE_TMPL_PART_SPEC_DECL(TMPLDECLKIND, DECLKIND)
Represents a linkage specification.
Definition: DeclCXX.h:2823
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda&#39;s captures is an init-capture.
Definition: ExprCXX.cpp:972
A binding in a decomposition declaration.
Definition: DeclCXX.h:3792
helper_expr_const_range source_exprs() const
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1068
helper_expr_const_range privates() const
This represents clause &#39;from&#39; in the &#39;#pragma omp ...&#39; directives.
Represents the this expression in C++.
Definition: ExprCXX.h:971
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2751
helper_expr_const_range reduction_ops() const
This represents &#39;#pragma omp target parallel for simd&#39; directive.
Definition: StmtOpenMP.h:3316
OpenMP 4.0 [2.4, Array Sections].
Definition: ExprOpenMP.h:45
This represents &#39;dynamic_allocators&#39; clause in the &#39;#pragma omp requires&#39; directive.
Definition: OpenMPClause.h:838
ConditionalOperator - The ?: ternary operator.
Definition: Expr.h:3528
#define CAO_LIST()
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition: ExprCXX.h:2211
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition: Decl.h:3047
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1021
This represents &#39;threads&#39; clause in the &#39;#pragma omp ...&#39; directive.
helper_expr_const_range destination_exprs() const
This represents &#39;#pragma omp taskgroup&#39; directive.
Definition: StmtOpenMP.h:1971
Expr * getSimdlen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:535
helper_expr_const_range source_exprs() const
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
Definition: DeclCXX.cpp:1627
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:688
This represents clause &#39;aligned&#39; in the &#39;#pragma omp ...&#39; directives.
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
Definition: OpenMPClause.h:79
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
Definition: Expr.h:2233
helper_expr_const_range private_copies() const
This represents clause &#39;task_reduction&#39; in the &#39;#pragma omp taskgroup&#39; directives.
ConstantExpr - An expression that occurs in a constant context.
Definition: Expr.h:904
Represents a call to the builtin function __builtin_va_arg.
Definition: Expr.h:4037
helper_expr_const_range destination_exprs() const
spec_range specializations() const
This represents &#39;#pragma omp requires...&#39; directive.
Definition: DeclOpenMP.h:250
This represents &#39;#pragma omp distribute&#39; directive.
Definition: StmtOpenMP.h:2972
This represents implicit clause &#39;depend&#39; for the &#39;#pragma omp task&#39; directive.
DEF_TRAVERSE_TYPELOC(ComplexType, { TRY_TO(TraverseType(TL.getTypePtr() ->getElementType()));}) DEF_TRAVERSE_TYPELOC(PointerType
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:432
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type...
Definition: ExprCXX.h:1828
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition: DeclCXX.h:3237
This represents &#39;proc_bind&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:675
This represents &#39;capture&#39; clause in the &#39;#pragma omp atomic&#39; directive.
This represents one expression.
Definition: Expr.h:106
bool TraverseConstructorInitializer(CXXCtorInitializer *Init)
Recursively visit a constructor initializer.
This represents &#39;simdlen&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:501
Declaration of a template type parameter.
Expr * getNumTasks() const
Return safe iteration space distance.
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
Definition: TypeLoc.h:320
Represents a C++ functional cast expression that builds a temporary object.
Definition: ExprCXX.h:1556
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Definition: TemplateBase.h:68
A C++ const_cast expression (C++ [expr.const.cast]).
Definition: ExprCXX.h:440
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:5123
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2703
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
Definition: Decl.h:1984
bool WalkUpFromQualifiedTypeLoc(QualifiedTypeLoc TL)
bool canIgnoreChildDeclWhileTraversingDeclContext(const Decl *Child)
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:547
This represents &#39;#pragma omp target teams distribute parallel for simd&#39; combined directive.
Definition: StmtOpenMP.h:3948
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition: ExprObjC.h:288
Represents Objective-C&#39;s @synchronized statement.
Definition: StmtObjC.h:262
ObjCSelectorExpr used for @selector in Objective-C.
Definition: ExprObjC.h:429
TypeSourceInfo * getNamedTypeInfo() const
getNamedTypeInfo - Returns the source type info associated to the name.
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
Represents an expression that computes the length of a parameter pack.
Definition: ExprCXX.h:3735
CXXTryStmt - A C++ try block, including all handlers.
Definition: StmtCXX.h:65
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition: Expr.h:5172
bool VisitQualifiedTypeLoc(QualifiedTypeLoc TL)
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
Definition: TemplateName.h:178
This represents &#39;#pragma omp target teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:4021
helper_expr_const_range rhs_exprs() const
Defines the clang::TypeLoc interface and its subclasses.
A namespace alias, stored as a NamespaceAliasDecl*.
This represents &#39;ordered&#39; clause in the &#39;#pragma omp ...&#39; directive.
bool TraverseAST(ASTContext &AST)
Recursively visits an entire AST, starting from the top-level Decls in the AST traversal scope (by de...
This represents &#39;#pragma omp for&#39; directive.
Definition: StmtOpenMP.h:1104
Declaration of an alias template.
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4157
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
Definition: Stmt.h:2223
This represents &#39;#pragma omp target teams&#39; directive.
Definition: StmtOpenMP.h:3737
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:904
This represents a Microsoft inline-assembly statement extension.
Definition: Stmt.h:2630
UnaryOperator - This represents the unary-expression&#39;s (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Definition: Expr.h:1907
A member reference to an MSPropertyDecl.
Definition: ExprCXX.h:754
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:3849
Expr * getDevice()
Return device number.
This represents &#39;#pragma omp cancel&#39; directive.
Definition: StmtOpenMP.h:2776
This represents &#39;collapse&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:555
This represents clause &#39;firstprivate&#39; in the &#39;#pragma omp ...&#39; directives.
Represents a C++ deduction guide declaration.
Definition: DeclCXX.h:1988
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2765
This template specialization was implicitly instantiated from a template.
Definition: Specifiers.h:152
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr.cast]), which uses the syntax (Type)expr.
Definition: Expr.h:3165
bool isNull() const
Return true if this QualType doesn&#39;t point to a type yet.
Definition: Type.h:707
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition: TypeLoc.h:2282
TypeLoc getReturnLoc() const
Definition: TypeLoc.h:1411
This file defines OpenMP AST classes for clauses.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
Definition: Expr.h:1528
This represents &#39;#pragma omp flush&#39; directive.
Definition: StmtOpenMP.h:2044
This represents &#39;#pragma omp parallel for simd&#39; directive.
Definition: StmtOpenMP.h:1632
DoStmt - This represents a &#39;do/while&#39; stmt.
Definition: Stmt.h:1965
This represents &#39;seq_cst&#39; clause in the &#39;#pragma omp atomic&#39; directive.
helper_expr_const_range assignment_ops() const
This represents &#39;untied&#39; clause in the &#39;#pragma omp ...&#39; directive.
This represents &#39;unified_address&#39; clause in the &#39;#pragma omp requires&#39; directive. ...
Definition: OpenMPClause.h:745
This represents &#39;#pragma omp target enter data&#39; directive.
Definition: StmtOpenMP.h:2404
Represents a C++ Modules TS module export declaration.
Definition: Decl.h:4223
bool WalkUpFromUnqualTypeLoc(UnqualTypeLoc TL)
This represents &#39;num_teams&#39; clause in the &#39;#pragma omp ...&#39; directive.
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition: ExprCXX.h:348
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Definition: Expr.h:945
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition: Expr.h:3860
This captures a statement into a function.
Definition: Stmt.h:2885
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition: ExprCXX.h:1418
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:5245
bool shouldVisitTemplateInstantiations() const
Return whether this visitor should recurse into template instantiations.
helper_expr_const_range taskgroup_descriptors() const
This represents &#39;#pragma omp single&#39; directive.
Definition: StmtOpenMP.h:1376
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Sugar for parentheses used when specifying types.
Definition: Type.h:2513
This represents &#39;hint&#39; clause in the &#39;#pragma omp ...&#39; directive.
This represents &#39;#pragma omp declare reduction ...&#39; directive.
Definition: DeclOpenMP.h:103
Pseudo declaration for capturing expressions.
Definition: DeclOpenMP.h:217
Interfaces are the core concept in Objective-C for object oriented design.
Definition: Type.h:5724
bool TraverseTypeLoc(TypeLoc TL)
Recursively visit a type with location, by dispatching to Traverse*TypeLoc() based on the argument ty...
This is a basic class for representing single OpenMP executable directive.
Definition: StmtOpenMP.h:33
private_copies_range private_copies()
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Definition: ExprCXX.h:1868
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit...
Definition: ExprCXX.h:482
DeclarationName getName() const
getName - Returns the embedded declaration name.
This represents &#39;schedule&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:948
Represents a call to a member function that may be written either with member call syntax (e...
Definition: ExprCXX.h:166
#define TRAVERSE_STMT_BASE(NAME, CLASS, VAR, QUEUE)
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Definition: Stmt.h:923
Represents the declaration of a label.
Definition: Decl.h:468
This represents clause &#39;shared&#39; in the &#39;#pragma omp ...&#39; directives.
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3568
bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Recursively visit a C++ nested-name-specifier with location information.
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2041
Expr * getPriority()
Return Priority number.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
This represents &#39;#pragma omp taskwait&#39; directive.
Definition: StmtOpenMP.h:1927
This file defines OpenMP nodes for declarative directives.
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2272
unsigned pack_size() const
The number of template arguments in the given template argument pack.
Definition: TemplateBase.h:360
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:51
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the similarly-named C++11 instructions, and __c11 variants for <stdatomic.h>, and corresponding __opencl_atomic_* for OpenCL 2.0.
Definition: Expr.h:5379
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition: ExprObjC.h:474
bool TraverseStmt(Stmt *S, DataRecursionQueue *Queue=nullptr)
Recursively visit a statement or expression, by dispatching to Traverse*() based on the argument&#39;s dy...
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:721
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:3051
This represents &#39;#pragma omp target&#39; directive.
Definition: StmtOpenMP.h:2288
Expr * getNumForLoops() const
Return the number of associated for-loops.
Definition: OpenMPClause.h:590
TypeClass getTypeClass() const
Definition: Type.h:1817
This template specialization was instantiated from a template due to an explicit instantiation defini...
Definition: Specifiers.h:164
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
Definition: Specifiers.h:149
bool isExplicit() const
Determine whether this was an explicit capture (written between the square brackets introducing the l...
An expression trait intrinsic.
Definition: ExprCXX.h:2505
DeclarationNameInfo getNameInfo() const
Definition: Decl.h:1902
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3743
This represents &#39;#pragma omp ordered&#39; directive.
Definition: StmtOpenMP.h:2099
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition: Expr.h:3747
This represents &#39;#pragma omp target update&#39; directive.
Definition: StmtOpenMP.h:3040
ObjCBoxedExpr - used for generalized expression boxing.
Definition: ExprObjC.h:117
bool TraverseType(QualType T)
Recursively visit a type, by dispatching to Traverse*Type() based on the argument&#39;s getTypeClass() pr...
TypeSourceInfo * getTypeSourceInfo() const
Retrieves the type and source location of the base class.
Definition: DeclCXX.h:296
std::vector< Decl * > getTraversalScope() const
Definition: ASTContext.h:620
helper_expr_const_range lhs_exprs() const
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name...
Definition: StmtCXX.h:241
bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C, Expr *Init)
Recursively visit a lambda capture.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:4158
The injected class name of a C++ class template or class template partial specialization.
Definition: Type.h:4964
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:2866
Represents a pack expansion of types.
Definition: Type.h:5341
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:3450
Defines various enumerations that describe declaration and type specifiers.
Represents a C11 generic selection.
Definition: Expr.h:4956
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
Definition: Decl.h:3300
bool shouldVisitImplicitCode() const
Return whether this visitor should recurse into implicit code, e.g., implicit constructors and destru...
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:3703
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers...
Definition: ExprObjC.h:1575
ast_type_traits::DynTypedNode Node
Represents a reference to a function parameter pack that has been substituted but not yet expanded...
Definition: ExprCXX.h:3969
Represents a template argument.
Definition: TemplateBase.h:51
Represents a template name that was expressed as a qualified name.
Definition: TemplateName.h:366
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition: Stmt.h:990
Dataflow Directional Tag Classes.
This represents &#39;device&#39; clause in the &#39;#pragma omp ...&#39; directive.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:499
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1769
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1262
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:2095
helper_expr_const_range privates() const
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:80
attr_range attrs() const
Definition: DeclBase.h:490
This represents &#39;#pragma omp section&#39; directive.
Definition: StmtOpenMP.h:1314
This represents &#39;#pragma omp teams distribute&#39; directive.
Definition: StmtOpenMP.h:3450
#define DEF_TRAVERSE_TMPL_INST(TMPLDECLKIND)
Represents a field injected from an anonymous union/struct into the parent scope. ...
Definition: Decl.h:2834
Expr * getSourceExpression() const
Definition: TemplateBase.h:512
const Expr * getInit() const
Definition: Decl.h:1219
A runtime availability query.
Definition: ExprObjC.h:1641
A decomposition declaration.
Definition: DeclCXX.h:3840
This template specialization was instantiated from a template due to an explicit instantiation declar...
Definition: Specifiers.h:160
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition: ExprCXX.h:395
This represents &#39;#pragma omp simd&#39; directive.
Definition: StmtOpenMP.h:1039
Represents a &#39;co_yield&#39; expression.
Definition: ExprCXX.h:4393
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3664
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:551
Kind getKind() const
Definition: DeclBase.h:421
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:3663
This represents &#39;unified_shared_memory&#39; clause in the &#39;#pragma omp requires&#39; directive.
Definition: OpenMPClause.h:776
This represents clause &#39;linear&#39; in the &#39;#pragma omp ...&#39; directives.
Represents an enum.
Definition: Decl.h:3335
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
This represents &#39;#pragma omp atomic&#39; directive.
Definition: StmtOpenMP.h:2154
A type that was preceded by the &#39;template&#39; keyword, stored as a Type*.
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
Definition: TemplateBase.h:340
Represents a __leave statement.
Definition: Stmt.h:2850
unsigned getNumParams() const
Definition: TypeLoc.h:1402
Represents a pointer to an Objective C object.
Definition: Type.h:5780
helper_expr_const_range privates() const
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition: ExprCXX.h:3611
SwitchStmt - This represents a &#39;switch&#39; stmt.
Definition: Stmt.h:1666
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2544
Represents the body of a coroutine.
Definition: StmtCXX.h:302
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:450
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2323
This file defines OpenMP AST classes for executable directives and clauses.
Represents Objective-C&#39;s collection statement.
Definition: StmtObjC.h:24
bool TraverseTemplateArgument(const TemplateArgument &Arg)
Recursively visit a template argument and dispatch to the appropriate method for the argument type...
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2253
This template specialization was declared or defined by an explicit specialization (C++ [temp...
Definition: Specifiers.h:156
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:386
helper_expr_const_range destination_exprs() const
Represents a call to a CUDA kernel function.
Definition: ExprCXX.h:206
Represents a &#39;co_await&#39; expression.
Definition: ExprCXX.h:4310
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:715
TypeLocClass getTypeLocClass() const
Definition: TypeLoc.h:114
Represents Objective-C&#39;s @finally statement.
Definition: StmtObjC.h:120
The template argument is a type.
Definition: TemplateBase.h:60
bool TraverseNestedNameSpecifier(NestedNameSpecifier *NNS)
Recursively visit a C++ nested-name-specifier.
The template argument is actually a parameter pack.
Definition: TemplateBase.h:91
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
Represents a base class of a C++ class.
Definition: DeclCXX.h:192
This represents &#39;write&#39; clause in the &#39;#pragma omp atomic&#39; directive.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:513
UnqualTypeLoc getUnqualifiedLoc() const
Definition: TypeLoc.h:275
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3092
GotoStmt - This represents a direct goto.
Definition: Stmt.h:2084
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1132
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition: TypeLoc.h:238
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:235
An attributed type is a type to which a type attribute has been applied.
Definition: Type.h:4411
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
Represents a type parameter type in Objective C.
Definition: Type.h:5450
Represents a field declaration created by an @defs(...).
Definition: DeclObjC.h:2004
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:2601
This represents &#39;#pragma omp target parallel&#39; directive.
Definition: StmtOpenMP.h:2521
This represents &#39;nowait&#39; clause in the &#39;#pragma omp ...&#39; directive.
Represents a C++ struct/union/class.
Definition: DeclCXX.h:300
Represents a template specialization type whose template cannot be resolved, e.g. ...
Definition: Type.h:5250
ContinueStmt - This represents a continue.
Definition: Stmt.h:2164
Represents a loop initializing the elements of an array.
Definition: Expr.h:4749
This represents &#39;num_tasks&#39; clause in the &#39;#pragma omp ...&#39; directive.
The template argument is a template name that was provided for a template template parameter...
Definition: TemplateBase.h:76
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition: Expr.h:3923
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition: Expr.h:3601
CXXCatchStmt - This represents a C++ catch block.
Definition: StmtCXX.h:29
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr.type.conv]).
Definition: ExprCXX.h:1489
bool dataTraverseStmtPost(Stmt *S)
Invoked after visiting a statement or expression via data recursion.
The parameter type of a method or function.
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1937
WhileStmt - This represents a &#39;while&#39; stmt.
Definition: Stmt.h:1843
helper_expr_const_range reduction_ops() const
Declaration of a class template.
Expr * getThreadLimit()
Return ThreadLimit number.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition: DeclObjC.h:629
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
Represents Objective-C&#39;s @try ... @catch ... @finally statement.
Definition: StmtObjC.h:154
This represents &#39;#pragma omp taskloop simd&#39; directive.
Definition: StmtOpenMP.h:2906
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1577
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2407
bool TraverseTemplateArguments(const TemplateArgument *Args, unsigned NumArgs)
Recursively visit a set of template arguments.
#define DEF_TRAVERSE_STMT(STMT, CODE)
This represents &#39;dist_schedule&#39; clause in the &#39;#pragma omp ...&#39; directive.
This represents &#39;#pragma omp sections&#39; directive.
Definition: StmtOpenMP.h:1246
Expr * getHint() const
Returns number of threads.
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition: ExprObjC.h:82
The top declaration context.
Definition: Decl.h:107
This represents &#39;#pragma omp target data&#39; directive.
Definition: StmtOpenMP.h:2346
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:257
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1042
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
BreakStmt - This represents a break.
Definition: Stmt.h:2190
Expr * getChunkSize()
Get chunk size.
Expr * getNumThreads() const
Returns number of threads.
Definition: OpenMPClause.h:426
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:3909
QualType getType() const
Definition: Decl.h:647
bool TraverseAttr(Attr *At)
Recursively visit an attribute, by dispatching to Traverse*Attr() based on the argument&#39;s dynamic typ...
This represents &#39;#pragma omp taskyield&#39; directive.
Definition: StmtOpenMP.h:1839
This represents a decl that may have a name.
Definition: Decl.h:248
This represents &#39;#pragma omp distribute parallel for simd&#39; composite directive.
Definition: StmtOpenMP.h:3179
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:557
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Definition: Expr.h:2128
This represents &#39;#pragma omp parallel sections&#39; directive.
Definition: StmtOpenMP.h:1700
Represents a C++ namespace alias.
Definition: DeclCXX.h:3017
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:882
bool VisitUnqualTypeLoc(UnqualTypeLoc TL)
Declaration of a friend template.
Represents C++ using-directive.
Definition: DeclCXX.h:2913
Represents a #pragma detect_mismatch line.
Definition: Decl.h:173
const Expr * getPostUpdateExpr() const
Get post-update expression for the clause.
Definition: OpenMPClause.h:151
The global specifier &#39;::&#39;. There is no stored value.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
Definition: TemplateBase.h:288
Represents Objective-C&#39;s @autoreleasepool Statement.
Definition: StmtObjC.h:345
This represents &#39;#pragma omp threadprivate ...&#39; directive.
Definition: DeclOpenMP.h:40
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
Definition: DeclObjC.h:2491
InitListExpr * getSyntacticForm() const
Definition: Expr.h:4288
Declaration of a template function.
Definition: DeclTemplate.h:968
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:4839
bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc)
Recursively visit a template argument location and dispatch to the appropriate method for the argumen...
This represents &#39;#pragma omp target parallel for&#39; directive.
Definition: StmtOpenMP.h:2581
Attr - This represents one attribute.
Definition: Attr.h:43
This represents clause &#39;use_device_ptr&#39; in the &#39;#pragma omp ...&#39; directives.
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Definition: DeclCXX.h:3136
Represents a pack of using declarations that a single using-declarator pack-expanded into...
Definition: DeclCXX.h:3499
InitListExpr * getSemanticForm() const
Definition: Expr.h:4282
Defines the LambdaCapture class.
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition: DeclObjC.h:2721
#define STMT(CLASS, PARENT)
This represents &#39;#pragma omp taskloop&#39; directive.
Definition: StmtOpenMP.h:2841