clang  8.0.0
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 syntactic or semantic form of an
302  /// initialization list.
303  ///
304  /// \returns false if the visitation was terminated early, true otherwise.
306  DataRecursionQueue *Queue = nullptr);
307 
308  // ---- Methods on Attrs ----
309 
310  // Visit an attribute.
311  bool VisitAttr(Attr *A) { return true; }
312 
313 // Declare Traverse* and empty Visit* for all Attr classes.
314 #define ATTR_VISITOR_DECLS_ONLY
315 #include "clang/AST/AttrVisitor.inc"
316 #undef ATTR_VISITOR_DECLS_ONLY
317 
318 // ---- Methods on Stmts ----
319 
321 
322 private:
323  template<typename T, typename U>
324  struct has_same_member_pointer_type : std::false_type {};
325  template<typename T, typename U, typename R, typename... P>
326  struct has_same_member_pointer_type<R (T::*)(P...), R (U::*)(P...)>
327  : std::true_type {};
328 
329  // Traverse the given statement. If the most-derived traverse function takes a
330  // data recursion queue, pass it on; otherwise, discard it. Note that the
331  // first branch of this conditional must compile whether or not the derived
332  // class can take a queue, so if we're taking the second arm, make the first
333  // arm call our function rather than the derived class version.
334 #define TRAVERSE_STMT_BASE(NAME, CLASS, VAR, QUEUE) \
335  (has_same_member_pointer_type<decltype( \
336  &RecursiveASTVisitor::Traverse##NAME), \
337  decltype(&Derived::Traverse##NAME)>::value \
338  ? static_cast<typename std::conditional< \
339  has_same_member_pointer_type< \
340  decltype(&RecursiveASTVisitor::Traverse##NAME), \
341  decltype(&Derived::Traverse##NAME)>::value, \
342  Derived &, RecursiveASTVisitor &>::type>(*this) \
343  .Traverse##NAME(static_cast<CLASS *>(VAR), QUEUE) \
344  : getDerived().Traverse##NAME(static_cast<CLASS *>(VAR)))
345 
346 // Try to traverse the given statement, or enqueue it if we're performing data
347 // recursion in the middle of traversing another statement. Can only be called
348 // from within a DEF_TRAVERSE_STMT body or similar context.
349 #define TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S) \
350  do { \
351  if (!TRAVERSE_STMT_BASE(Stmt, Stmt, S, Queue)) \
352  return false; \
353  } while (false)
354 
355 public:
356 // Declare Traverse*() for all concrete Stmt classes.
357 #define ABSTRACT_STMT(STMT)
358 #define STMT(CLASS, PARENT) \
359  bool Traverse##CLASS(CLASS *S, DataRecursionQueue *Queue = nullptr);
360 #include "clang/AST/StmtNodes.inc"
361  // The above header #undefs ABSTRACT_STMT and STMT upon exit.
362 
363  // Define WalkUpFrom*() and empty Visit*() for all Stmt classes.
364  bool WalkUpFromStmt(Stmt *S) { return getDerived().VisitStmt(S); }
365  bool VisitStmt(Stmt *S) { return true; }
366 #define STMT(CLASS, PARENT) \
367  bool WalkUpFrom##CLASS(CLASS *S) { \
368  TRY_TO(WalkUpFrom##PARENT(S)); \
369  TRY_TO(Visit##CLASS(S)); \
370  return true; \
371  } \
372  bool Visit##CLASS(CLASS *S) { return true; }
373 #include "clang/AST/StmtNodes.inc"
374 
375 // Define Traverse*(), WalkUpFrom*(), and Visit*() for unary
376 // operator methods. Unary operators are not classes in themselves
377 // (they're all opcodes in UnaryOperator) but do have visitors.
378 #define OPERATOR(NAME) \
379  bool TraverseUnary##NAME(UnaryOperator *S, \
380  DataRecursionQueue *Queue = nullptr) { \
381  if (!getDerived().shouldTraversePostOrder()) \
382  TRY_TO(WalkUpFromUnary##NAME(S)); \
383  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr()); \
384  return true; \
385  } \
386  bool WalkUpFromUnary##NAME(UnaryOperator *S) { \
387  TRY_TO(WalkUpFromUnaryOperator(S)); \
388  TRY_TO(VisitUnary##NAME(S)); \
389  return true; \
390  } \
391  bool VisitUnary##NAME(UnaryOperator *S) { return true; }
392 
393  UNARYOP_LIST()
394 #undef OPERATOR
395 
396 // Define Traverse*(), WalkUpFrom*(), and Visit*() for binary
397 // operator methods. Binary operators are not classes in themselves
398 // (they're all opcodes in BinaryOperator) but do have visitors.
399 #define GENERAL_BINOP_FALLBACK(NAME, BINOP_TYPE) \
400  bool TraverseBin##NAME(BINOP_TYPE *S, DataRecursionQueue *Queue = nullptr) { \
401  if (!getDerived().shouldTraversePostOrder()) \
402  TRY_TO(WalkUpFromBin##NAME(S)); \
403  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLHS()); \
404  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRHS()); \
405  return true; \
406  } \
407  bool WalkUpFromBin##NAME(BINOP_TYPE *S) { \
408  TRY_TO(WalkUpFrom##BINOP_TYPE(S)); \
409  TRY_TO(VisitBin##NAME(S)); \
410  return true; \
411  } \
412  bool VisitBin##NAME(BINOP_TYPE *S) { return true; }
413 
414 #define OPERATOR(NAME) GENERAL_BINOP_FALLBACK(NAME, BinaryOperator)
415  BINOP_LIST()
416 #undef OPERATOR
417 
418 // Define Traverse*(), WalkUpFrom*(), and Visit*() for compound
419 // assignment methods. Compound assignment operators are not
420 // classes in themselves (they're all opcodes in
421 // CompoundAssignOperator) but do have visitors.
422 #define OPERATOR(NAME) \
423  GENERAL_BINOP_FALLBACK(NAME##Assign, CompoundAssignOperator)
424 
425  CAO_LIST()
426 #undef OPERATOR
427 #undef GENERAL_BINOP_FALLBACK
428 
429 // ---- Methods on Types ----
430 // FIXME: revamp to take TypeLoc's rather than Types.
431 
432 // Declare Traverse*() for all concrete Type classes.
433 #define ABSTRACT_TYPE(CLASS, BASE)
434 #define TYPE(CLASS, BASE) bool Traverse##CLASS##Type(CLASS##Type *T);
435 #include "clang/AST/TypeNodes.def"
436  // The above header #undefs ABSTRACT_TYPE and TYPE upon exit.
437 
438  // Define WalkUpFrom*() and empty Visit*() for all Type classes.
439  bool WalkUpFromType(Type *T) { return getDerived().VisitType(T); }
440  bool VisitType(Type *T) { return true; }
441 #define TYPE(CLASS, BASE) \
442  bool WalkUpFrom##CLASS##Type(CLASS##Type *T) { \
443  TRY_TO(WalkUpFrom##BASE(T)); \
444  TRY_TO(Visit##CLASS##Type(T)); \
445  return true; \
446  } \
447  bool Visit##CLASS##Type(CLASS##Type *T) { return true; }
448 #include "clang/AST/TypeNodes.def"
449 
450 // ---- Methods on TypeLocs ----
451 // FIXME: this currently just calls the matching Type methods
452 
453 // Declare Traverse*() for all concrete TypeLoc classes.
454 #define ABSTRACT_TYPELOC(CLASS, BASE)
455 #define TYPELOC(CLASS, BASE) bool Traverse##CLASS##TypeLoc(CLASS##TypeLoc TL);
456 #include "clang/AST/TypeLocNodes.def"
457  // The above header #undefs ABSTRACT_TYPELOC and TYPELOC upon exit.
458 
459  // Define WalkUpFrom*() and empty Visit*() for all TypeLoc classes.
460  bool WalkUpFromTypeLoc(TypeLoc TL) { return getDerived().VisitTypeLoc(TL); }
461  bool VisitTypeLoc(TypeLoc TL) { return true; }
462 
463  // QualifiedTypeLoc and UnqualTypeLoc are not declared in
464  // TypeNodes.def and thus need to be handled specially.
466  return getDerived().VisitUnqualTypeLoc(TL.getUnqualifiedLoc());
467  }
468  bool VisitQualifiedTypeLoc(QualifiedTypeLoc TL) { return true; }
470  return getDerived().VisitUnqualTypeLoc(TL.getUnqualifiedLoc());
471  }
472  bool VisitUnqualTypeLoc(UnqualTypeLoc TL) { return true; }
473 
474 // Note that BASE includes trailing 'Type' which CLASS doesn't.
475 #define TYPE(CLASS, BASE) \
476  bool WalkUpFrom##CLASS##TypeLoc(CLASS##TypeLoc TL) { \
477  TRY_TO(WalkUpFrom##BASE##Loc(TL)); \
478  TRY_TO(Visit##CLASS##TypeLoc(TL)); \
479  return true; \
480  } \
481  bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TL) { return true; }
482 #include "clang/AST/TypeNodes.def"
483 
484 // ---- Methods on Decls ----
485 
486 // Declare Traverse*() for all concrete Decl classes.
487 #define ABSTRACT_DECL(DECL)
488 #define DECL(CLASS, BASE) bool Traverse##CLASS##Decl(CLASS##Decl *D);
489 #include "clang/AST/DeclNodes.inc"
490  // The above header #undefs ABSTRACT_DECL and DECL upon exit.
491 
492  // Define WalkUpFrom*() and empty Visit*() for all Decl classes.
493  bool WalkUpFromDecl(Decl *D) { return getDerived().VisitDecl(D); }
494  bool VisitDecl(Decl *D) { return true; }
495 #define DECL(CLASS, BASE) \
496  bool WalkUpFrom##CLASS##Decl(CLASS##Decl *D) { \
497  TRY_TO(WalkUpFrom##BASE(D)); \
498  TRY_TO(Visit##CLASS##Decl(D)); \
499  return true; \
500  } \
501  bool Visit##CLASS##Decl(CLASS##Decl *D) { return true; }
502 #include "clang/AST/DeclNodes.inc"
503 
504  bool canIgnoreChildDeclWhileTraversingDeclContext(const Decl *Child);
505 
506 private:
507  // These are helper methods used by more than one Traverse* method.
508  bool TraverseTemplateParameterListHelper(TemplateParameterList *TPL);
509 
510  // Traverses template parameter lists of either a DeclaratorDecl or TagDecl.
511  template <typename T>
512  bool TraverseDeclTemplateParameterLists(T *D);
513 
514 #define DEF_TRAVERSE_TMPL_INST(TMPLDECLKIND) \
515  bool TraverseTemplateInstantiations(TMPLDECLKIND##TemplateDecl *D);
518  DEF_TRAVERSE_TMPL_INST(Function)
519 #undef DEF_TRAVERSE_TMPL_INST
520  bool TraverseTemplateArgumentLocsHelper(const TemplateArgumentLoc *TAL,
521  unsigned Count);
522  bool TraverseArrayTypeLocHelper(ArrayTypeLoc TL);
523  bool TraverseRecordHelper(RecordDecl *D);
524  bool TraverseCXXRecordHelper(CXXRecordDecl *D);
525  bool TraverseDeclaratorHelper(DeclaratorDecl *D);
526  bool TraverseDeclContextHelper(DeclContext *DC);
527  bool TraverseFunctionHelper(FunctionDecl *D);
528  bool TraverseVarHelper(VarDecl *D);
529  bool TraverseOMPExecutableDirective(OMPExecutableDirective *S);
530  bool TraverseOMPLoopDirective(OMPLoopDirective *S);
531  bool TraverseOMPClause(OMPClause *C);
532 #define OPENMP_CLAUSE(Name, Class) bool Visit##Class(Class *C);
533 #include "clang/Basic/OpenMPKinds.def"
534  /// Process clauses with list of variables.
535  template <typename T> bool VisitOMPClauseList(T *Node);
536  /// Process clauses with pre-initis.
537  bool VisitOMPClauseWithPreInit(OMPClauseWithPreInit *Node);
538  bool VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *Node);
539 
540  bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue);
541  bool PostVisitStmt(Stmt *S);
542 };
543 
544 template <typename Derived>
545 bool RecursiveASTVisitor<Derived>::dataTraverseNode(Stmt *S,
546  DataRecursionQueue *Queue) {
547 #define DISPATCH_STMT(NAME, CLASS, VAR) \
548  return TRAVERSE_STMT_BASE(NAME, CLASS, VAR, Queue);
549 
550  // If we have a binary expr, dispatch to the subcode of the binop. A smart
551  // optimizer (e.g. LLVM) will fold this comparison into the switch stmt
552  // below.
553  if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(S)) {
554  switch (BinOp->getOpcode()) {
555 #define OPERATOR(NAME) \
556  case BO_##NAME: \
557  DISPATCH_STMT(Bin##NAME, BinaryOperator, S);
558 
559  BINOP_LIST()
560 #undef OPERATOR
561 #undef BINOP_LIST
562 
563 #define OPERATOR(NAME) \
564  case BO_##NAME##Assign: \
565  DISPATCH_STMT(Bin##NAME##Assign, CompoundAssignOperator, S);
566 
567  CAO_LIST()
568 #undef OPERATOR
569 #undef CAO_LIST
570  }
571  } else if (UnaryOperator *UnOp = dyn_cast<UnaryOperator>(S)) {
572  switch (UnOp->getOpcode()) {
573 #define OPERATOR(NAME) \
574  case UO_##NAME: \
575  DISPATCH_STMT(Unary##NAME, UnaryOperator, S);
576 
577  UNARYOP_LIST()
578 #undef OPERATOR
579 #undef UNARYOP_LIST
580  }
581  }
582 
583  // Top switch stmt: dispatch to TraverseFooStmt for each concrete FooStmt.
584  switch (S->getStmtClass()) {
585  case Stmt::NoStmtClass:
586  break;
587 #define ABSTRACT_STMT(STMT)
588 #define STMT(CLASS, PARENT) \
589  case Stmt::CLASS##Class: \
590  DISPATCH_STMT(CLASS, CLASS, S);
591 #include "clang/AST/StmtNodes.inc"
592  }
593 
594  return true;
595 }
596 
597 #undef DISPATCH_STMT
598 
599 template <typename Derived>
600 bool RecursiveASTVisitor<Derived>::PostVisitStmt(Stmt *S) {
601  switch (S->getStmtClass()) {
602  case Stmt::NoStmtClass:
603  break;
604 #define ABSTRACT_STMT(STMT)
605 #define STMT(CLASS, PARENT) \
606  case Stmt::CLASS##Class: \
607  TRY_TO(WalkUpFrom##CLASS(static_cast<CLASS *>(S))); break;
608 #define INITLISTEXPR(CLASS, PARENT) \
609  case Stmt::CLASS##Class: \
610  { \
611  auto ILE = static_cast<CLASS *>(S); \
612  if (auto Syn = ILE->isSemanticForm() ? ILE->getSyntacticForm() : ILE) \
613  TRY_TO(WalkUpFrom##CLASS(Syn)); \
614  if (auto Sem = ILE->isSemanticForm() ? ILE : ILE->getSemanticForm()) \
615  TRY_TO(WalkUpFrom##CLASS(Sem)); \
616  break; \
617  }
618 #include "clang/AST/StmtNodes.inc"
619  }
620 
621  return true;
622 }
623 
624 #undef DISPATCH_STMT
625 
626 template <typename Derived>
628  DataRecursionQueue *Queue) {
629  if (!S)
630  return true;
631 
632  if (Queue) {
633  Queue->push_back({S, false});
634  return true;
635  }
636 
638  LocalQueue.push_back({S, false});
639 
640  while (!LocalQueue.empty()) {
641  auto &CurrSAndVisited = LocalQueue.back();
642  Stmt *CurrS = CurrSAndVisited.getPointer();
643  bool Visited = CurrSAndVisited.getInt();
644  if (Visited) {
645  LocalQueue.pop_back();
648  TRY_TO(PostVisitStmt(CurrS));
649  }
650  continue;
651  }
652 
653  if (getDerived().dataTraverseStmtPre(CurrS)) {
654  CurrSAndVisited.setInt(true);
655  size_t N = LocalQueue.size();
656  TRY_TO(dataTraverseNode(CurrS, &LocalQueue));
657  // Process new children in the order they were added.
658  std::reverse(LocalQueue.begin() + N, LocalQueue.end());
659  } else {
660  LocalQueue.pop_back();
661  }
662  }
663 
664  return true;
665 }
666 
667 #define DISPATCH(NAME, CLASS, VAR) \
668  return getDerived().Traverse##NAME(static_cast<CLASS *>(VAR))
669 
670 template <typename Derived>
672  if (T.isNull())
673  return true;
674 
675  switch (T->getTypeClass()) {
676 #define ABSTRACT_TYPE(CLASS, BASE)
677 #define TYPE(CLASS, BASE) \
678  case Type::CLASS: \
679  DISPATCH(CLASS##Type, CLASS##Type, const_cast<Type *>(T.getTypePtr()));
680 #include "clang/AST/TypeNodes.def"
681  }
682 
683  return true;
684 }
685 
686 template <typename Derived>
688  if (TL.isNull())
689  return true;
690 
691  switch (TL.getTypeLocClass()) {
692 #define ABSTRACT_TYPELOC(CLASS, BASE)
693 #define TYPELOC(CLASS, BASE) \
694  case TypeLoc::CLASS: \
695  return getDerived().Traverse##CLASS##TypeLoc(TL.castAs<CLASS##TypeLoc>());
696 #include "clang/AST/TypeLocNodes.def"
697  }
698 
699  return true;
700 }
701 
702 // Define the Traverse*Attr(Attr* A) methods
703 #define VISITORCLASS RecursiveASTVisitor
704 #include "clang/AST/AttrVisitor.inc"
705 #undef VISITORCLASS
706 
707 template <typename Derived>
709  if (!D)
710  return true;
711 
712  // As a syntax visitor, by default we want to ignore declarations for
713  // implicit declarations (ones not typed explicitly by the user).
715  return true;
716 
717  switch (D->getKind()) {
718 #define ABSTRACT_DECL(DECL)
719 #define DECL(CLASS, BASE) \
720  case Decl::CLASS: \
721  if (!getDerived().Traverse##CLASS##Decl(static_cast<CLASS##Decl *>(D))) \
722  return false; \
723  break;
724 #include "clang/AST/DeclNodes.inc"
725  }
726 
727  // Visit any attributes attached to this declaration.
728  for (auto *I : D->attrs()) {
729  if (!getDerived().TraverseAttr(I))
730  return false;
731  }
732  return true;
733 }
734 
735 #undef DISPATCH
736 
737 template <typename Derived>
739  NestedNameSpecifier *NNS) {
740  if (!NNS)
741  return true;
742 
743  if (NNS->getPrefix())
745 
746  switch (NNS->getKind()) {
752  return true;
753 
756  TRY_TO(TraverseType(QualType(NNS->getAsType(), 0)));
757  }
758 
759  return true;
760 }
761 
762 template <typename Derived>
765  if (!NNS)
766  return true;
767 
768  if (NestedNameSpecifierLoc Prefix = NNS.getPrefix())
770 
771  switch (NNS.getNestedNameSpecifier()->getKind()) {
777  return true;
778 
782  break;
783  }
784 
785  return true;
786 }
787 
788 template <typename Derived>
790  DeclarationNameInfo NameInfo) {
791  switch (NameInfo.getName().getNameKind()) {
795  if (TypeSourceInfo *TSInfo = NameInfo.getNamedTypeInfo())
796  TRY_TO(TraverseTypeLoc(TSInfo->getTypeLoc()));
797  break;
798 
802  break;
803 
811  break;
812  }
813 
814  return true;
815 }
816 
817 template <typename Derived>
820  TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier()));
821  else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
822  TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
823 
824  return true;
825 }
826 
827 template <typename Derived>
829  const TemplateArgument &Arg) {
830  switch (Arg.getKind()) {
835  return true;
836 
838  return getDerived().TraverseType(Arg.getAsType());
839 
842  return getDerived().TraverseTemplateName(
844 
846  return getDerived().TraverseStmt(Arg.getAsExpr());
847 
849  return getDerived().TraverseTemplateArguments(Arg.pack_begin(),
850  Arg.pack_size());
851  }
852 
853  return true;
854 }
855 
856 // FIXME: no template name location?
857 // FIXME: no source locations for a template argument pack?
858 template <typename Derived>
860  const TemplateArgumentLoc &ArgLoc) {
861  const TemplateArgument &Arg = ArgLoc.getArgument();
862 
863  switch (Arg.getKind()) {
868  return true;
869 
870  case TemplateArgument::Type: {
871  // FIXME: how can TSI ever be NULL?
872  if (TypeSourceInfo *TSI = ArgLoc.getTypeSourceInfo())
873  return getDerived().TraverseTypeLoc(TSI->getTypeLoc());
874  else
875  return getDerived().TraverseType(Arg.getAsType());
876  }
877 
880  if (ArgLoc.getTemplateQualifierLoc())
881  TRY_TO(getDerived().TraverseNestedNameSpecifierLoc(
882  ArgLoc.getTemplateQualifierLoc()));
883  return getDerived().TraverseTemplateName(
885 
887  return getDerived().TraverseStmt(ArgLoc.getSourceExpression());
888 
890  return getDerived().TraverseTemplateArguments(Arg.pack_begin(),
891  Arg.pack_size());
892  }
893 
894  return true;
895 }
896 
897 template <typename Derived>
899  const TemplateArgument *Args, unsigned NumArgs) {
900  for (unsigned I = 0; I != NumArgs; ++I) {
902  }
903 
904  return true;
905 }
906 
907 template <typename Derived>
909  CXXCtorInitializer *Init) {
910  if (TypeSourceInfo *TInfo = Init->getTypeSourceInfo())
911  TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
912 
913  if (Init->isWritten() || getDerived().shouldVisitImplicitCode())
914  TRY_TO(TraverseStmt(Init->getInit()));
915 
916  return true;
917 }
918 
919 template <typename Derived>
920 bool
922  const LambdaCapture *C,
923  Expr *Init) {
924  if (LE->isInitCapture(C))
926  else
927  TRY_TO(TraverseStmt(Init));
928  return true;
929 }
930 
931 // ----------------- Type traversal -----------------
932 
933 // This macro makes available a variable T, the passed-in type.
934 #define DEF_TRAVERSE_TYPE(TYPE, CODE) \
935  template <typename Derived> \
936  bool RecursiveASTVisitor<Derived>::Traverse##TYPE(TYPE *T) { \
937  if (!getDerived().shouldTraversePostOrder()) \
938  TRY_TO(WalkUpFrom##TYPE(T)); \
939  { CODE; } \
940  if (getDerived().shouldTraversePostOrder()) \
941  TRY_TO(WalkUpFrom##TYPE(T)); \
942  return true; \
943  }
944 
945 DEF_TRAVERSE_TYPE(BuiltinType, {})
946 
947 DEF_TRAVERSE_TYPE(ComplexType, { TRY_TO(TraverseType(T->getElementType())); })
948 
949 DEF_TRAVERSE_TYPE(PointerType, { TRY_TO(TraverseType(T->getPointeeType())); })
950 
951 DEF_TRAVERSE_TYPE(BlockPointerType,
952  { TRY_TO(TraverseType(T->getPointeeType())); })
953 
954 DEF_TRAVERSE_TYPE(LValueReferenceType,
955  { TRY_TO(TraverseType(T->getPointeeType())); })
956 
957 DEF_TRAVERSE_TYPE(RValueReferenceType,
958  { TRY_TO(TraverseType(T->getPointeeType())); })
959 
960 DEF_TRAVERSE_TYPE(MemberPointerType, {
961  TRY_TO(TraverseType(QualType(T->getClass(), 0)));
962  TRY_TO(TraverseType(T->getPointeeType()));
963 })
964 
965 DEF_TRAVERSE_TYPE(AdjustedType, { TRY_TO(TraverseType(T->getOriginalType())); })
966 
967 DEF_TRAVERSE_TYPE(DecayedType, { TRY_TO(TraverseType(T->getOriginalType())); })
968 
969 DEF_TRAVERSE_TYPE(ConstantArrayType,
970  { TRY_TO(TraverseType(T->getElementType())); })
971 
972 DEF_TRAVERSE_TYPE(IncompleteArrayType,
973  { TRY_TO(TraverseType(T->getElementType())); })
974 
975 DEF_TRAVERSE_TYPE(VariableArrayType, {
976  TRY_TO(TraverseType(T->getElementType()));
977  TRY_TO(TraverseStmt(T->getSizeExpr()));
978 })
979 
980 DEF_TRAVERSE_TYPE(DependentSizedArrayType, {
981  TRY_TO(TraverseType(T->getElementType()));
982  if (T->getSizeExpr())
983  TRY_TO(TraverseStmt(T->getSizeExpr()));
984 })
985 
986 DEF_TRAVERSE_TYPE(DependentAddressSpaceType, {
987  TRY_TO(TraverseStmt(T->getAddrSpaceExpr()));
988  TRY_TO(TraverseType(T->getPointeeType()));
989 })
990 
991 DEF_TRAVERSE_TYPE(DependentVectorType, {
992  if (T->getSizeExpr())
993  TRY_TO(TraverseStmt(T->getSizeExpr()));
994  TRY_TO(TraverseType(T->getElementType()));
995 })
996 
997 DEF_TRAVERSE_TYPE(DependentSizedExtVectorType, {
998  if (T->getSizeExpr())
999  TRY_TO(TraverseStmt(T->getSizeExpr()));
1000  TRY_TO(TraverseType(T->getElementType()));
1001 })
1002 
1003 DEF_TRAVERSE_TYPE(VectorType, { TRY_TO(TraverseType(T->getElementType())); })
1004 
1005 DEF_TRAVERSE_TYPE(ExtVectorType, { TRY_TO(TraverseType(T->getElementType())); })
1006 
1007 DEF_TRAVERSE_TYPE(FunctionNoProtoType,
1008  { TRY_TO(TraverseType(T->getReturnType())); })
1009 
1010 DEF_TRAVERSE_TYPE(FunctionProtoType, {
1011  TRY_TO(TraverseType(T->getReturnType()));
1012 
1013  for (const auto &A : T->param_types()) {
1014  TRY_TO(TraverseType(A));
1015  }
1016 
1017  for (const auto &E : T->exceptions()) {
1018  TRY_TO(TraverseType(E));
1019  }
1020 
1021  if (Expr *NE = T->getNoexceptExpr())
1022  TRY_TO(TraverseStmt(NE));
1023 })
1024 
1025 DEF_TRAVERSE_TYPE(UnresolvedUsingType, {})
1026 DEF_TRAVERSE_TYPE(TypedefType, {})
1027 
1028 DEF_TRAVERSE_TYPE(TypeOfExprType,
1029  { TRY_TO(TraverseStmt(T->getUnderlyingExpr())); })
1030 
1031 DEF_TRAVERSE_TYPE(TypeOfType, { TRY_TO(TraverseType(T->getUnderlyingType())); })
1032 
1033 DEF_TRAVERSE_TYPE(DecltypeType,
1034  { TRY_TO(TraverseStmt(T->getUnderlyingExpr())); })
1035 
1036 DEF_TRAVERSE_TYPE(UnaryTransformType, {
1037  TRY_TO(TraverseType(T->getBaseType()));
1038  TRY_TO(TraverseType(T->getUnderlyingType()));
1039 })
1040 
1041 DEF_TRAVERSE_TYPE(AutoType, { TRY_TO(TraverseType(T->getDeducedType())); })
1042 DEF_TRAVERSE_TYPE(DeducedTemplateSpecializationType, {
1043  TRY_TO(TraverseTemplateName(T->getTemplateName()));
1044  TRY_TO(TraverseType(T->getDeducedType()));
1045 })
1046 
1047 DEF_TRAVERSE_TYPE(RecordType, {})
1048 DEF_TRAVERSE_TYPE(EnumType, {})
1049 DEF_TRAVERSE_TYPE(TemplateTypeParmType, {})
1050 DEF_TRAVERSE_TYPE(SubstTemplateTypeParmType, {
1051  TRY_TO(TraverseType(T->getReplacementType()));
1052 })
1053 DEF_TRAVERSE_TYPE(SubstTemplateTypeParmPackType, {
1054  TRY_TO(TraverseTemplateArgument(T->getArgumentPack()));
1055 })
1056 
1057 DEF_TRAVERSE_TYPE(TemplateSpecializationType, {
1058  TRY_TO(TraverseTemplateName(T->getTemplateName()));
1059  TRY_TO(TraverseTemplateArguments(T->getArgs(), T->getNumArgs()));
1060 })
1061 
1062 DEF_TRAVERSE_TYPE(InjectedClassNameType, {})
1063 
1064 DEF_TRAVERSE_TYPE(AttributedType,
1065  { TRY_TO(TraverseType(T->getModifiedType())); })
1066 
1067 DEF_TRAVERSE_TYPE(ParenType, { TRY_TO(TraverseType(T->getInnerType())); })
1068 
1069 DEF_TRAVERSE_TYPE(ElaboratedType, {
1070  if (T->getQualifier()) {
1071  TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
1072  }
1073  TRY_TO(TraverseType(T->getNamedType()));
1074 })
1075 
1076 DEF_TRAVERSE_TYPE(DependentNameType,
1077  { TRY_TO(TraverseNestedNameSpecifier(T->getQualifier())); })
1078 
1079 DEF_TRAVERSE_TYPE(DependentTemplateSpecializationType, {
1080  TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
1081  TRY_TO(TraverseTemplateArguments(T->getArgs(), T->getNumArgs()));
1082 })
1083 
1084 DEF_TRAVERSE_TYPE(PackExpansionType, { TRY_TO(TraverseType(T->getPattern())); })
1085 
1086 DEF_TRAVERSE_TYPE(ObjCTypeParamType, {})
1087 
1088 DEF_TRAVERSE_TYPE(ObjCInterfaceType, {})
1089 
1090 DEF_TRAVERSE_TYPE(ObjCObjectType, {
1091  // We have to watch out here because an ObjCInterfaceType's base
1092  // type is itself.
1093  if (T->getBaseType().getTypePtr() != T)
1094  TRY_TO(TraverseType(T->getBaseType()));
1095  for (auto typeArg : T->getTypeArgsAsWritten()) {
1096  TRY_TO(TraverseType(typeArg));
1097  }
1098 })
1099 
1100 DEF_TRAVERSE_TYPE(ObjCObjectPointerType,
1101  { TRY_TO(TraverseType(T->getPointeeType())); })
1102 
1103 DEF_TRAVERSE_TYPE(AtomicType, { TRY_TO(TraverseType(T->getValueType())); })
1104 
1105 DEF_TRAVERSE_TYPE(PipeType, { TRY_TO(TraverseType(T->getElementType())); })
1106 
1107 #undef DEF_TRAVERSE_TYPE
1108 
1109 // ----------------- TypeLoc traversal -----------------
1110 
1111 // This macro makes available a variable TL, the passed-in TypeLoc.
1112 // If requested, it calls WalkUpFrom* for the Type in the given TypeLoc,
1113 // in addition to WalkUpFrom* for the TypeLoc itself, such that existing
1114 // clients that override the WalkUpFrom*Type() and/or Visit*Type() methods
1115 // continue to work.
1116 #define DEF_TRAVERSE_TYPELOC(TYPE, CODE) \
1117  template <typename Derived> \
1118  bool RecursiveASTVisitor<Derived>::Traverse##TYPE##Loc(TYPE##Loc TL) { \
1120  TRY_TO(WalkUpFrom##TYPE(const_cast<TYPE *>(TL.getTypePtr()))); \
1121  TRY_TO(WalkUpFrom##TYPE##Loc(TL)); \
1122  { CODE; } \
1123  return true; \
1124  }
1125 
1126 template <typename Derived>
1127 bool
1128 RecursiveASTVisitor<Derived>::TraverseQualifiedTypeLoc(QualifiedTypeLoc TL) {
1129  // Move this over to the 'main' typeloc tree. Note that this is a
1130  // move -- we pretend that we were really looking at the unqualified
1131  // typeloc all along -- rather than a recursion, so we don't follow
1132  // the normal CRTP plan of going through
1133  // getDerived().TraverseTypeLoc. If we did, we'd be traversing
1134  // twice for the same type (once as a QualifiedTypeLoc version of
1135  // the type, once as an UnqualifiedTypeLoc version of the type),
1136  // which in effect means we'd call VisitTypeLoc twice with the
1137  // 'same' type. This solves that problem, at the cost of never
1138  // seeing the qualified version of the type (unless the client
1139  // subclasses TraverseQualifiedTypeLoc themselves). It's not a
1140  // perfect solution. A perfect solution probably requires making
1141  // QualifiedTypeLoc a wrapper around TypeLoc -- like QualType is a
1142  // wrapper around Type* -- rather than being its own class in the
1143  // type hierarchy.
1144  return TraverseTypeLoc(TL.getUnqualifiedLoc());
1145 }
1146 
1147 DEF_TRAVERSE_TYPELOC(BuiltinType, {})
1148 
1149 // FIXME: ComplexTypeLoc is unfinished
1150 DEF_TRAVERSE_TYPELOC(ComplexType, {
1151  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1152 })
1153 
1154 DEF_TRAVERSE_TYPELOC(PointerType,
1155  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1156 
1157 DEF_TRAVERSE_TYPELOC(BlockPointerType,
1158  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1159 
1160 DEF_TRAVERSE_TYPELOC(LValueReferenceType,
1161  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1162 
1163 DEF_TRAVERSE_TYPELOC(RValueReferenceType,
1164  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1165 
1166 // FIXME: location of base class?
1167 // We traverse this in the type case as well, but how is it not reached through
1168 // the pointee type?
1169 DEF_TRAVERSE_TYPELOC(MemberPointerType, {
1170  TRY_TO(TraverseType(QualType(TL.getTypePtr()->getClass(), 0)));
1171  TRY_TO(TraverseTypeLoc(TL.getPointeeLoc()));
1172 })
1173 
1174 DEF_TRAVERSE_TYPELOC(AdjustedType,
1175  { TRY_TO(TraverseTypeLoc(TL.getOriginalLoc())); })
1176 
1177 DEF_TRAVERSE_TYPELOC(DecayedType,
1178  { TRY_TO(TraverseTypeLoc(TL.getOriginalLoc())); })
1179 
1180 template <typename Derived>
1181 bool RecursiveASTVisitor<Derived>::TraverseArrayTypeLocHelper(ArrayTypeLoc TL) {
1182  // This isn't available for ArrayType, but is for the ArrayTypeLoc.
1183  TRY_TO(TraverseStmt(TL.getSizeExpr()));
1184  return true;
1185 }
1186 
1187 DEF_TRAVERSE_TYPELOC(ConstantArrayType, {
1188  TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1189  return TraverseArrayTypeLocHelper(TL);
1190 })
1191 
1192 DEF_TRAVERSE_TYPELOC(IncompleteArrayType, {
1193  TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1194  return TraverseArrayTypeLocHelper(TL);
1195 })
1196 
1197 DEF_TRAVERSE_TYPELOC(VariableArrayType, {
1198  TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1199  return TraverseArrayTypeLocHelper(TL);
1200 })
1201 
1202 DEF_TRAVERSE_TYPELOC(DependentSizedArrayType, {
1203  TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1204  return TraverseArrayTypeLocHelper(TL);
1205 })
1206 
1207 DEF_TRAVERSE_TYPELOC(DependentAddressSpaceType, {
1208  TRY_TO(TraverseStmt(TL.getTypePtr()->getAddrSpaceExpr()));
1209  TRY_TO(TraverseType(TL.getTypePtr()->getPointeeType()));
1210 })
1211 
1212 // FIXME: order? why not size expr first?
1213 // FIXME: base VectorTypeLoc is unfinished
1214 DEF_TRAVERSE_TYPELOC(DependentSizedExtVectorType, {
1215  if (TL.getTypePtr()->getSizeExpr())
1216  TRY_TO(TraverseStmt(TL.getTypePtr()->getSizeExpr()));
1217  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1218 })
1219 
1220 // FIXME: VectorTypeLoc is unfinished
1221 DEF_TRAVERSE_TYPELOC(VectorType, {
1222  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1223 })
1224 
1225 DEF_TRAVERSE_TYPELOC(DependentVectorType, {
1226  if (TL.getTypePtr()->getSizeExpr())
1227  TRY_TO(TraverseStmt(TL.getTypePtr()->getSizeExpr()));
1228  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1229 })
1230 
1231 // FIXME: size and attributes
1232 // FIXME: base VectorTypeLoc is unfinished
1233 DEF_TRAVERSE_TYPELOC(ExtVectorType, {
1234  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1235 })
1236 
1237 DEF_TRAVERSE_TYPELOC(FunctionNoProtoType,
1238  { TRY_TO(TraverseTypeLoc(TL.getReturnLoc())); })
1239 
1240 // FIXME: location of exception specifications (attributes?)
1241 DEF_TRAVERSE_TYPELOC(FunctionProtoType, {
1242  TRY_TO(TraverseTypeLoc(TL.getReturnLoc()));
1243 
1244  const FunctionProtoType *T = TL.getTypePtr();
1245 
1246  for (unsigned I = 0, E = TL.getNumParams(); I != E; ++I) {
1247  if (TL.getParam(I)) {
1248  TRY_TO(TraverseDecl(TL.getParam(I)));
1249  } else if (I < T->getNumParams()) {
1250  TRY_TO(TraverseType(T->getParamType(I)));
1251  }
1252  }
1253 
1254  for (const auto &E : T->exceptions()) {
1255  TRY_TO(TraverseType(E));
1256  }
1257 
1258  if (Expr *NE = T->getNoexceptExpr())
1259  TRY_TO(TraverseStmt(NE));
1260 })
1261 
1262 DEF_TRAVERSE_TYPELOC(UnresolvedUsingType, {})
1263 DEF_TRAVERSE_TYPELOC(TypedefType, {})
1264 
1265 DEF_TRAVERSE_TYPELOC(TypeOfExprType,
1266  { TRY_TO(TraverseStmt(TL.getUnderlyingExpr())); })
1267 
1268 DEF_TRAVERSE_TYPELOC(TypeOfType, {
1269  TRY_TO(TraverseTypeLoc(TL.getUnderlyingTInfo()->getTypeLoc()));
1270 })
1271 
1272 // FIXME: location of underlying expr
1273 DEF_TRAVERSE_TYPELOC(DecltypeType, {
1274  TRY_TO(TraverseStmt(TL.getTypePtr()->getUnderlyingExpr()));
1275 })
1276 
1277 DEF_TRAVERSE_TYPELOC(UnaryTransformType, {
1278  TRY_TO(TraverseTypeLoc(TL.getUnderlyingTInfo()->getTypeLoc()));
1279 })
1280 
1281 DEF_TRAVERSE_TYPELOC(AutoType, {
1282  TRY_TO(TraverseType(TL.getTypePtr()->getDeducedType()));
1283 })
1284 
1285 DEF_TRAVERSE_TYPELOC(DeducedTemplateSpecializationType, {
1286  TRY_TO(TraverseTemplateName(TL.getTypePtr()->getTemplateName()));
1287  TRY_TO(TraverseType(TL.getTypePtr()->getDeducedType()));
1288 })
1289 
1290 DEF_TRAVERSE_TYPELOC(RecordType, {})
1291 DEF_TRAVERSE_TYPELOC(EnumType, {})
1292 DEF_TRAVERSE_TYPELOC(TemplateTypeParmType, {})
1293 DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmType, {
1294  TRY_TO(TraverseType(TL.getTypePtr()->getReplacementType()));
1295 })
1296 DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmPackType, {
1297  TRY_TO(TraverseTemplateArgument(TL.getTypePtr()->getArgumentPack()));
1298 })
1299 
1300 // FIXME: use the loc for the template name?
1301 DEF_TRAVERSE_TYPELOC(TemplateSpecializationType, {
1302  TRY_TO(TraverseTemplateName(TL.getTypePtr()->getTemplateName()));
1303  for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) {
1304  TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(I)));
1305  }
1306 })
1307 
1309 
1310 DEF_TRAVERSE_TYPELOC(ParenType, { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
1311 
1313  { TRY_TO(TraverseTypeLoc(TL.getModifiedLoc())); })
1314 
1316  if (TL.getQualifierLoc()) {
1317  TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1318  }
1319  TRY_TO(TraverseTypeLoc(TL.getNamedTypeLoc()));
1320 })
1321 
1323  TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1324 })
1325 
1327  if (TL.getQualifierLoc()) {
1328  TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1329  }
1330 
1331  for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) {
1332  TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(I)));
1333  }
1334 })
1335 
1337  { TRY_TO(TraverseTypeLoc(TL.getPatternLoc())); })
1338 
1340 
1342 
1344  // We have to watch out here because an ObjCInterfaceType's base
1345  // type is itself.
1346  if (TL.getTypePtr()->getBaseType().getTypePtr() != TL.getTypePtr())
1347  TRY_TO(TraverseTypeLoc(TL.getBaseLoc()));
1348  for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
1349  TRY_TO(TraverseTypeLoc(TL.getTypeArgTInfo(i)->getTypeLoc()));
1350 })
1351 
1353  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1354 
1355 DEF_TRAVERSE_TYPELOC(AtomicType, { TRY_TO(TraverseTypeLoc(TL.getValueLoc())); })
1356 
1357 DEF_TRAVERSE_TYPELOC(PipeType, { TRY_TO(TraverseTypeLoc(TL.getValueLoc())); })
1358 
1359 #undef DEF_TRAVERSE_TYPELOC
1360 
1361 // ----------------- Decl traversal -----------------
1362 //
1363 // For a Decl, we automate (in the DEF_TRAVERSE_DECL macro) traversing
1364 // the children that come from the DeclContext associated with it.
1365 // Therefore each Traverse* only needs to worry about children other
1366 // than those.
1367 
1368 template <typename Derived>
1370  const Decl *Child) {
1371  // BlockDecls are traversed through BlockExprs,
1372  // CapturedDecls are traversed through CapturedStmts.
1373  if (isa<BlockDecl>(Child) || isa<CapturedDecl>(Child))
1374  return true;
1375  // Lambda classes are traversed through LambdaExprs.
1376  if (const CXXRecordDecl* Cls = dyn_cast<CXXRecordDecl>(Child))
1377  return Cls->isLambda();
1378  return false;
1379 }
1380 
1381 template <typename Derived>
1383  if (!DC)
1384  return true;
1385 
1386  for (auto *Child : DC->decls()) {
1388  TRY_TO(TraverseDecl(Child));
1389  }
1390 
1391  return true;
1392 }
1393 
1394 // This macro makes available a variable D, the passed-in decl.
1395 #define DEF_TRAVERSE_DECL(DECL, CODE) \
1396  template <typename Derived> \
1397  bool RecursiveASTVisitor<Derived>::Traverse##DECL(DECL *D) { \
1398  bool ShouldVisitChildren = true; \
1399  bool ReturnValue = true; \
1400  if (!getDerived().shouldTraversePostOrder()) \
1401  TRY_TO(WalkUpFrom##DECL(D)); \
1402  { CODE; } \
1403  if (ReturnValue && ShouldVisitChildren) \
1404  TRY_TO(TraverseDeclContextHelper(dyn_cast<DeclContext>(D))); \
1405  if (ReturnValue && getDerived().shouldTraversePostOrder()) \
1406  TRY_TO(WalkUpFrom##DECL(D)); \
1407  return ReturnValue; \
1408  }
1409 
1410 DEF_TRAVERSE_DECL(AccessSpecDecl, {})
1411 
1412 DEF_TRAVERSE_DECL(BlockDecl, {
1413  if (TypeSourceInfo *TInfo = D->getSignatureAsWritten())
1414  TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
1415  TRY_TO(TraverseStmt(D->getBody()));
1416  for (const auto &I : D->captures()) {
1417  if (I.hasCopyExpr()) {
1418  TRY_TO(TraverseStmt(I.getCopyExpr()));
1419  }
1420  }
1421  ShouldVisitChildren = false;
1422 })
1423 
1424 DEF_TRAVERSE_DECL(CapturedDecl, {
1425  TRY_TO(TraverseStmt(D->getBody()));
1427 })
1428 
1430 
1432  { TRY_TO(TraverseStmt(D->getAsmString())); })
1433 
1435 
1437  // Friend is either decl or a type.
1438  if (D->getFriendType())
1439  TRY_TO(TraverseTypeLoc(D->getFriendType()->getTypeLoc()));
1440  else
1441  TRY_TO(TraverseDecl(D->getFriendDecl()));
1442 })
1443 
1445  if (D->getFriendType())
1446  TRY_TO(TraverseTypeLoc(D->getFriendType()->getTypeLoc()));
1447  else
1448  TRY_TO(TraverseDecl(D->getFriendDecl()));
1449  for (unsigned I = 0, E = D->getNumTemplateParameters(); I < E; ++I) {
1450  TemplateParameterList *TPL = D->getTemplateParameterList(I);
1451  for (TemplateParameterList::iterator ITPL = TPL->begin(), ETPL = TPL->end();
1452  ITPL != ETPL; ++ITPL) {
1453  TRY_TO(TraverseDecl(*ITPL));
1454  }
1455  }
1456 })
1457 
1459  TRY_TO(TraverseDecl(D->getSpecialization()));
1460 
1461  if (D->hasExplicitTemplateArgs()) {
1462  const TemplateArgumentListInfo &args = D->templateArgs();
1463  TRY_TO(TraverseTemplateArgumentLocsHelper(args.getArgumentArray(),
1464  args.size()));
1465  }
1466 })
1467 
1469 
1471 
1472 DEF_TRAVERSE_DECL(ObjCPropertyImplDecl, {// FIXME: implement this
1473  })
1474 
1476  TRY_TO(TraverseStmt(D->getAssertExpr()));
1477  TRY_TO(TraverseStmt(D->getMessage()));
1478 })
1479 
1482  {// Code in an unnamed namespace shows up automatically in
1483  // decls_begin()/decls_end(). Thus we don't need to recurse on
1484  // D->getAnonymousNamespace().
1485  })
1486 
1488 
1490 
1492 
1494  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1495 
1496  // We shouldn't traverse an aliased namespace, since it will be
1497  // defined (and, therefore, traversed) somewhere else.
1498  ShouldVisitChildren = false;
1499 })
1500 
1501 DEF_TRAVERSE_DECL(LabelDecl, {// There is no code in a LabelDecl.
1502  })
1503 
1505  NamespaceDecl,
1506  {// Code in an unnamed namespace shows up automatically in
1507  // decls_begin()/decls_end(). Thus we don't need to recurse on
1508  // D->getAnonymousNamespace().
1509  })
1510 
1511 DEF_TRAVERSE_DECL(ObjCCompatibleAliasDecl, {// FIXME: implement
1512  })
1513 
1514 DEF_TRAVERSE_DECL(ObjCCategoryDecl, {// FIXME: implement
1515  if (ObjCTypeParamList *typeParamList = D->getTypeParamList()) {
1516  for (auto typeParam : *typeParamList) {
1517  TRY_TO(TraverseObjCTypeParamDecl(typeParam));
1518  }
1519  }
1520 })
1521 
1522 DEF_TRAVERSE_DECL(ObjCCategoryImplDecl, {// FIXME: implement
1523  })
1524 
1525 DEF_TRAVERSE_DECL(ObjCImplementationDecl, {// FIXME: implement
1526  })
1527 
1528 DEF_TRAVERSE_DECL(ObjCInterfaceDecl, {// FIXME: implement
1529  if (ObjCTypeParamList *typeParamList = D->getTypeParamListAsWritten()) {
1530  for (auto typeParam : *typeParamList) {
1531  TRY_TO(TraverseObjCTypeParamDecl(typeParam));
1532  }
1533  }
1534 
1535  if (TypeSourceInfo *superTInfo = D->getSuperClassTInfo()) {
1536  TRY_TO(TraverseTypeLoc(superTInfo->getTypeLoc()));
1537  }
1538 })
1539 
1540 DEF_TRAVERSE_DECL(ObjCProtocolDecl, {// FIXME: implement
1541  })
1542 
1544  if (D->getReturnTypeSourceInfo()) {
1545  TRY_TO(TraverseTypeLoc(D->getReturnTypeSourceInfo()->getTypeLoc()));
1546  }
1547  for (ParmVarDecl *Parameter : D->parameters()) {
1549  }
1550  if (D->isThisDeclarationADefinition()) {
1551  TRY_TO(TraverseStmt(D->getBody()));
1552  }
1553  ShouldVisitChildren = false;
1554 })
1555 
1557  if (D->hasExplicitBound()) {
1558  TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1559  // We shouldn't traverse D->getTypeForDecl(); it's a result of
1560  // declaring the type alias, not something that was written in the
1561  // source.
1562  }
1563 })
1564 
1566  if (D->getTypeSourceInfo())
1567  TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1568  else
1569  TRY_TO(TraverseType(D->getType()));
1570  ShouldVisitChildren = false;
1571 })
1572 
1574  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1575  TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
1576 })
1577 
1579 
1581  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1582 })
1583 
1585 
1587 
1589  for (auto *I : D->varlists()) {
1590  TRY_TO(TraverseStmt(I));
1591  }
1592  })
1593 
1595  for (auto *C : D->clauselists()) {
1596  TRY_TO(TraverseOMPClause(C));
1597  }
1598 })
1599 
1601  TRY_TO(TraverseStmt(D->getCombiner()));
1602  if (auto *Initializer = D->getInitializer())
1603  TRY_TO(TraverseStmt(Initializer));
1604  TRY_TO(TraverseType(D->getType()));
1605  return true;
1606 })
1607 
1608 DEF_TRAVERSE_DECL(OMPCapturedExprDecl, { TRY_TO(TraverseVarHelper(D)); })
1609 
1610 // A helper method for TemplateDecl's children.
1611 template <typename Derived>
1613  TemplateParameterList *TPL) {
1614  if (TPL) {
1615  for (TemplateParameterList::iterator I = TPL->begin(), E = TPL->end();
1616  I != E; ++I) {
1617  TRY_TO(TraverseDecl(*I));
1618  }
1619  }
1620  return true;
1621 }
1622 
1623 template <typename Derived>
1624 template <typename T>
1626  for (unsigned i = 0; i < D->getNumTemplateParameterLists(); i++) {
1627  TemplateParameterList *TPL = D->getTemplateParameterList(i);
1628  TraverseTemplateParameterListHelper(TPL);
1629  }
1630  return true;
1631 }
1632 
1633 template <typename Derived>
1635  ClassTemplateDecl *D) {
1636  for (auto *SD : D->specializations()) {
1637  for (auto *RD : SD->redecls()) {
1638  // We don't want to visit injected-class-names in this traversal.
1639  if (cast<CXXRecordDecl>(RD)->isInjectedClassName())
1640  continue;
1641 
1642  switch (
1643  cast<ClassTemplateSpecializationDecl>(RD)->getSpecializationKind()) {
1644  // Visit the implicit instantiations with the requested pattern.
1645  case TSK_Undeclared:
1647  TRY_TO(TraverseDecl(RD));
1648  break;
1649 
1650  // We don't need to do anything on an explicit instantiation
1651  // or explicit specialization because there will be an explicit
1652  // node for it elsewhere.
1656  break;
1657  }
1658  }
1659  }
1660 
1661  return true;
1662 }
1663 
1664 template <typename Derived>
1666  VarTemplateDecl *D) {
1667  for (auto *SD : D->specializations()) {
1668  for (auto *RD : SD->redecls()) {
1669  switch (
1670  cast<VarTemplateSpecializationDecl>(RD)->getSpecializationKind()) {
1671  case TSK_Undeclared:
1673  TRY_TO(TraverseDecl(RD));
1674  break;
1675 
1679  break;
1680  }
1681  }
1682  }
1683 
1684  return true;
1685 }
1686 
1687 // A helper method for traversing the instantiations of a
1688 // function while skipping its specializations.
1689 template <typename Derived>
1691  FunctionTemplateDecl *D) {
1692  for (auto *FD : D->specializations()) {
1693  for (auto *RD : FD->redecls()) {
1694  switch (RD->getTemplateSpecializationKind()) {
1695  case TSK_Undeclared:
1697  // We don't know what kind of FunctionDecl this is.
1698  TRY_TO(TraverseDecl(RD));
1699  break;
1700 
1701  // FIXME: For now traverse explicit instantiations here. Change that
1702  // once they are represented as dedicated nodes in the AST.
1705  TRY_TO(TraverseDecl(RD));
1706  break;
1707 
1709  break;
1710  }
1711  }
1712  }
1713 
1714  return true;
1715 }
1716 
1717 // This macro unifies the traversal of class, variable and function
1718 // template declarations.
1719 #define DEF_TRAVERSE_TMPL_DECL(TMPLDECLKIND) \
1720  DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateDecl, { \
1721  TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \
1722  TRY_TO(TraverseDecl(D->getTemplatedDecl())); \
1723  \
1724  /* By default, we do not traverse the instantiations of \
1725  class templates since they do not appear in the user code. The \
1726  following code optionally traverses them. \
1727  \
1728  We only traverse the class instantiations when we see the canonical \
1729  declaration of the template, to ensure we only visit them once. */ \
1730  if (getDerived().shouldVisitTemplateInstantiations() && \
1731  D == D->getCanonicalDecl()) \
1732  TRY_TO(TraverseTemplateInstantiations(D)); \
1733  \
1734  /* Note that getInstantiatedFromMemberTemplate() is just a link \
1735  from a template instantiation back to the template from which \
1736  it was instantiated, and thus should not be traversed. */ \
1737  })
1738 
1741 DEF_TRAVERSE_TMPL_DECL(Function)
1742 
1744  // D is the "T" in something like
1745  // template <template <typename> class T> class container { };
1747  if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) {
1748  TRY_TO(TraverseTemplateArgumentLoc(D->getDefaultArgument()));
1749  }
1750  TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1751 })
1752 
1754  TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1755 })
1756 
1758  // D is the "T" in something like "template<typename T> class vector;"
1759  if (D->getTypeForDecl())
1760  TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
1761  if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
1762  TRY_TO(TraverseTypeLoc(D->getDefaultArgumentInfo()->getTypeLoc()));
1763 })
1764 
1766  TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1767  // We shouldn't traverse D->getTypeForDecl(); it's a result of
1768  // declaring the typedef, not something that was written in the
1769  // source.
1770 })
1771 
1773  TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1774  // We shouldn't traverse D->getTypeForDecl(); it's a result of
1775  // declaring the type alias, not something that was written in the
1776  // source.
1777 })
1778 
1781  TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1782 })
1783 
1785  // A dependent using declaration which was marked with 'typename'.
1786  // template<class T> class A : public B<T> { using typename B<T>::foo; };
1787  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1788  // We shouldn't traverse D->getTypeForDecl(); it's a result of
1789  // declaring the type, not something that was written in the
1790  // source.
1791 })
1792 
1794  TRY_TO(TraverseDeclTemplateParameterLists(D));
1795 
1796  if (D->getTypeForDecl())
1797  TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
1798 
1799  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1800  // The enumerators are already traversed by
1801  // decls_begin()/decls_end().
1802 })
1803 
1804 // Helper methods for RecordDecl and its children.
1805 template <typename Derived>
1807  // We shouldn't traverse D->getTypeForDecl(); it's a result of
1808  // declaring the type, not something that was written in the source.
1809 
1810  TRY_TO(TraverseDeclTemplateParameterLists(D));
1812  return true;
1813 }
1814 
1815 template <typename Derived>
1817  const CXXBaseSpecifier &Base) {
1819  return true;
1820 }
1821 
1822 template <typename Derived>
1824  if (!TraverseRecordHelper(D))
1825  return false;
1826  if (D->isCompleteDefinition()) {
1827  for (const auto &I : D->bases()) {
1829  }
1830  // We don't traverse the friends or the conversions, as they are
1831  // already in decls_begin()/decls_end().
1832  }
1833  return true;
1834 }
1835 
1836 DEF_TRAVERSE_DECL(RecordDecl, { TRY_TO(TraverseRecordHelper(D)); })
1837 
1838 DEF_TRAVERSE_DECL(CXXRecordDecl, { TRY_TO(TraverseCXXRecordHelper(D)); })
1839 
1840 #define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND) \
1841  DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateSpecializationDecl, { \
1842  /* For implicit instantiations ("set<int> x;"), we don't want to \
1843  recurse at all, since the instatiated template isn't written in \
1844  the source code anywhere. (Note the instatiated *type* -- \
1845  set<int> -- is written, and will still get a callback of \
1846  TemplateSpecializationType). For explicit instantiations \
1847  ("template set<int>;"), we do need a callback, since this \
1848  is the only callback that's made for this instantiation. \
1849  We use getTypeAsWritten() to distinguish. */ \
1850  if (TypeSourceInfo *TSI = D->getTypeAsWritten()) \
1851  TRY_TO(TraverseTypeLoc(TSI->getTypeLoc())); \
1852  \
1856  /* Returning from here skips traversing the \
1857  declaration context of the *TemplateSpecializationDecl \
1858  (embedded in the DEF_TRAVERSE_DECL() macro) \
1859  which contains the instantiated members of the template. */ \
1860  return true; \
1861  })
1862 
1865 
1866 template <typename Derived>
1868  const TemplateArgumentLoc *TAL, unsigned Count) {
1869  for (unsigned I = 0; I < Count; ++I) {
1871  }
1872  return true;
1873 }
1874 
1875 #define DEF_TRAVERSE_TMPL_PART_SPEC_DECL(TMPLDECLKIND, DECLKIND) \
1876  DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplatePartialSpecializationDecl, { \
1877  /* The partial specialization. */ \
1878  if (TemplateParameterList *TPL = D->getTemplateParameters()) { \
1879  for (TemplateParameterList::iterator I = TPL->begin(), E = TPL->end(); \
1880  I != E; ++I) { \
1881  TRY_TO(TraverseDecl(*I)); \
1882  } \
1883  } \
1884  /* The args that remains unspecialized. */ \
1885  TRY_TO(TraverseTemplateArgumentLocsHelper( \
1886  D->getTemplateArgsAsWritten()->getTemplateArgs(), \
1887  D->getTemplateArgsAsWritten()->NumTemplateArgs)); \
1888  \
1889  /* Don't need the *TemplatePartialSpecializationHelper, even \
1890  though that's our parent class -- we already visit all the \
1891  template args here. */ \
1892  TRY_TO(Traverse##DECLKIND##Helper(D)); \
1893  \
1894  /* Instantiations will have been visited with the primary template. */ \
1895  })
1896 
1897 DEF_TRAVERSE_TMPL_PART_SPEC_DECL(Class, CXXRecord)
1899 
1900 DEF_TRAVERSE_DECL(EnumConstantDecl, { TRY_TO(TraverseStmt(D->getInitExpr())); })
1901 
1903  // Like UnresolvedUsingTypenameDecl, but without the 'typename':
1904  // template <class T> Class A : public Base<T> { using Base<T>::foo; };
1906  TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
1907 })
1908 
1910 
1911 template <typename Derived>
1913  TRY_TO(TraverseDeclTemplateParameterLists(D));
1915  if (D->getTypeSourceInfo())
1917  else
1918  TRY_TO(TraverseType(D->getType()));
1919  return true;
1920 }
1921 
1923  TRY_TO(TraverseVarHelper(D));
1924  for (auto *Binding : D->bindings()) {
1925  TRY_TO(TraverseDecl(Binding));
1926  }
1927 })
1928 
1931  TRY_TO(TraverseStmt(D->getBinding()));
1932 })
1933 
1934 DEF_TRAVERSE_DECL(MSPropertyDecl, { TRY_TO(TraverseDeclaratorHelper(D)); })
1935 
1937  TRY_TO(TraverseDeclaratorHelper(D));
1938  if (D->isBitField())
1939  TRY_TO(TraverseStmt(D->getBitWidth()));
1940  else if (D->hasInClassInitializer())
1941  TRY_TO(TraverseStmt(D->getInClassInitializer()));
1942 })
1943 
1945  TRY_TO(TraverseDeclaratorHelper(D));
1946  if (D->isBitField())
1947  TRY_TO(TraverseStmt(D->getBitWidth()));
1948  // FIXME: implement the rest.
1949 })
1950 
1952  TRY_TO(TraverseDeclaratorHelper(D));
1953  if (D->isBitField())
1954  TRY_TO(TraverseStmt(D->getBitWidth()));
1955  // FIXME: implement the rest.
1956 })
1957 
1958 template <typename Derived>
1960  TRY_TO(TraverseDeclTemplateParameterLists(D));
1963 
1964  // If we're an explicit template specialization, iterate over the
1965  // template args that were explicitly specified. If we were doing
1966  // this in typing order, we'd do it between the return type and
1967  // the function args, but both are handled by the FunctionTypeLoc
1968  // above, so we have to choose one side. I've decided to do before.
1969  if (const FunctionTemplateSpecializationInfo *FTSI =
1971  if (FTSI->getTemplateSpecializationKind() != TSK_Undeclared &&
1972  FTSI->getTemplateSpecializationKind() != TSK_ImplicitInstantiation) {
1973  // A specialization might not have explicit template arguments if it has
1974  // a templated return type and concrete arguments.
1975  if (const ASTTemplateArgumentListInfo *TALI =
1976  FTSI->TemplateArgumentsAsWritten) {
1977  TRY_TO(TraverseTemplateArgumentLocsHelper(TALI->getTemplateArgs(),
1978  TALI->NumTemplateArgs));
1979  }
1980  }
1981  }
1982 
1983  // Visit the function type itself, which can be either
1984  // FunctionNoProtoType or FunctionProtoType, or a typedef. This
1985  // also covers the return type and the function parameters,
1986  // including exception specifications.
1987  if (TypeSourceInfo *TSI = D->getTypeSourceInfo()) {
1988  TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
1989  } else if (getDerived().shouldVisitImplicitCode()) {
1990  // Visit parameter variable declarations of the implicit function
1991  // if the traverser is visiting implicit code. Parameter variable
1992  // declarations do not have valid TypeSourceInfo, so to visit them
1993  // we need to traverse the declarations explicitly.
1994  for (ParmVarDecl *Parameter : D->parameters()) {
1996  }
1997  }
1998 
1999  if (CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(D)) {
2000  // Constructor initializers.
2001  for (auto *I : Ctor->inits()) {
2003  }
2004  }
2005 
2006  if (D->isThisDeclarationADefinition()) {
2007  TRY_TO(TraverseStmt(D->getBody())); // Function body.
2008  }
2009  return true;
2010 }
2011 
2013  // We skip decls_begin/decls_end, which are already covered by
2014  // TraverseFunctionHelper().
2015  ShouldVisitChildren = false;
2016  ReturnValue = TraverseFunctionHelper(D);
2017 })
2018 
2020  // We skip decls_begin/decls_end, which are already covered by
2021  // TraverseFunctionHelper().
2022  ShouldVisitChildren = false;
2023  ReturnValue = TraverseFunctionHelper(D);
2024 })
2025 
2027  // We skip decls_begin/decls_end, which are already covered by
2028  // TraverseFunctionHelper().
2029  ShouldVisitChildren = false;
2030  ReturnValue = TraverseFunctionHelper(D);
2031 })
2032 
2034  // We skip decls_begin/decls_end, which are already covered by
2035  // TraverseFunctionHelper().
2036  ShouldVisitChildren = false;
2037  ReturnValue = TraverseFunctionHelper(D);
2038 })
2039 
2040 // CXXConversionDecl is the declaration of a type conversion operator.
2041 // It's not a cast expression.
2043  // We skip decls_begin/decls_end, which are already covered by
2044  // TraverseFunctionHelper().
2045  ShouldVisitChildren = false;
2046  ReturnValue = TraverseFunctionHelper(D);
2047 })
2048 
2050  // We skip decls_begin/decls_end, which are already covered by
2051  // TraverseFunctionHelper().
2052  ShouldVisitChildren = false;
2053  ReturnValue = TraverseFunctionHelper(D);
2054 })
2055 
2056 template <typename Derived>
2058  TRY_TO(TraverseDeclaratorHelper(D));
2059  // Default params are taken care of when we traverse the ParmVarDecl.
2060  if (!isa<ParmVarDecl>(D) &&
2061  (!D->isCXXForRangeDecl() || getDerived().shouldVisitImplicitCode()))
2062  TRY_TO(TraverseStmt(D->getInit()));
2063  return true;
2064 }
2065 
2066 DEF_TRAVERSE_DECL(VarDecl, { TRY_TO(TraverseVarHelper(D)); })
2067 
2068 DEF_TRAVERSE_DECL(ImplicitParamDecl, { TRY_TO(TraverseVarHelper(D)); })
2069 
2071  // A non-type template parameter, e.g. "S" in template<int S> class Foo ...
2072  TRY_TO(TraverseDeclaratorHelper(D));
2073  if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
2074  TRY_TO(TraverseStmt(D->getDefaultArgument()));
2075 })
2076 
2078  TRY_TO(TraverseVarHelper(D));
2079 
2080  if (D->hasDefaultArg() && D->hasUninstantiatedDefaultArg() &&
2081  !D->hasUnparsedDefaultArg())
2082  TRY_TO(TraverseStmt(D->getUninstantiatedDefaultArg()));
2083 
2084  if (D->hasDefaultArg() && !D->hasUninstantiatedDefaultArg() &&
2085  !D->hasUnparsedDefaultArg())
2086  TRY_TO(TraverseStmt(D->getDefaultArg()));
2087 })
2088 
2089 #undef DEF_TRAVERSE_DECL
2090 
2091 // ----------------- Stmt traversal -----------------
2092 //
2093 // For stmts, we automate (in the DEF_TRAVERSE_STMT macro) iterating
2094 // over the children defined in children() (every stmt defines these,
2095 // though sometimes the range is empty). Each individual Traverse*
2096 // method only needs to worry about children other than those. To see
2097 // what children() does for a given class, see, e.g.,
2098 // http://clang.llvm.org/doxygen/Stmt_8cpp_source.html
2099 
2100 // This macro makes available a variable S, the passed-in stmt.
2101 #define DEF_TRAVERSE_STMT(STMT, CODE) \
2102  template <typename Derived> \
2104  STMT *S, DataRecursionQueue *Queue) { \
2105  bool ShouldVisitChildren = true; \
2106  bool ReturnValue = true; \
2108  TRY_TO(WalkUpFrom##STMT(S)); \
2109  { CODE; } \
2110  if (ShouldVisitChildren) { \
2111  for (Stmt * SubStmt : getDerived().getStmtChildren(S)) { \
2112  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(SubStmt); \
2113  } \
2114  } \
2115  if (!Queue && ReturnValue && getDerived().shouldTraversePostOrder()) \
2116  TRY_TO(WalkUpFrom##STMT(S)); \
2117  return ReturnValue; \
2118  }
2119 
2121  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getAsmString());
2122  for (unsigned I = 0, E = S->getNumInputs(); I < E; ++I) {
2123  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getInputConstraintLiteral(I));
2124  }
2125  for (unsigned I = 0, E = S->getNumOutputs(); I < E; ++I) {
2126  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOutputConstraintLiteral(I));
2127  }
2128  for (unsigned I = 0, E = S->getNumClobbers(); I < E; ++I) {
2129  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getClobberStringLiteral(I));
2130  }
2131  // children() iterates over inputExpr and outputExpr.
2132 })
2133 
2135  MSAsmStmt,
2136  {// FIXME: MS Asm doesn't currently parse Constraints, Clobbers, etc. Once
2137  // added this needs to be implemented.
2138  })
2139 
2141  TRY_TO(TraverseDecl(S->getExceptionDecl()));
2142  // children() iterates over the handler block.
2143 })
2144 
2146  for (auto *I : S->decls()) {
2147  TRY_TO(TraverseDecl(I));
2148  }
2149  // Suppress the default iteration over children() by
2150  // returning. Here's why: A DeclStmt looks like 'type var [=
2151  // initializer]'. The decls above already traverse over the
2152  // initializers, so we don't have to do it again (which
2153  // children() would do).
2154  ShouldVisitChildren = false;
2155 })
2156 
2157 // These non-expr stmts (most of them), do not need any action except
2158 // iterating over the children.
2180 
2183  if (S->getInit())
2184  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getInit());
2185  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLoopVarStmt());
2186  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRangeInit());
2187  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getBody());
2188  // Visit everything else only if shouldVisitImplicitCode().
2189  ShouldVisitChildren = false;
2190  }
2191 })
2192 
2194  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2195  TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2196 })
2197 
2201 
2203 
2205  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2206  TRY_TO(TraverseDeclarationNameInfo(S->getMemberNameInfo()));
2207  if (S->hasExplicitTemplateArgs()) {
2208  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2209  S->getNumTemplateArgs()));
2210  }
2211 })
2212 
2214  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2215  TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2216  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2217  S->getNumTemplateArgs()));
2218 })
2219 
2221  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2222  TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2223  if (S->hasExplicitTemplateArgs()) {
2224  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2225  S->getNumTemplateArgs()));
2226  }
2227 })
2228 
2230  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2231  TRY_TO(TraverseDeclarationNameInfo(S->getMemberNameInfo()));
2232  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2233  S->getNumTemplateArgs()));
2234 })
2235 
2238  {// We don't traverse the cast type, as it's not written in the
2239  // source code.
2240  })
2241 
2243  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2244 })
2245 
2247  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2248 })
2249 
2251  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2252 })
2253 
2255  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2256 })
2257 
2259  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2260 })
2261 
2263  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2264 })
2265 
2266 template <typename Derived>
2268  InitListExpr *S, DataRecursionQueue *Queue) {
2269  if (S) {
2270  // Skip this if we traverse postorder. We will visit it later
2271  // in PostVisitStmt.
2272  if (!getDerived().shouldTraversePostOrder())
2273  TRY_TO(WalkUpFromInitListExpr(S));
2274 
2275  // All we need are the default actions. FIXME: use a helper function.
2276  for (Stmt *SubStmt : S->children()) {
2278  }
2279  }
2280  return true;
2281 }
2282 
2283 // This method is called once for each pair of syntactic and semantic
2284 // InitListExpr, and it traverses the subtrees defined by the two forms. This
2285 // may cause some of the children to be visited twice, if they appear both in
2286 // the syntactic and the semantic form.
2287 //
2288 // There is no guarantee about which form \p S takes when this method is called.
2289 template <typename Derived>
2291  InitListExpr *S, DataRecursionQueue *Queue) {
2293  S->isSemanticForm() ? S->getSyntacticForm() : S, Queue));
2295  S->isSemanticForm() ? S : S->getSemanticForm(), Queue));
2296  return true;
2297 }
2298 
2299 // GenericSelectionExpr is a special case because the types and expressions
2300 // are interleaved. We also need to watch out for null types (default
2301 // generic associations).
2303  TRY_TO(TraverseStmt(S->getControllingExpr()));
2304  for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
2305  if (TypeSourceInfo *TS = S->getAssocTypeSourceInfo(i))
2306  TRY_TO(TraverseTypeLoc(TS->getTypeLoc()));
2307  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getAssocExpr(i));
2308  }
2309  ShouldVisitChildren = false;
2310 })
2311 
2312 // PseudoObjectExpr is a special case because of the weirdness with
2313 // syntactic expressions and opaque values.
2316  for (PseudoObjectExpr::semantics_iterator i = S->semantics_begin(),
2317  e = S->semantics_end();
2318  i != e; ++i) {
2319  Expr *sub = *i;
2320  if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(sub))
2321  sub = OVE->getSourceExpr();
2323  }
2324  ShouldVisitChildren = false;
2325 })
2326 
2328  // This is called for code like 'return T()' where T is a built-in
2329  // (i.e. non-class) type.
2330  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2331 })
2332 
2334  // The child-iterator will pick up the other arguments.
2335  TRY_TO(TraverseTypeLoc(S->getAllocatedTypeSourceInfo()->getTypeLoc()));
2336 })
2337 
2339  // The child-iterator will pick up the expression representing
2340  // the field.
2341  // FIMXE: for code like offsetof(Foo, a.b.c), should we get
2342  // making a MemberExpr callbacks for Foo.a, Foo.a.b, and Foo.a.b.c?
2343  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2344 })
2345 
2347  // The child-iterator will pick up the arg if it's an expression,
2348  // but not if it's a type.
2349  if (S->isArgumentType())
2350  TRY_TO(TraverseTypeLoc(S->getArgumentTypeInfo()->getTypeLoc()));
2351 })
2352 
2354  // The child-iterator will pick up the arg if it's an expression,
2355  // but not if it's a type.
2356  if (S->isTypeOperand())
2357  TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
2358 })
2359 
2361  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2362 })
2363 
2365 
2367  // The child-iterator will pick up the arg if it's an expression,
2368  // but not if it's a type.
2369  if (S->isTypeOperand())
2370  TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
2371 })
2372 
2374  for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
2375  TRY_TO(TraverseTypeLoc(S->getArg(I)->getTypeLoc()));
2376 })
2377 
2379  TRY_TO(TraverseTypeLoc(S->getQueriedTypeSourceInfo()->getTypeLoc()));
2380 })
2381 
2383  { TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getQueriedExpression()); })
2384 
2386  // The child-iterator will pick up the expression argument.
2387  TRY_TO(TraverseTypeLoc(S->getWrittenTypeInfo()->getTypeLoc()));
2388 })
2389 
2391  // This is called for code like 'return T()' where T is a class type.
2392  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2393 })
2394 
2395 // Walk only the visible parts of lambda expressions.
2397  // Visit the capture list.
2398  for (unsigned I = 0, N = S->capture_size(); I != N; ++I) {
2399  const LambdaCapture *C = S->capture_begin() + I;
2400  if (C->isExplicit() || getDerived().shouldVisitImplicitCode()) {
2401  TRY_TO(TraverseLambdaCapture(S, C, S->capture_init_begin()[I]));
2402  }
2403  }
2404 
2406  // The implicit model is simple: everything else is in the lambda class.
2407  TRY_TO(TraverseDecl(S->getLambdaClass()));
2408  } else {
2409  // We need to poke around to find the bits that might be explicitly written.
2410  TypeLoc TL = S->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
2412 
2413  if (S->hasExplicitParameters()) {
2414  // Visit parameters.
2415  for (unsigned I = 0, N = Proto.getNumParams(); I != N; ++I)
2416  TRY_TO(TraverseDecl(Proto.getParam(I)));
2417  }
2418  if (S->hasExplicitResultType())
2420 
2421  auto *T = Proto.getTypePtr();
2422  for (const auto &E : T->exceptions())
2423  TRY_TO(TraverseType(E));
2424 
2425  if (Expr *NE = T->getNoexceptExpr())
2427 
2428  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getBody());
2429  }
2430  ShouldVisitChildren = false;
2431 })
2432 
2434  // This is called for code like 'T()', where T is a template argument.
2435  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2436 })
2437 
2438 // These expressions all might take explicit template arguments.
2439 // We traverse those if so. FIXME: implement these.
2443 
2444 // These exprs (most of them), do not need any action except iterating
2445 // over the children.
2449 
2451  TRY_TO(TraverseDecl(S->getBlockDecl()));
2452  return true; // no child statements to loop through.
2453 })
2454 
2457  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2458 })
2461 
2464  TRY_TO(TraverseStmt(S->getExpr()));
2465 })
2466 
2473 
2475  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2476  if (TypeSourceInfo *ScopeInfo = S->getScopeTypeInfo())
2477  TRY_TO(TraverseTypeLoc(ScopeInfo->getTypeLoc()));
2478  if (TypeSourceInfo *DestroyedTypeInfo = S->getDestroyedTypeInfo())
2479  TRY_TO(TraverseTypeLoc(DestroyedTypeInfo->getTypeLoc()));
2480 })
2481 
2492  // FIXME: The source expression of the OVE should be listed as
2493  // a child of the ArrayInitLoopExpr.
2494  if (OpaqueValueExpr *OVE = S->getCommonExpr())
2495  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(OVE->getSourceExpr());
2496 })
2499 
2501  if (TypeSourceInfo *TInfo = S->getEncodedTypeSourceInfo())
2502  TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
2503 })
2504 
2507 
2509  if (TypeSourceInfo *TInfo = S->getClassReceiverTypeInfo())
2510  TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
2511 })
2512 
2518 
2520  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2521 })
2522 
2531  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2532  if (S->hasExplicitTemplateArgs()) {
2533  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2534  S->getNumTemplateArgs()));
2535  }
2536 })
2537 
2539  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2540  if (S->hasExplicitTemplateArgs()) {
2541  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2542  S->getNumTemplateArgs()));
2543  }
2544 })
2545 
2550 DEF_TRAVERSE_STMT(CapturedStmt, { TRY_TO(TraverseDecl(S->getCapturedDecl())); })
2551 
2556 
2557 // These operators (all of them) do not need any action except
2558 // iterating over the children.
2573 
2574 // For coroutines expressions, traverse either the operand
2575 // as written or the implied calls, depending on what the
2576 // derived class requests.
2579  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getBody());
2580  ShouldVisitChildren = false;
2581  }
2582 })
2584  if (!getDerived().shouldVisitImplicitCode()) {
2585  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand());
2586  ShouldVisitChildren = false;
2587  }
2588 })
2590  if (!getDerived().shouldVisitImplicitCode()) {
2591  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand());
2592  ShouldVisitChildren = false;
2593  }
2594 })
2596  if (!getDerived().shouldVisitImplicitCode()) {
2597  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand());
2598  ShouldVisitChildren = false;
2599  }
2600 })
2602  if (!getDerived().shouldVisitImplicitCode()) {
2603  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand());
2604  ShouldVisitChildren = false;
2605  }
2606 })
2607 
2608 // These literals (all of them) do not need any action.
2619 
2620 // Traverse OpenCL: AsType, Convert.
2622 
2623 // OpenMP directives.
2624 template <typename Derived>
2627  for (auto *C : S->clauses()) {
2628  TRY_TO(TraverseOMPClause(C));
2629  }
2630  return true;
2631 }
2632 
2633 template <typename Derived>
2634 bool
2636  return TraverseOMPExecutableDirective(S);
2637 }
2638 
2640  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2641 
2643  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2644 
2646  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2647 
2649  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2650 
2652  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2653 
2655  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2656 
2658  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2659 
2661  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2662 
2664  TRY_TO(TraverseDeclarationNameInfo(S->getDirectiveName()));
2665  TRY_TO(TraverseOMPExecutableDirective(S));
2666 })
2667 
2669  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2670 
2672  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2673 
2675  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2676 
2678  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2679 
2681  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2682 
2684  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2685 
2687  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2688 
2690  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2691 
2693  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2694 
2696  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2697 
2699  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2700 
2702  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2703 
2705  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2706 
2708  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2709 
2711  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2712 
2714  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2715 
2717  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2718 
2720  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2721 
2723  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2724 
2726  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2727 
2729  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2730 
2732  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2733 
2735  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2736 
2738  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2739 
2741  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2742 
2744  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2745 
2747  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2748 
2750  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2751 
2753  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2754 
2756  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2757 
2759  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2760 
2762  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2763 
2765  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2766 
2768  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2769 
2771  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2772 
2774  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2775 
2777  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2778 
2780  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2781 
2782 // OpenMP clauses.
2783 template <typename Derived>
2785  if (!C)
2786  return true;
2787  switch (C->getClauseKind()) {
2788 #define OPENMP_CLAUSE(Name, Class) \
2789  case OMPC_##Name: \
2790  TRY_TO(Visit##Class(static_cast<Class *>(C))); \
2791  break;
2792 #include "clang/Basic/OpenMPKinds.def"
2793  case OMPC_threadprivate:
2794  case OMPC_uniform:
2795  case OMPC_unknown:
2796  break;
2797  }
2798  return true;
2799 }
2800 
2801 template <typename Derived>
2805  return true;
2806 }
2807 
2808 template <typename Derived>
2810  OMPClauseWithPostUpdate *Node) {
2811  TRY_TO(VisitOMPClauseWithPreInit(Node));
2813  return true;
2814 }
2815 
2816 template <typename Derived>
2818  TRY_TO(VisitOMPClauseWithPreInit(C));
2820  return true;
2821 }
2822 
2823 template <typename Derived>
2826  return true;
2827 }
2828 
2829 template <typename Derived>
2830 bool
2832  TRY_TO(VisitOMPClauseWithPreInit(C));
2834  return true;
2835 }
2836 
2837 template <typename Derived>
2840  return true;
2841 }
2842 
2843 template <typename Derived>
2846  return true;
2847 }
2848 
2849 template <typename Derived>
2850 bool
2853  return true;
2854 }
2855 
2856 template <typename Derived>
2858  return true;
2859 }
2860 
2861 template <typename Derived>
2863  return true;
2864 }
2865 
2866 template <typename Derived>
2869  return true;
2870 }
2871 
2872 template <typename Derived>
2875  return true;
2876 }
2877 
2878 template <typename Derived>
2881  return true;
2882 }
2883 
2884 template <typename Derived>
2887  return true;
2888 }
2889 
2890 template <typename Derived>
2893  return true;
2894 }
2895 
2896 template <typename Derived>
2897 bool
2899  TRY_TO(VisitOMPClauseWithPreInit(C));
2901  return true;
2902 }
2903 
2904 template <typename Derived>
2907  return true;
2908 }
2909 
2910 template <typename Derived>
2912  return true;
2913 }
2914 
2915 template <typename Derived>
2917  return true;
2918 }
2919 
2920 template <typename Derived>
2921 bool
2923  return true;
2924 }
2925 
2926 template <typename Derived>
2928  return true;
2929 }
2930 
2931 template <typename Derived>
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>
2967 template <typename T>
2969  for (auto *E : Node->varlists()) {
2970  TRY_TO(TraverseStmt(E));
2971  }
2972  return true;
2973 }
2974 
2975 template <typename Derived>
2977  TRY_TO(VisitOMPClauseList(C));
2978  for (auto *E : C->private_copies()) {
2979  TRY_TO(TraverseStmt(E));
2980  }
2981  return true;
2982 }
2983 
2984 template <typename Derived>
2986  OMPFirstprivateClause *C) {
2987  TRY_TO(VisitOMPClauseList(C));
2988  TRY_TO(VisitOMPClauseWithPreInit(C));
2989  for (auto *E : C->private_copies()) {
2990  TRY_TO(TraverseStmt(E));
2991  }
2992  for (auto *E : C->inits()) {
2993  TRY_TO(TraverseStmt(E));
2994  }
2995  return true;
2996 }
2997 
2998 template <typename Derived>
3000  OMPLastprivateClause *C) {
3001  TRY_TO(VisitOMPClauseList(C));
3002  TRY_TO(VisitOMPClauseWithPostUpdate(C));
3003  for (auto *E : C->private_copies()) {
3004  TRY_TO(TraverseStmt(E));
3005  }
3006  for (auto *E : C->source_exprs()) {
3007  TRY_TO(TraverseStmt(E));
3008  }
3009  for (auto *E : C->destination_exprs()) {
3010  TRY_TO(TraverseStmt(E));
3011  }
3012  for (auto *E : C->assignment_ops()) {
3013  TRY_TO(TraverseStmt(E));
3014  }
3015  return true;
3016 }
3017 
3018 template <typename Derived>
3020  TRY_TO(VisitOMPClauseList(C));
3021  return true;
3022 }
3023 
3024 template <typename Derived>
3026  TRY_TO(TraverseStmt(C->getStep()));
3027  TRY_TO(TraverseStmt(C->getCalcStep()));
3028  TRY_TO(VisitOMPClauseList(C));
3029  TRY_TO(VisitOMPClauseWithPostUpdate(C));
3030  for (auto *E : C->privates()) {
3031  TRY_TO(TraverseStmt(E));
3032  }
3033  for (auto *E : C->inits()) {
3034  TRY_TO(TraverseStmt(E));
3035  }
3036  for (auto *E : C->updates()) {
3037  TRY_TO(TraverseStmt(E));
3038  }
3039  for (auto *E : C->finals()) {
3040  TRY_TO(TraverseStmt(E));
3041  }
3042  return true;
3043 }
3044 
3045 template <typename Derived>
3048  TRY_TO(VisitOMPClauseList(C));
3049  return true;
3050 }
3051 
3052 template <typename Derived>
3054  TRY_TO(VisitOMPClauseList(C));
3055  for (auto *E : C->source_exprs()) {
3056  TRY_TO(TraverseStmt(E));
3057  }
3058  for (auto *E : C->destination_exprs()) {
3059  TRY_TO(TraverseStmt(E));
3060  }
3061  for (auto *E : C->assignment_ops()) {
3062  TRY_TO(TraverseStmt(E));
3063  }
3064  return true;
3065 }
3066 
3067 template <typename Derived>
3069  OMPCopyprivateClause *C) {
3070  TRY_TO(VisitOMPClauseList(C));
3071  for (auto *E : C->source_exprs()) {
3072  TRY_TO(TraverseStmt(E));
3073  }
3074  for (auto *E : C->destination_exprs()) {
3075  TRY_TO(TraverseStmt(E));
3076  }
3077  for (auto *E : C->assignment_ops()) {
3078  TRY_TO(TraverseStmt(E));
3079  }
3080  return true;
3081 }
3082 
3083 template <typename Derived>
3084 bool
3088  TRY_TO(VisitOMPClauseList(C));
3089  TRY_TO(VisitOMPClauseWithPostUpdate(C));
3090  for (auto *E : C->privates()) {
3091  TRY_TO(TraverseStmt(E));
3092  }
3093  for (auto *E : C->lhs_exprs()) {
3094  TRY_TO(TraverseStmt(E));
3095  }
3096  for (auto *E : C->rhs_exprs()) {
3097  TRY_TO(TraverseStmt(E));
3098  }
3099  for (auto *E : C->reduction_ops()) {
3100  TRY_TO(TraverseStmt(E));
3101  }
3102  return true;
3103 }
3104 
3105 template <typename Derived>
3110  TRY_TO(VisitOMPClauseList(C));
3111  TRY_TO(VisitOMPClauseWithPostUpdate(C));
3112  for (auto *E : C->privates()) {
3113  TRY_TO(TraverseStmt(E));
3114  }
3115  for (auto *E : C->lhs_exprs()) {
3116  TRY_TO(TraverseStmt(E));
3117  }
3118  for (auto *E : C->rhs_exprs()) {
3119  TRY_TO(TraverseStmt(E));
3120  }
3121  for (auto *E : C->reduction_ops()) {
3122  TRY_TO(TraverseStmt(E));
3123  }
3124  return true;
3125 }
3126 
3127 template <typename Derived>
3129  OMPInReductionClause *C) {
3132  TRY_TO(VisitOMPClauseList(C));
3133  TRY_TO(VisitOMPClauseWithPostUpdate(C));
3134  for (auto *E : C->privates()) {
3135  TRY_TO(TraverseStmt(E));
3136  }
3137  for (auto *E : C->lhs_exprs()) {
3138  TRY_TO(TraverseStmt(E));
3139  }
3140  for (auto *E : C->rhs_exprs()) {
3141  TRY_TO(TraverseStmt(E));
3142  }
3143  for (auto *E : C->reduction_ops()) {
3144  TRY_TO(TraverseStmt(E));
3145  }
3146  for (auto *E : C->taskgroup_descriptors())
3147  TRY_TO(TraverseStmt(E));
3148  return true;
3149 }
3150 
3151 template <typename Derived>
3153  TRY_TO(VisitOMPClauseList(C));
3154  return true;
3155 }
3156 
3157 template <typename Derived>
3159  TRY_TO(VisitOMPClauseList(C));
3160  return true;
3161 }
3162 
3163 template <typename Derived>
3165  TRY_TO(VisitOMPClauseWithPreInit(C));
3166  TRY_TO(TraverseStmt(C->getDevice()));
3167  return true;
3168 }
3169 
3170 template <typename Derived>
3172  TRY_TO(VisitOMPClauseList(C));
3173  return true;
3174 }
3175 
3176 template <typename Derived>
3178  OMPNumTeamsClause *C) {
3179  TRY_TO(VisitOMPClauseWithPreInit(C));
3181  return true;
3182 }
3183 
3184 template <typename Derived>
3186  OMPThreadLimitClause *C) {
3187  TRY_TO(VisitOMPClauseWithPreInit(C));
3189  return true;
3190 }
3191 
3192 template <typename Derived>
3194  OMPPriorityClause *C) {
3196  return true;
3197 }
3198 
3199 template <typename Derived>
3201  OMPGrainsizeClause *C) {
3203  return true;
3204 }
3205 
3206 template <typename Derived>
3208  OMPNumTasksClause *C) {
3210  return true;
3211 }
3212 
3213 template <typename Derived>
3215  TRY_TO(TraverseStmt(C->getHint()));
3216  return true;
3217 }
3218 
3219 template <typename Derived>
3221  OMPDistScheduleClause *C) {
3222  TRY_TO(VisitOMPClauseWithPreInit(C));
3224  return true;
3225 }
3226 
3227 template <typename Derived>
3228 bool
3230  return true;
3231 }
3232 
3233 template <typename Derived>
3235  TRY_TO(VisitOMPClauseList(C));
3236  return true;
3237 }
3238 
3239 template <typename Derived>
3241  TRY_TO(VisitOMPClauseList(C));
3242  return true;
3243 }
3244 
3245 template <typename Derived>
3247  OMPUseDevicePtrClause *C) {
3248  TRY_TO(VisitOMPClauseList(C));
3249  return true;
3250 }
3251 
3252 template <typename Derived>
3254  OMPIsDevicePtrClause *C) {
3255  TRY_TO(VisitOMPClauseList(C));
3256  return true;
3257 }
3258 
3259 // FIXME: look at the following tricky-seeming exprs to see if we
3260 // need to recurse on anything. These are ones that have methods
3261 // returning decls or qualtypes or nestednamespecifier -- though I'm
3262 // not sure if they own them -- or just seemed very complicated, or
3263 // had lots of sub-types to explore.
3264 //
3265 // VisitOverloadExpr and its children: recurse on template args? etc?
3266 
3267 // FIXME: go through all the stmts and exprs again, and see which of them
3268 // create new types, and recurse on the types (TypeLocs?) of those.
3269 // Candidates:
3270 //
3271 // http://clang.llvm.org/doxygen/classclang_1_1CXXTypeidExpr.html
3272 // http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html
3273 // http://clang.llvm.org/doxygen/classclang_1_1TypesCompatibleExpr.html
3274 // Every class that has getQualifier.
3275 
3276 #undef DEF_TRAVERSE_STMT
3277 #undef TRAVERSE_STMT
3278 #undef TRAVERSE_STMT_BASE
3279 
3280 #undef TRY_TO
3281 
3282 } // end namespace clang
3283 
3284 #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:5129
VarDecl * getCapturedVar() const
Retrieve the declaration of the local variable being captured.
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:596
This represents &#39;#pragma omp task&#39; directive.
Definition: StmtOpenMP.h:1771
This represents a GCC inline-assembly statement extension.
Definition: Stmt.h:2675
Represents a function declaration or definition.
Definition: Decl.h:1738
Represents a &#39;co_await&#39; expression while the type of the promise is dependent.
Definition: ExprCXX.h:4455
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:2454
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:638
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:2430
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:5370
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:1687
#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:2786
Represents the declaration of a typedef-name via the &#39;typedef&#39; type specifier.
Definition: Decl.h:3018
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:5212
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:4863
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:2828
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:2424
StringRef P
Represents an attribute applied to a statement.
Definition: Stmt.h:1633
ParenExpr - This represents a parethesized expression, e.g.
Definition: Expr.h:1844
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:1335
This represents &#39;priority&#39; clause in the &#39;#pragma omp ...&#39; directive.
The base class of the type hierarchy.
Definition: Type.h:1407
Represents an empty-declaration.
Definition: Decl.h:4259
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:4340
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:1098
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:515
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1262
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:2514
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:365
A container of type source information.
Definition: Decl.h:87
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:828
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:2484
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:4156
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:3169
Represents a #pragma comment line.
Definition: Decl.h:140
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:813
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:2930
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:222
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:604
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:624
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:1015
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:3089
Represents a parameter to a function.
Definition: Decl.h:1550
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:6002
A C++ static_cast expression (C++ [expr.static.cast]).
Definition: ExprCXX.h:326
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:1593
Represents a struct/union/class.
Definition: Decl.h:3593
Represents a C99 designated initializer expression.
Definition: Expr.h:4424
This represents &#39;#pragma omp parallel&#39; directive.
Definition: StmtOpenMP.h:276
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition: Expr.h:3851
Represents a class type in Objective C.
Definition: Type.h:5538
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:155
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:423
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:2579
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:2386
Represents a place-holder for an object not to be initialized by anything.
Definition: Expr.h:4718
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:4062
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:3538
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:5121
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:4014
This represents &#39;#pragma omp critical&#39; directive.
Definition: StmtOpenMP.h:1478
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:2262
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:2339
Describes an C or C++ initializer list.
Definition: Expr.h:4190
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition: ExprCXX.h:669
Represents a C++ using-declaration.
Definition: DeclCXX.h:3352
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:2237
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:555
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:3292
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
Definition: Decl.h:753
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:4373
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:579
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:3469
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:1394
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
Definition: Expr.h:5567
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:2064
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1217
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1649
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:3284
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:1172
#define DEF_TRAVERSE_TMPL_PART_SPEC_DECL(TMPLDECLKIND, DECLKIND)
Represents a linkage specification.
Definition: DeclCXX.h:2826
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda&#39;s captures is an init-capture.
Definition: ExprCXX.cpp:1153
A binding in a decomposition declaration.
Definition: DeclCXX.h:3795
helper_expr_const_range source_exprs() const
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1073
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:976
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2759
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:3587
#define CAO_LIST()
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition: ExprCXX.h:2286
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition: Decl.h:3038
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1241
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:689
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:2222
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:4096
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:1871
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition: DeclCXX.h:3240
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:1581
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:444
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:5182
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2706
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
Definition: Decl.h:1983
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:3844
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:5231
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:179
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:4266
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
Definition: Stmt.h:2443
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:2850
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:1896
A member reference to an MSPropertyDecl.
Definition: ExprCXX.h:759
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:3958
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:2768
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:3229
bool isNull() const
Return true if this QualType doesn&#39;t point to a type yet.
Definition: Type.h:703
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:1517
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:2185
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:4214
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:362
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:3919
This captures a statement into a function.
Definition: Stmt.h:3105
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition: ExprCXX.h:1448
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:5304
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:2507
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:5738
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:1914
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit...
Definition: ExprCXX.h:481
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:171
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Definition: Stmt.h:1143
Represents the declaration of a label.
Definition: Decl.h:469
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:3571
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:2280
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:5438
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:729
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:3120
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:1811
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:2580
DeclarationNameInfo getNameInfo() const
Definition: Decl.h:1901
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3746
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:3806
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:621
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:4149
The injected class name of a C++ class template or class template partial specialization.
Definition: Type.h:4978
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:2942
Represents a pack expansion of types.
Definition: Type.h:5355
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:3509
Defines various enumerations that describe declaration and type specifiers.
Represents a C11 generic selection.
Definition: Expr.h:5015
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
Definition: Decl.h:3291
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:3762
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:4078
Represents a template argument.
Definition: TemplateBase.h:51
Represents a template name that was expressed as a qualified name.
Definition: TemplateName.h:367
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition: Stmt.h:1210
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:1758
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:2170
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:2825
Expr * getSourceExpression() const
Definition: TemplateBase.h:512
const Expr * getInit() const
Definition: Decl.h:1220
A runtime availability query.
Definition: ExprObjC.h:1636
A decomposition declaration.
Definition: DeclCXX.h:3843
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:404
This represents &#39;#pragma omp simd&#39; directive.
Definition: StmtOpenMP.h:1039
Represents a &#39;co_yield&#39; expression.
Definition: ExprCXX.h:4502
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3667
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:559
Kind getKind() const
Definition: DeclBase.h:421
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:3772
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:3326
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:3070
unsigned getNumParams() const
Definition: TypeLoc.h:1402
Represents a pointer to an Objective C object.
Definition: Type.h:5794
helper_expr_const_range privates() const
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition: ExprCXX.h:3719
SwitchStmt - This represents a &#39;switch&#39; stmt.
Definition: Stmt.h:1886
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2552
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:2312
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:2256
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:219
Represents a &#39;co_await&#39; expression.
Definition: ExprCXX.h:4419
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:716
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:3169
GotoStmt - This represents a direct goto.
Definition: Stmt.h:2304
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1137
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:4425
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:5464
Represents a field declaration created by an @defs(...).
Definition: DeclObjC.h:2012
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:2687
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:5264
ContinueStmt - This represents a continue.
Definition: Stmt.h:2384
Represents a loop initializing the elements of an array.
Definition: Expr.h:4808
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:3982
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition: Expr.h:3660
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:1519
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:1945
WhileStmt - This represents a &#39;while&#39; stmt.
Definition: Stmt.h:2063
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:637
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:1566
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2396
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:108
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:1041
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
BreakStmt - This represents a break.
Definition: Stmt.h:2410
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:3912
QualType getType() const
Definition: Decl.h:648
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:249
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:562
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Definition: Expr.h:2117
This represents &#39;#pragma omp parallel sections&#39; directive.
Definition: StmtOpenMP.h:1700
Represents a C++ namespace alias.
Definition: DeclCXX.h:3020
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:887
bool VisitUnqualTypeLoc(UnqualTypeLoc TL)
Declaration of a friend template.
Represents C++ using-directive.
Definition: DeclCXX.h:2916
Represents a #pragma detect_mismatch line.
Definition: Decl.h:174
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:2499
InitListExpr * getSyntacticForm() const
Definition: Expr.h:4347
Declaration of a template function.
Definition: DeclTemplate.h:969
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:4898
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:44
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:3139
Represents a pack of using declarations that a single using-declarator pack-expanded into...
Definition: DeclCXX.h:3502
InitListExpr * getSemanticForm() const
Definition: Expr.h:4341
Defines the LambdaCapture class.
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition: DeclObjC.h:2729
#define STMT(CLASS, PARENT)
This represents &#39;#pragma omp taskloop&#39; directive.
Definition: StmtOpenMP.h:2841