clang  6.0.0svn
RecursiveASTVisitor.h
Go to the documentation of this file.
1 //===--- RecursiveASTVisitor.h - Recursive AST Visitor ----------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the RecursiveASTVisitor interface, which recursively
11 // traverses the entire AST.
12 //
13 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
15 #define LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
16 
17 #include "clang/AST/Attr.h"
18 #include "clang/AST/Decl.h"
20 #include "clang/AST/DeclBase.h"
21 #include "clang/AST/DeclCXX.h"
22 #include "clang/AST/DeclFriend.h"
23 #include "clang/AST/DeclObjC.h"
24 #include "clang/AST/DeclOpenMP.h"
25 #include "clang/AST/DeclTemplate.h"
26 #include "clang/AST/Expr.h"
27 #include "clang/AST/ExprCXX.h"
28 #include "clang/AST/ExprObjC.h"
29 #include "clang/AST/ExprOpenMP.h"
32 #include "clang/AST/OpenMPClause.h"
33 #include "clang/AST/Stmt.h"
34 #include "clang/AST/StmtCXX.h"
35 #include "clang/AST/StmtObjC.h"
36 #include "clang/AST/StmtOpenMP.h"
37 #include "clang/AST/TemplateBase.h"
38 #include "clang/AST/TemplateName.h"
39 #include "clang/AST/Type.h"
40 #include "clang/AST/TypeLoc.h"
41 #include "clang/Basic/LLVM.h"
43 #include "clang/Basic/Specifiers.h"
44 #include "llvm/ADT/PointerIntPair.h"
45 #include "llvm/ADT/SmallVector.h"
46 #include "llvm/Support/Casting.h"
47 #include <algorithm>
48 #include <cstddef>
49 #include <type_traits>
50 
51 // The following three macros are used for meta programming. The code
52 // using them is responsible for defining macro OPERATOR().
53 
54 // All unary operators.
55 #define UNARYOP_LIST() \
56  OPERATOR(PostInc) OPERATOR(PostDec) OPERATOR(PreInc) OPERATOR(PreDec) \
57  OPERATOR(AddrOf) OPERATOR(Deref) OPERATOR(Plus) OPERATOR(Minus) \
58  OPERATOR(Not) OPERATOR(LNot) OPERATOR(Real) OPERATOR(Imag) \
59  OPERATOR(Extension) OPERATOR(Coawait)
60 
61 // All binary operators (excluding compound assign operators).
62 #define BINOP_LIST() \
63  OPERATOR(PtrMemD) OPERATOR(PtrMemI) OPERATOR(Mul) OPERATOR(Div) \
64  OPERATOR(Rem) OPERATOR(Add) OPERATOR(Sub) OPERATOR(Shl) OPERATOR(Shr) \
65  OPERATOR(LT) OPERATOR(GT) OPERATOR(LE) OPERATOR(GE) OPERATOR(EQ) \
66  OPERATOR(NE) OPERATOR(And) OPERATOR(Xor) OPERATOR(Or) OPERATOR(LAnd) \
67  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 /// \brief 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 overriden
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  /// \brief Return a reference to the derived class.
162  Derived &getDerived() { return *static_cast<Derived *>(this); }
163 
164  /// \brief Return whether this visitor should recurse into
165  /// template instantiations.
166  bool shouldVisitTemplateInstantiations() const { return false; }
167 
168  /// \brief Return whether this visitor should recurse into the types of
169  /// TypeLocs.
170  bool shouldWalkTypesOfTypeLocs() const { return true; }
171 
172  /// \brief Return whether this visitor should recurse into implicit
173  /// code, e.g., implicit constructors and destructors.
174  bool shouldVisitImplicitCode() const { return false; }
175 
176  /// \brief Return whether this visitor should traverse post-order.
177  bool shouldTraversePostOrder() const { return false; }
178 
179  /// \brief Recursively visit a statement or expression, by
180  /// dispatching to Traverse*() based on the argument's dynamic type.
181  ///
182  /// \returns false if the visitation was terminated early, true
183  /// otherwise (including when the argument is nullptr).
184  bool TraverseStmt(Stmt *S, DataRecursionQueue *Queue = nullptr);
185 
186  /// Invoked before visiting a statement or expression via data recursion.
187  ///
188  /// \returns false to skip visiting the node, true otherwise.
189  bool dataTraverseStmtPre(Stmt *S) { return true; }
190 
191  /// Invoked after visiting a statement or expression via data recursion.
192  /// This is not invoked if the previously invoked \c dataTraverseStmtPre
193  /// returned false.
194  ///
195  /// \returns false if the visitation was terminated early, true otherwise.
196  bool dataTraverseStmtPost(Stmt *S) { return true; }
197 
198  /// \brief Recursively visit a type, by dispatching to
199  /// Traverse*Type() based on the argument's getTypeClass() property.
200  ///
201  /// \returns false if the visitation was terminated early, true
202  /// otherwise (including when the argument is a Null type).
203  bool TraverseType(QualType T);
204 
205  /// \brief Recursively visit a type with location, by dispatching to
206  /// Traverse*TypeLoc() based on the argument type's getTypeClass() property.
207  ///
208  /// \returns false if the visitation was terminated early, true
209  /// otherwise (including when the argument is a Null type location).
210  bool TraverseTypeLoc(TypeLoc TL);
211 
212  /// \brief Recursively visit an attribute, by dispatching to
213  /// Traverse*Attr() based on the argument's dynamic type.
214  ///
215  /// \returns false if the visitation was terminated early, true
216  /// otherwise (including when the argument is a Null type location).
217  bool TraverseAttr(Attr *At);
218 
219  /// \brief Recursively visit a declaration, by dispatching to
220  /// Traverse*Decl() based on the argument's dynamic type.
221  ///
222  /// \returns false if the visitation was terminated early, true
223  /// otherwise (including when the argument is NULL).
224  bool TraverseDecl(Decl *D);
225 
226  /// \brief Recursively visit a C++ nested-name-specifier.
227  ///
228  /// \returns false if the visitation was terminated early, true otherwise.
230 
231  /// \brief Recursively visit a C++ nested-name-specifier with location
232  /// information.
233  ///
234  /// \returns false if the visitation was terminated early, true otherwise.
236 
237  /// \brief Recursively visit a name with its location information.
238  ///
239  /// \returns false if the visitation was terminated early, true otherwise.
241 
242  /// \brief Recursively visit a template name and dispatch to the
243  /// appropriate method.
244  ///
245  /// \returns false if the visitation was terminated early, true otherwise.
246  bool TraverseTemplateName(TemplateName Template);
247 
248  /// \brief Recursively visit a template argument and dispatch to the
249  /// appropriate method for the argument type.
250  ///
251  /// \returns false if the visitation was terminated early, true otherwise.
252  // FIXME: migrate callers to TemplateArgumentLoc instead.
254 
255  /// \brief Recursively visit a template argument location and dispatch to the
256  /// appropriate method for the argument type.
257  ///
258  /// \returns false if the visitation was terminated early, true otherwise.
260 
261  /// \brief Recursively visit a set of template arguments.
262  /// This can be overridden by a subclass, but it's not expected that
263  /// will be needed -- this visitor always dispatches to another.
264  ///
265  /// \returns false if the visitation was terminated early, true otherwise.
266  // FIXME: take a TemplateArgumentLoc* (or TemplateArgumentListInfo) instead.
268  unsigned NumArgs);
269 
270  /// \brief Recursively visit a base specifier. This can be overridden by a
271  /// subclass.
272  ///
273  /// \returns false if the visitation was terminated early, true otherwise.
275 
276  /// \brief Recursively visit a constructor initializer. This
277  /// automatically dispatches to another visitor for the initializer
278  /// expression, but not for the name of the initializer, so may
279  /// be overridden for clients that need access to the name.
280  ///
281  /// \returns false if the visitation was terminated early, true otherwise.
283 
284  /// \brief Recursively visit a lambda capture. \c Init is the expression that
285  /// will be used to initialize the capture.
286  ///
287  /// \returns false if the visitation was terminated early, true otherwise.
289  Expr *Init);
290 
291  /// \brief Recursively visit the body of a lambda expression.
292  ///
293  /// This provides a hook for visitors that need more context when visiting
294  /// \c LE->getBody().
295  ///
296  /// \returns false if the visitation was terminated early, true otherwise.
297  bool TraverseLambdaBody(LambdaExpr *LE, DataRecursionQueue *Queue = nullptr);
298 
299  /// \brief Recursively visit the syntactic or semantic form of an
300  /// initialization list.
301  ///
302  /// \returns false if the visitation was terminated early, true otherwise.
304  DataRecursionQueue *Queue = nullptr);
305 
306  // ---- Methods on Attrs ----
307 
308  // \brief Visit an attribute.
309  bool VisitAttr(Attr *A) { return true; }
310 
311 // Declare Traverse* and empty Visit* for all Attr classes.
312 #define ATTR_VISITOR_DECLS_ONLY
313 #include "clang/AST/AttrVisitor.inc"
314 #undef ATTR_VISITOR_DECLS_ONLY
315 
316 // ---- Methods on Stmts ----
317 
319 
320 private:
321  template<typename T, typename U>
322  struct has_same_member_pointer_type : std::false_type {};
323  template<typename T, typename U, typename R, typename... P>
324  struct has_same_member_pointer_type<R (T::*)(P...), R (U::*)(P...)>
325  : std::true_type {};
326 
327  // Traverse the given statement. If the most-derived traverse function takes a
328  // data recursion queue, pass it on; otherwise, discard it. Note that the
329  // first branch of this conditional must compile whether or not the derived
330  // class can take a queue, so if we're taking the second arm, make the first
331  // arm call our function rather than the derived class version.
332 #define TRAVERSE_STMT_BASE(NAME, CLASS, VAR, QUEUE) \
333  (has_same_member_pointer_type<decltype( \
334  &RecursiveASTVisitor::Traverse##NAME), \
335  decltype(&Derived::Traverse##NAME)>::value \
336  ? static_cast<typename std::conditional< \
337  has_same_member_pointer_type< \
338  decltype(&RecursiveASTVisitor::Traverse##NAME), \
339  decltype(&Derived::Traverse##NAME)>::value, \
340  Derived &, RecursiveASTVisitor &>::type>(*this) \
341  .Traverse##NAME(static_cast<CLASS *>(VAR), QUEUE) \
342  : getDerived().Traverse##NAME(static_cast<CLASS *>(VAR)))
343 
344 // Try to traverse the given statement, or enqueue it if we're performing data
345 // recursion in the middle of traversing another statement. Can only be called
346 // from within a DEF_TRAVERSE_STMT body or similar context.
347 #define TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S) \
348  do { \
349  if (!TRAVERSE_STMT_BASE(Stmt, Stmt, S, Queue)) \
350  return false; \
351  } while (false)
352 
353 public:
354 // Declare Traverse*() for all concrete Stmt classes.
355 #define ABSTRACT_STMT(STMT)
356 #define STMT(CLASS, PARENT) \
357  bool Traverse##CLASS(CLASS *S, DataRecursionQueue *Queue = nullptr);
358 #include "clang/AST/StmtNodes.inc"
359  // The above header #undefs ABSTRACT_STMT and STMT upon exit.
360 
361  // Define WalkUpFrom*() and empty Visit*() for all Stmt classes.
362  bool WalkUpFromStmt(Stmt *S) { return getDerived().VisitStmt(S); }
363  bool VisitStmt(Stmt *S) { return true; }
364 #define STMT(CLASS, PARENT) \
365  bool WalkUpFrom##CLASS(CLASS *S) { \
366  TRY_TO(WalkUpFrom##PARENT(S)); \
367  TRY_TO(Visit##CLASS(S)); \
368  return true; \
369  } \
370  bool Visit##CLASS(CLASS *S) { return true; }
371 #include "clang/AST/StmtNodes.inc"
372 
373 // Define Traverse*(), WalkUpFrom*(), and Visit*() for unary
374 // operator methods. Unary operators are not classes in themselves
375 // (they're all opcodes in UnaryOperator) but do have visitors.
376 #define OPERATOR(NAME) \
377  bool TraverseUnary##NAME(UnaryOperator *S, \
378  DataRecursionQueue *Queue = nullptr) { \
379  if (!getDerived().shouldTraversePostOrder()) \
380  TRY_TO(WalkUpFromUnary##NAME(S)); \
381  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr()); \
382  return true; \
383  } \
384  bool WalkUpFromUnary##NAME(UnaryOperator *S) { \
385  TRY_TO(WalkUpFromUnaryOperator(S)); \
386  TRY_TO(VisitUnary##NAME(S)); \
387  return true; \
388  } \
389  bool VisitUnary##NAME(UnaryOperator *S) { return true; }
390 
391  UNARYOP_LIST()
392 #undef OPERATOR
393 
394 // Define Traverse*(), WalkUpFrom*(), and Visit*() for binary
395 // operator methods. Binary operators are not classes in themselves
396 // (they're all opcodes in BinaryOperator) but do have visitors.
397 #define GENERAL_BINOP_FALLBACK(NAME, BINOP_TYPE) \
398  bool TraverseBin##NAME(BINOP_TYPE *S, DataRecursionQueue *Queue = nullptr) { \
399  if (!getDerived().shouldTraversePostOrder()) \
400  TRY_TO(WalkUpFromBin##NAME(S)); \
401  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLHS()); \
402  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRHS()); \
403  return true; \
404  } \
405  bool WalkUpFromBin##NAME(BINOP_TYPE *S) { \
406  TRY_TO(WalkUpFrom##BINOP_TYPE(S)); \
407  TRY_TO(VisitBin##NAME(S)); \
408  return true; \
409  } \
410  bool VisitBin##NAME(BINOP_TYPE *S) { return true; }
411 
412 #define OPERATOR(NAME) GENERAL_BINOP_FALLBACK(NAME, BinaryOperator)
413  BINOP_LIST()
414 #undef OPERATOR
415 
416 // Define Traverse*(), WalkUpFrom*(), and Visit*() for compound
417 // assignment methods. Compound assignment operators are not
418 // classes in themselves (they're all opcodes in
419 // CompoundAssignOperator) but do have visitors.
420 #define OPERATOR(NAME) \
421  GENERAL_BINOP_FALLBACK(NAME##Assign, CompoundAssignOperator)
422 
423  CAO_LIST()
424 #undef OPERATOR
425 #undef GENERAL_BINOP_FALLBACK
426 
427 // ---- Methods on Types ----
428 // FIXME: revamp to take TypeLoc's rather than Types.
429 
430 // Declare Traverse*() for all concrete Type classes.
431 #define ABSTRACT_TYPE(CLASS, BASE)
432 #define TYPE(CLASS, BASE) bool Traverse##CLASS##Type(CLASS##Type *T);
433 #include "clang/AST/TypeNodes.def"
434  // The above header #undefs ABSTRACT_TYPE and TYPE upon exit.
435 
436  // Define WalkUpFrom*() and empty Visit*() for all Type classes.
437  bool WalkUpFromType(Type *T) { return getDerived().VisitType(T); }
438  bool VisitType(Type *T) { return true; }
439 #define TYPE(CLASS, BASE) \
440  bool WalkUpFrom##CLASS##Type(CLASS##Type *T) { \
441  TRY_TO(WalkUpFrom##BASE(T)); \
442  TRY_TO(Visit##CLASS##Type(T)); \
443  return true; \
444  } \
445  bool Visit##CLASS##Type(CLASS##Type *T) { return true; }
446 #include "clang/AST/TypeNodes.def"
447 
448 // ---- Methods on TypeLocs ----
449 // FIXME: this currently just calls the matching Type methods
450 
451 // Declare Traverse*() for all concrete TypeLoc classes.
452 #define ABSTRACT_TYPELOC(CLASS, BASE)
453 #define TYPELOC(CLASS, BASE) bool Traverse##CLASS##TypeLoc(CLASS##TypeLoc TL);
454 #include "clang/AST/TypeLocNodes.def"
455  // The above header #undefs ABSTRACT_TYPELOC and TYPELOC upon exit.
456 
457  // Define WalkUpFrom*() and empty Visit*() for all TypeLoc classes.
458  bool WalkUpFromTypeLoc(TypeLoc TL) { return getDerived().VisitTypeLoc(TL); }
459  bool VisitTypeLoc(TypeLoc TL) { return true; }
460 
461  // QualifiedTypeLoc and UnqualTypeLoc are not declared in
462  // TypeNodes.def and thus need to be handled specially.
464  return getDerived().VisitUnqualTypeLoc(TL.getUnqualifiedLoc());
465  }
466  bool VisitQualifiedTypeLoc(QualifiedTypeLoc TL) { return true; }
468  return getDerived().VisitUnqualTypeLoc(TL.getUnqualifiedLoc());
469  }
470  bool VisitUnqualTypeLoc(UnqualTypeLoc TL) { return true; }
471 
472 // Note that BASE includes trailing 'Type' which CLASS doesn't.
473 #define TYPE(CLASS, BASE) \
474  bool WalkUpFrom##CLASS##TypeLoc(CLASS##TypeLoc TL) { \
475  TRY_TO(WalkUpFrom##BASE##Loc(TL)); \
476  TRY_TO(Visit##CLASS##TypeLoc(TL)); \
477  return true; \
478  } \
479  bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TL) { return true; }
480 #include "clang/AST/TypeNodes.def"
481 
482 // ---- Methods on Decls ----
483 
484 // Declare Traverse*() for all concrete Decl classes.
485 #define ABSTRACT_DECL(DECL)
486 #define DECL(CLASS, BASE) bool Traverse##CLASS##Decl(CLASS##Decl *D);
487 #include "clang/AST/DeclNodes.inc"
488  // The above header #undefs ABSTRACT_DECL and DECL upon exit.
489 
490  // Define WalkUpFrom*() and empty Visit*() for all Decl classes.
491  bool WalkUpFromDecl(Decl *D) { return getDerived().VisitDecl(D); }
492  bool VisitDecl(Decl *D) { return true; }
493 #define DECL(CLASS, BASE) \
494  bool WalkUpFrom##CLASS##Decl(CLASS##Decl *D) { \
495  TRY_TO(WalkUpFrom##BASE(D)); \
496  TRY_TO(Visit##CLASS##Decl(D)); \
497  return true; \
498  } \
499  bool Visit##CLASS##Decl(CLASS##Decl *D) { return true; }
500 #include "clang/AST/DeclNodes.inc"
501 
502  bool canIgnoreChildDeclWhileTraversingDeclContext(const Decl *Child);
503 
504 private:
505  // These are helper methods used by more than one Traverse* method.
506  bool TraverseTemplateParameterListHelper(TemplateParameterList *TPL);
507 
508  // Traverses template parameter lists of either a DeclaratorDecl or TagDecl.
509  template <typename T>
510  bool TraverseDeclTemplateParameterLists(T *D);
511 
512 #define DEF_TRAVERSE_TMPL_INST(TMPLDECLKIND) \
513  bool TraverseTemplateInstantiations(TMPLDECLKIND##TemplateDecl *D);
516  DEF_TRAVERSE_TMPL_INST(Function)
517 #undef DEF_TRAVERSE_TMPL_INST
518  bool TraverseTemplateArgumentLocsHelper(const TemplateArgumentLoc *TAL,
519  unsigned Count);
520  bool TraverseArrayTypeLocHelper(ArrayTypeLoc TL);
521  bool TraverseRecordHelper(RecordDecl *D);
522  bool TraverseCXXRecordHelper(CXXRecordDecl *D);
523  bool TraverseDeclaratorHelper(DeclaratorDecl *D);
524  bool TraverseDeclContextHelper(DeclContext *DC);
525  bool TraverseFunctionHelper(FunctionDecl *D);
526  bool TraverseVarHelper(VarDecl *D);
527  bool TraverseOMPExecutableDirective(OMPExecutableDirective *S);
528  bool TraverseOMPLoopDirective(OMPLoopDirective *S);
529  bool TraverseOMPClause(OMPClause *C);
530 #define OPENMP_CLAUSE(Name, Class) bool Visit##Class(Class *C);
531 #include "clang/Basic/OpenMPKinds.def"
532  /// \brief Process clauses with list of variables.
533  template <typename T> bool VisitOMPClauseList(T *Node);
534  /// Process clauses with pre-initis.
535  bool VisitOMPClauseWithPreInit(OMPClauseWithPreInit *Node);
536  bool VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *Node);
537 
538  bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue);
539  bool PostVisitStmt(Stmt *S);
540 };
541 
542 template <typename Derived>
543 bool RecursiveASTVisitor<Derived>::dataTraverseNode(Stmt *S,
544  DataRecursionQueue *Queue) {
545 #define DISPATCH_STMT(NAME, CLASS, VAR) \
546  return TRAVERSE_STMT_BASE(NAME, CLASS, VAR, Queue);
547 
548  // If we have a binary expr, dispatch to the subcode of the binop. A smart
549  // optimizer (e.g. LLVM) will fold this comparison into the switch stmt
550  // below.
551  if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(S)) {
552  switch (BinOp->getOpcode()) {
553 #define OPERATOR(NAME) \
554  case BO_##NAME: \
555  DISPATCH_STMT(Bin##NAME, BinaryOperator, S);
556 
557  BINOP_LIST()
558 #undef OPERATOR
559 #undef BINOP_LIST
560 
561 #define OPERATOR(NAME) \
562  case BO_##NAME##Assign: \
563  DISPATCH_STMT(Bin##NAME##Assign, CompoundAssignOperator, S);
564 
565  CAO_LIST()
566 #undef OPERATOR
567 #undef CAO_LIST
568  }
569  } else if (UnaryOperator *UnOp = dyn_cast<UnaryOperator>(S)) {
570  switch (UnOp->getOpcode()) {
571 #define OPERATOR(NAME) \
572  case UO_##NAME: \
573  DISPATCH_STMT(Unary##NAME, UnaryOperator, S);
574 
575  UNARYOP_LIST()
576 #undef OPERATOR
577 #undef UNARYOP_LIST
578  }
579  }
580 
581  // Top switch stmt: dispatch to TraverseFooStmt for each concrete FooStmt.
582  switch (S->getStmtClass()) {
583  case Stmt::NoStmtClass:
584  break;
585 #define ABSTRACT_STMT(STMT)
586 #define STMT(CLASS, PARENT) \
587  case Stmt::CLASS##Class: \
588  DISPATCH_STMT(CLASS, CLASS, S);
589 #include "clang/AST/StmtNodes.inc"
590  }
591 
592  return true;
593 }
594 
595 #undef DISPATCH_STMT
596 
597 template <typename Derived>
598 bool RecursiveASTVisitor<Derived>::PostVisitStmt(Stmt *S) {
599  switch (S->getStmtClass()) {
600  case Stmt::NoStmtClass:
601  break;
602 #define ABSTRACT_STMT(STMT)
603 #define STMT(CLASS, PARENT) \
604  case Stmt::CLASS##Class: \
605  TRY_TO(WalkUpFrom##CLASS(static_cast<CLASS *>(S))); break;
606 #define INITLISTEXPR(CLASS, PARENT) \
607  case Stmt::CLASS##Class: \
608  { \
609  auto ILE = static_cast<CLASS *>(S); \
610  if (auto Syn = ILE->isSemanticForm() ? ILE->getSyntacticForm() : ILE) \
611  TRY_TO(WalkUpFrom##CLASS(Syn)); \
612  if (auto Sem = ILE->isSemanticForm() ? ILE : ILE->getSemanticForm()) \
613  TRY_TO(WalkUpFrom##CLASS(Sem)); \
614  break; \
615  }
616 #include "clang/AST/StmtNodes.inc"
617  }
618 
619  return true;
620 }
621 
622 #undef DISPATCH_STMT
623 
624 template <typename Derived>
626  DataRecursionQueue *Queue) {
627  if (!S)
628  return true;
629 
630  if (Queue) {
631  Queue->push_back({S, false});
632  return true;
633  }
634 
636  LocalQueue.push_back({S, false});
637 
638  while (!LocalQueue.empty()) {
639  auto &CurrSAndVisited = LocalQueue.back();
640  Stmt *CurrS = CurrSAndVisited.getPointer();
641  bool Visited = CurrSAndVisited.getInt();
642  if (Visited) {
643  LocalQueue.pop_back();
646  TRY_TO(PostVisitStmt(CurrS));
647  }
648  continue;
649  }
650 
651  if (getDerived().dataTraverseStmtPre(CurrS)) {
652  CurrSAndVisited.setInt(true);
653  size_t N = LocalQueue.size();
654  TRY_TO(dataTraverseNode(CurrS, &LocalQueue));
655  // Process new children in the order they were added.
656  std::reverse(LocalQueue.begin() + N, LocalQueue.end());
657  } else {
658  LocalQueue.pop_back();
659  }
660  }
661 
662  return true;
663 }
664 
665 #define DISPATCH(NAME, CLASS, VAR) \
666  return getDerived().Traverse##NAME(static_cast<CLASS *>(VAR))
667 
668 template <typename Derived>
670  if (T.isNull())
671  return true;
672 
673  switch (T->getTypeClass()) {
674 #define ABSTRACT_TYPE(CLASS, BASE)
675 #define TYPE(CLASS, BASE) \
676  case Type::CLASS: \
677  DISPATCH(CLASS##Type, CLASS##Type, const_cast<Type *>(T.getTypePtr()));
678 #include "clang/AST/TypeNodes.def"
679  }
680 
681  return true;
682 }
683 
684 template <typename Derived>
686  if (TL.isNull())
687  return true;
688 
689  switch (TL.getTypeLocClass()) {
690 #define ABSTRACT_TYPELOC(CLASS, BASE)
691 #define TYPELOC(CLASS, BASE) \
692  case TypeLoc::CLASS: \
693  return getDerived().Traverse##CLASS##TypeLoc(TL.castAs<CLASS##TypeLoc>());
694 #include "clang/AST/TypeLocNodes.def"
695  }
696 
697  return true;
698 }
699 
700 // Define the Traverse*Attr(Attr* A) methods
701 #define VISITORCLASS RecursiveASTVisitor
702 #include "clang/AST/AttrVisitor.inc"
703 #undef VISITORCLASS
704 
705 template <typename Derived>
707  if (!D)
708  return true;
709 
710  // As a syntax visitor, by default we want to ignore declarations for
711  // implicit declarations (ones not typed explicitly by the user).
713  return true;
714 
715  switch (D->getKind()) {
716 #define ABSTRACT_DECL(DECL)
717 #define DECL(CLASS, BASE) \
718  case Decl::CLASS: \
719  if (!getDerived().Traverse##CLASS##Decl(static_cast<CLASS##Decl *>(D))) \
720  return false; \
721  break;
722 #include "clang/AST/DeclNodes.inc"
723  }
724 
725  // Visit any attributes attached to this declaration.
726  for (auto *I : D->attrs()) {
727  if (!getDerived().TraverseAttr(I))
728  return false;
729  }
730  return true;
731 }
732 
733 #undef DISPATCH
734 
735 template <typename Derived>
737  NestedNameSpecifier *NNS) {
738  if (!NNS)
739  return true;
740 
741  if (NNS->getPrefix())
743 
744  switch (NNS->getKind()) {
750  return true;
751 
754  TRY_TO(TraverseType(QualType(NNS->getAsType(), 0)));
755  }
756 
757  return true;
758 }
759 
760 template <typename Derived>
763  if (!NNS)
764  return true;
765 
766  if (NestedNameSpecifierLoc Prefix = NNS.getPrefix())
768 
769  switch (NNS.getNestedNameSpecifier()->getKind()) {
775  return true;
776 
780  break;
781  }
782 
783  return true;
784 }
785 
786 template <typename Derived>
788  DeclarationNameInfo NameInfo) {
789  switch (NameInfo.getName().getNameKind()) {
793  if (TypeSourceInfo *TSInfo = NameInfo.getNamedTypeInfo())
794  TRY_TO(TraverseTypeLoc(TSInfo->getTypeLoc()));
795  break;
796 
800  break;
801 
809  break;
810  }
811 
812  return true;
813 }
814 
815 template <typename Derived>
818  TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier()));
819  else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
820  TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
821 
822  return true;
823 }
824 
825 template <typename Derived>
827  const TemplateArgument &Arg) {
828  switch (Arg.getKind()) {
833  return true;
834 
836  return getDerived().TraverseType(Arg.getAsType());
837 
840  return getDerived().TraverseTemplateName(
842 
844  return getDerived().TraverseStmt(Arg.getAsExpr());
845 
847  return getDerived().TraverseTemplateArguments(Arg.pack_begin(),
848  Arg.pack_size());
849  }
850 
851  return true;
852 }
853 
854 // FIXME: no template name location?
855 // FIXME: no source locations for a template argument pack?
856 template <typename Derived>
858  const TemplateArgumentLoc &ArgLoc) {
859  const TemplateArgument &Arg = ArgLoc.getArgument();
860 
861  switch (Arg.getKind()) {
866  return true;
867 
868  case TemplateArgument::Type: {
869  // FIXME: how can TSI ever be NULL?
870  if (TypeSourceInfo *TSI = ArgLoc.getTypeSourceInfo())
871  return getDerived().TraverseTypeLoc(TSI->getTypeLoc());
872  else
873  return getDerived().TraverseType(Arg.getAsType());
874  }
875 
878  if (ArgLoc.getTemplateQualifierLoc())
879  TRY_TO(getDerived().TraverseNestedNameSpecifierLoc(
880  ArgLoc.getTemplateQualifierLoc()));
881  return getDerived().TraverseTemplateName(
883 
885  return getDerived().TraverseStmt(ArgLoc.getSourceExpression());
886 
888  return getDerived().TraverseTemplateArguments(Arg.pack_begin(),
889  Arg.pack_size());
890  }
891 
892  return true;
893 }
894 
895 template <typename Derived>
897  const TemplateArgument *Args, unsigned NumArgs) {
898  for (unsigned I = 0; I != NumArgs; ++I) {
900  }
901 
902  return true;
903 }
904 
905 template <typename Derived>
907  CXXCtorInitializer *Init) {
908  if (TypeSourceInfo *TInfo = Init->getTypeSourceInfo())
909  TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
910 
911  if (Init->isWritten() || getDerived().shouldVisitImplicitCode())
912  TRY_TO(TraverseStmt(Init->getInit()));
913 
914  return true;
915 }
916 
917 template <typename Derived>
918 bool
920  const LambdaCapture *C,
921  Expr *Init) {
922  if (LE->isInitCapture(C))
924  else
925  TRY_TO(TraverseStmt(Init));
926  return true;
927 }
928 
929 template <typename Derived>
931  LambdaExpr *LE, DataRecursionQueue *Queue) {
933  return true;
934 }
935 
936 // ----------------- Type traversal -----------------
937 
938 // This macro makes available a variable T, the passed-in type.
939 #define DEF_TRAVERSE_TYPE(TYPE, CODE) \
940  template <typename Derived> \
941  bool RecursiveASTVisitor<Derived>::Traverse##TYPE(TYPE *T) { \
942  if (!getDerived().shouldTraversePostOrder()) \
943  TRY_TO(WalkUpFrom##TYPE(T)); \
944  { CODE; } \
945  if (getDerived().shouldTraversePostOrder()) \
946  TRY_TO(WalkUpFrom##TYPE(T)); \
947  return true; \
948  }
949 
950 DEF_TRAVERSE_TYPE(BuiltinType, {})
951 
952 DEF_TRAVERSE_TYPE(ComplexType, { TRY_TO(TraverseType(T->getElementType())); })
953 
954 DEF_TRAVERSE_TYPE(PointerType, { TRY_TO(TraverseType(T->getPointeeType())); })
955 
956 DEF_TRAVERSE_TYPE(BlockPointerType,
957  { TRY_TO(TraverseType(T->getPointeeType())); })
958 
959 DEF_TRAVERSE_TYPE(LValueReferenceType,
960  { TRY_TO(TraverseType(T->getPointeeType())); })
961 
962 DEF_TRAVERSE_TYPE(RValueReferenceType,
963  { TRY_TO(TraverseType(T->getPointeeType())); })
964 
965 DEF_TRAVERSE_TYPE(MemberPointerType, {
966  TRY_TO(TraverseType(QualType(T->getClass(), 0)));
967  TRY_TO(TraverseType(T->getPointeeType()));
968 })
969 
970 DEF_TRAVERSE_TYPE(AdjustedType, { TRY_TO(TraverseType(T->getOriginalType())); })
971 
972 DEF_TRAVERSE_TYPE(DecayedType, { TRY_TO(TraverseType(T->getOriginalType())); })
973 
974 DEF_TRAVERSE_TYPE(ConstantArrayType,
975  { TRY_TO(TraverseType(T->getElementType())); })
976 
977 DEF_TRAVERSE_TYPE(IncompleteArrayType,
978  { TRY_TO(TraverseType(T->getElementType())); })
979 
980 DEF_TRAVERSE_TYPE(VariableArrayType, {
981  TRY_TO(TraverseType(T->getElementType()));
982  TRY_TO(TraverseStmt(T->getSizeExpr()));
983 })
984 
985 DEF_TRAVERSE_TYPE(DependentSizedArrayType, {
986  TRY_TO(TraverseType(T->getElementType()));
987  if (T->getSizeExpr())
988  TRY_TO(TraverseStmt(T->getSizeExpr()));
989 })
990 
991 DEF_TRAVERSE_TYPE(DependentAddressSpaceType, {
992  TRY_TO(TraverseStmt(T->getAddrSpaceExpr()));
993  TRY_TO(TraverseType(T->getPointeeType()));
994 })
995 
996 DEF_TRAVERSE_TYPE(DependentSizedExtVectorType, {
997  if (T->getSizeExpr())
998  TRY_TO(TraverseStmt(T->getSizeExpr()));
999  TRY_TO(TraverseType(T->getElementType()));
1000 })
1001 
1002 DEF_TRAVERSE_TYPE(VectorType, { TRY_TO(TraverseType(T->getElementType())); })
1003 
1004 DEF_TRAVERSE_TYPE(ExtVectorType, { TRY_TO(TraverseType(T->getElementType())); })
1005 
1006 DEF_TRAVERSE_TYPE(FunctionNoProtoType,
1007  { TRY_TO(TraverseType(T->getReturnType())); })
1008 
1009 DEF_TRAVERSE_TYPE(FunctionProtoType, {
1010  TRY_TO(TraverseType(T->getReturnType()));
1011 
1012  for (const auto &A : T->param_types()) {
1013  TRY_TO(TraverseType(A));
1014  }
1015 
1016  for (const auto &E : T->exceptions()) {
1017  TRY_TO(TraverseType(E));
1018  }
1019 
1020  if (Expr *NE = T->getNoexceptExpr())
1021  TRY_TO(TraverseStmt(NE));
1022 })
1023 
1026 
1028  { TRY_TO(TraverseStmt(T->getUnderlyingExpr())); })
1029 
1030 DEF_TRAVERSE_TYPE(TypeOfType, { TRY_TO(TraverseType(T->getUnderlyingType())); })
1031 
1033  { TRY_TO(TraverseStmt(T->getUnderlyingExpr())); })
1034 
1036  TRY_TO(TraverseType(T->getBaseType()));
1037  TRY_TO(TraverseType(T->getUnderlyingType()));
1038 })
1039 
1040 DEF_TRAVERSE_TYPE(AutoType, { TRY_TO(TraverseType(T->getDeducedType())); })
1042  TRY_TO(TraverseTemplateName(T->getTemplateName()));
1043  TRY_TO(TraverseType(T->getDeducedType()));
1044 })
1045 
1050  TRY_TO(TraverseType(T->getReplacementType()));
1051 })
1053  TRY_TO(TraverseTemplateArgument(T->getArgumentPack()));
1054 })
1055 
1057  TRY_TO(TraverseTemplateName(T->getTemplateName()));
1058  TRY_TO(TraverseTemplateArguments(T->getArgs(), T->getNumArgs()));
1059 })
1060 
1062 
1064  { TRY_TO(TraverseType(T->getModifiedType())); })
1065 
1066 DEF_TRAVERSE_TYPE(ParenType, { TRY_TO(TraverseType(T->getInnerType())); })
1067 
1069  if (T->getQualifier()) {
1070  TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
1071  }
1072  TRY_TO(TraverseType(T->getNamedType()));
1073 })
1074 
1076  { TRY_TO(TraverseNestedNameSpecifier(T->getQualifier())); })
1077 
1079  TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
1080  TRY_TO(TraverseTemplateArguments(T->getArgs(), T->getNumArgs()));
1081 })
1082 
1083 DEF_TRAVERSE_TYPE(PackExpansionType, { TRY_TO(TraverseType(T->getPattern())); })
1084 
1086 
1088 
1090  // We have to watch out here because an ObjCInterfaceType's base
1091  // type is itself.
1092  if (T->getBaseType().getTypePtr() != T)
1093  TRY_TO(TraverseType(T->getBaseType()));
1094  for (auto typeArg : T->getTypeArgsAsWritten()) {
1095  TRY_TO(TraverseType(typeArg));
1096  }
1097 })
1098 
1100  { TRY_TO(TraverseType(T->getPointeeType())); })
1101 
1102 DEF_TRAVERSE_TYPE(AtomicType, { TRY_TO(TraverseType(T->getValueType())); })
1103 
1104 DEF_TRAVERSE_TYPE(PipeType, { TRY_TO(TraverseType(T->getElementType())); })
1105 
1106 #undef DEF_TRAVERSE_TYPE
1107 
1108 // ----------------- TypeLoc traversal -----------------
1109 
1110 // This macro makes available a variable TL, the passed-in TypeLoc.
1111 // If requested, it calls WalkUpFrom* for the Type in the given TypeLoc,
1112 // in addition to WalkUpFrom* for the TypeLoc itself, such that existing
1113 // clients that override the WalkUpFrom*Type() and/or Visit*Type() methods
1114 // continue to work.
1115 #define DEF_TRAVERSE_TYPELOC(TYPE, CODE) \
1116  template <typename Derived> \
1117  bool RecursiveASTVisitor<Derived>::Traverse##TYPE##Loc(TYPE##Loc TL) { \
1119  TRY_TO(WalkUpFrom##TYPE(const_cast<TYPE *>(TL.getTypePtr()))); \
1120  TRY_TO(WalkUpFrom##TYPE##Loc(TL)); \
1121  { CODE; } \
1122  return true; \
1123  }
1124 
1125 template <typename Derived>
1126 bool
1128  // Move this over to the 'main' typeloc tree. Note that this is a
1129  // move -- we pretend that we were really looking at the unqualified
1130  // typeloc all along -- rather than a recursion, so we don't follow
1131  // the normal CRTP plan of going through
1132  // getDerived().TraverseTypeLoc. If we did, we'd be traversing
1133  // twice for the same type (once as a QualifiedTypeLoc version of
1134  // the type, once as an UnqualifiedTypeLoc version of the type),
1135  // which in effect means we'd call VisitTypeLoc twice with the
1136  // 'same' type. This solves that problem, at the cost of never
1137  // seeing the qualified version of the type (unless the client
1138  // subclasses TraverseQualifiedTypeLoc themselves). It's not a
1139  // perfect solution. A perfect solution probably requires making
1140  // QualifiedTypeLoc a wrapper around TypeLoc -- like QualType is a
1141  // wrapper around Type* -- rather than being its own class in the
1142  // type hierarchy.
1143  return TraverseTypeLoc(TL.getUnqualifiedLoc());
1144 }
1145 
1147 
1148 // FIXME: ComplexTypeLoc is unfinished
1150  TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1151 })
1152 
1154  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1155 
1157  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1158 
1160  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1161 
1163  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1164 
1165 // FIXME: location of base class?
1166 // We traverse this in the type case as well, but how is it not reached through
1167 // the pointee type?
1169  TRY_TO(TraverseType(QualType(TL.getTypePtr()->getClass(), 0)));
1170  TRY_TO(TraverseTypeLoc(TL.getPointeeLoc()));
1171 })
1172 
1174  { TRY_TO(TraverseTypeLoc(TL.getOriginalLoc())); })
1175 
1177  { TRY_TO(TraverseTypeLoc(TL.getOriginalLoc())); })
1178 
1179 template <typename Derived>
1181  // This isn't available for ArrayType, but is for the ArrayTypeLoc.
1183  return true;
1184 }
1185 
1188  return TraverseArrayTypeLocHelper(TL);
1189 })
1190 
1193  return TraverseArrayTypeLocHelper(TL);
1194 })
1195 
1198  return TraverseArrayTypeLocHelper(TL);
1199 })
1200 
1203  return TraverseArrayTypeLocHelper(TL);
1204 })
1205 
1207  TRY_TO(TraverseStmt(TL.getTypePtr()->getAddrSpaceExpr()));
1209 })
1210 
1211 // FIXME: order? why not size expr first?
1212 // FIXME: base VectorTypeLoc is unfinished
1214  if (TL.getTypePtr()->getSizeExpr())
1215  TRY_TO(TraverseStmt(TL.getTypePtr()->getSizeExpr()));
1217 })
1218 
1219 // FIXME: VectorTypeLoc is unfinished
1222 })
1223 
1224 // FIXME: size and attributes
1225 // FIXME: base VectorTypeLoc is unfinished
1228 })
1229 
1231  { TRY_TO(TraverseTypeLoc(TL.getReturnLoc())); })
1232 
1233 // FIXME: location of exception specifications (attributes?)
1235  TRY_TO(TraverseTypeLoc(TL.getReturnLoc()));
1236 
1238 
1239  for (unsigned I = 0, E = TL.getNumParams(); I != E; ++I) {
1240  if (TL.getParam(I)) {
1241  TRY_TO(TraverseDecl(TL.getParam(I)));
1242  } else if (I < T->getNumParams()) {
1244  }
1245  }
1246 
1247  for (const auto &E : T->exceptions()) {
1248  TRY_TO(TraverseType(E));
1249  }
1250 
1251  if (Expr *NE = T->getNoexceptExpr())
1252  TRY_TO(TraverseStmt(NE));
1253 })
1254 
1257 
1259  { TRY_TO(TraverseStmt(TL.getUnderlyingExpr())); })
1260 
1262  TRY_TO(TraverseTypeLoc(TL.getUnderlyingTInfo()->getTypeLoc()));
1263 })
1264 
1265 // FIXME: location of underlying expr
1267  TRY_TO(TraverseStmt(TL.getTypePtr()->getUnderlyingExpr()));
1268 })
1269 
1271  TRY_TO(TraverseTypeLoc(TL.getUnderlyingTInfo()->getTypeLoc()));
1272 })
1273 
1275  TRY_TO(TraverseType(TL.getTypePtr()->getDeducedType()));
1276 })
1277 
1279  TRY_TO(TraverseTemplateName(TL.getTypePtr()->getTemplateName()));
1280  TRY_TO(TraverseType(TL.getTypePtr()->getDeducedType()));
1281 })
1282 
1287  TRY_TO(TraverseType(TL.getTypePtr()->getReplacementType()));
1288 })
1290  TRY_TO(TraverseTemplateArgument(TL.getTypePtr()->getArgumentPack()));
1291 })
1292 
1293 // FIXME: use the loc for the template name?
1295  TRY_TO(TraverseTemplateName(TL.getTypePtr()->getTemplateName()));
1296  for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) {
1297  TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(I)));
1298  }
1299 })
1300 
1302 
1303 DEF_TRAVERSE_TYPELOC(ParenType, { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
1304 
1306  { TRY_TO(TraverseTypeLoc(TL.getModifiedLoc())); })
1307 
1309  if (TL.getQualifierLoc()) {
1310  TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1311  }
1312  TRY_TO(TraverseTypeLoc(TL.getNamedTypeLoc()));
1313 })
1314 
1316  TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1317 })
1318 
1320  if (TL.getQualifierLoc()) {
1321  TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1322  }
1323 
1324  for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) {
1325  TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(I)));
1326  }
1327 })
1328 
1330  { TRY_TO(TraverseTypeLoc(TL.getPatternLoc())); })
1331 
1333 
1335 
1337  // We have to watch out here because an ObjCInterfaceType's base
1338  // type is itself.
1339  if (TL.getTypePtr()->getBaseType().getTypePtr() != TL.getTypePtr())
1340  TRY_TO(TraverseTypeLoc(TL.getBaseLoc()));
1341  for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
1342  TRY_TO(TraverseTypeLoc(TL.getTypeArgTInfo(i)->getTypeLoc()));
1343 })
1344 
1346  { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1347 
1348 DEF_TRAVERSE_TYPELOC(AtomicType, { TRY_TO(TraverseTypeLoc(TL.getValueLoc())); })
1349 
1350 DEF_TRAVERSE_TYPELOC(PipeType, { TRY_TO(TraverseTypeLoc(TL.getValueLoc())); })
1351 
1352 #undef DEF_TRAVERSE_TYPELOC
1353 
1354 // ----------------- Decl traversal -----------------
1355 //
1356 // For a Decl, we automate (in the DEF_TRAVERSE_DECL macro) traversing
1357 // the children that come from the DeclContext associated with it.
1358 // Therefore each Traverse* only needs to worry about children other
1359 // than those.
1360 
1361 template <typename Derived>
1363  const Decl *Child) {
1364  // BlockDecls and CapturedDecls are traversed through BlockExprs and
1365  // CapturedStmts respectively.
1366  return isa<BlockDecl>(Child) || isa<CapturedDecl>(Child);
1367 }
1368 
1369 template <typename Derived>
1371  if (!DC)
1372  return true;
1373 
1374  for (auto *Child : DC->decls()) {
1376  TRY_TO(TraverseDecl(Child));
1377  }
1378 
1379  return true;
1380 }
1381 
1382 // This macro makes available a variable D, the passed-in decl.
1383 #define DEF_TRAVERSE_DECL(DECL, CODE) \
1384  template <typename Derived> \
1385  bool RecursiveASTVisitor<Derived>::Traverse##DECL(DECL *D) { \
1386  bool ShouldVisitChildren = true; \
1387  bool ReturnValue = true; \
1388  if (!getDerived().shouldTraversePostOrder()) \
1389  TRY_TO(WalkUpFrom##DECL(D)); \
1390  { CODE; } \
1391  if (ReturnValue && ShouldVisitChildren) \
1392  TRY_TO(TraverseDeclContextHelper(dyn_cast<DeclContext>(D))); \
1393  if (ReturnValue && getDerived().shouldTraversePostOrder()) \
1394  TRY_TO(WalkUpFrom##DECL(D)); \
1395  return ReturnValue; \
1396  }
1397 
1399 
1401  if (TypeSourceInfo *TInfo = D->getSignatureAsWritten())
1402  TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
1403  TRY_TO(TraverseStmt(D->getBody()));
1404  for (const auto &I : D->captures()) {
1405  if (I.hasCopyExpr()) {
1406  TRY_TO(TraverseStmt(I.getCopyExpr()));
1407  }
1408  }
1409  ShouldVisitChildren = false;
1410 })
1411 
1413  TRY_TO(TraverseStmt(D->getBody()));
1414  ShouldVisitChildren = false;
1415 })
1416 
1418 
1420  { TRY_TO(TraverseStmt(D->getAsmString())); })
1421 
1423 
1425  // Friend is either decl or a type.
1426  if (D->getFriendType())
1427  TRY_TO(TraverseTypeLoc(D->getFriendType()->getTypeLoc()));
1428  else
1429  TRY_TO(TraverseDecl(D->getFriendDecl()));
1430 })
1431 
1433  if (D->getFriendType())
1434  TRY_TO(TraverseTypeLoc(D->getFriendType()->getTypeLoc()));
1435  else
1436  TRY_TO(TraverseDecl(D->getFriendDecl()));
1437  for (unsigned I = 0, E = D->getNumTemplateParameters(); I < E; ++I) {
1438  TemplateParameterList *TPL = D->getTemplateParameterList(I);
1439  for (TemplateParameterList::iterator ITPL = TPL->begin(), ETPL = TPL->end();
1440  ITPL != ETPL; ++ITPL) {
1441  TRY_TO(TraverseDecl(*ITPL));
1442  }
1443  }
1444 })
1445 
1447  TRY_TO(TraverseDecl(D->getSpecialization()));
1448 
1449  if (D->hasExplicitTemplateArgs()) {
1450  const TemplateArgumentListInfo &args = D->templateArgs();
1451  TRY_TO(TraverseTemplateArgumentLocsHelper(args.getArgumentArray(),
1452  args.size()));
1453  }
1454 })
1455 
1457 
1459 
1460 DEF_TRAVERSE_DECL(ObjCPropertyImplDecl, {// FIXME: implement this
1461  })
1462 
1464  TRY_TO(TraverseStmt(D->getAssertExpr()));
1465  TRY_TO(TraverseStmt(D->getMessage()));
1466 })
1467 
1470  {// Code in an unnamed namespace shows up automatically in
1471  // decls_begin()/decls_end(). Thus we don't need to recurse on
1472  // D->getAnonymousNamespace().
1473  })
1474 
1476 
1478 
1480 
1482  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1483 
1484  // We shouldn't traverse an aliased namespace, since it will be
1485  // defined (and, therefore, traversed) somewhere else.
1486  ShouldVisitChildren = false;
1487 })
1488 
1489 DEF_TRAVERSE_DECL(LabelDecl, {// There is no code in a LabelDecl.
1490  })
1491 
1493  NamespaceDecl,
1494  {// Code in an unnamed namespace shows up automatically in
1495  // decls_begin()/decls_end(). Thus we don't need to recurse on
1496  // D->getAnonymousNamespace().
1497  })
1498 
1499 DEF_TRAVERSE_DECL(ObjCCompatibleAliasDecl, {// FIXME: implement
1500  })
1501 
1502 DEF_TRAVERSE_DECL(ObjCCategoryDecl, {// FIXME: implement
1503  if (ObjCTypeParamList *typeParamList = D->getTypeParamList()) {
1504  for (auto typeParam : *typeParamList) {
1505  TRY_TO(TraverseObjCTypeParamDecl(typeParam));
1506  }
1507  }
1508 })
1509 
1510 DEF_TRAVERSE_DECL(ObjCCategoryImplDecl, {// FIXME: implement
1511  })
1512 
1513 DEF_TRAVERSE_DECL(ObjCImplementationDecl, {// FIXME: implement
1514  })
1515 
1516 DEF_TRAVERSE_DECL(ObjCInterfaceDecl, {// FIXME: implement
1517  if (ObjCTypeParamList *typeParamList = D->getTypeParamListAsWritten()) {
1518  for (auto typeParam : *typeParamList) {
1519  TRY_TO(TraverseObjCTypeParamDecl(typeParam));
1520  }
1521  }
1522 
1523  if (TypeSourceInfo *superTInfo = D->getSuperClassTInfo()) {
1524  TRY_TO(TraverseTypeLoc(superTInfo->getTypeLoc()));
1525  }
1526 })
1527 
1528 DEF_TRAVERSE_DECL(ObjCProtocolDecl, {// FIXME: implement
1529  })
1530 
1532  if (D->getReturnTypeSourceInfo()) {
1533  TRY_TO(TraverseTypeLoc(D->getReturnTypeSourceInfo()->getTypeLoc()));
1534  }
1535  for (ParmVarDecl *Parameter : D->parameters()) {
1537  }
1538  if (D->isThisDeclarationADefinition()) {
1539  TRY_TO(TraverseStmt(D->getBody()));
1540  }
1541  ShouldVisitChildren = false;
1542 })
1543 
1545  if (D->hasExplicitBound()) {
1546  TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1547  // We shouldn't traverse D->getTypeForDecl(); it's a result of
1548  // declaring the type alias, not something that was written in the
1549  // source.
1550  }
1551 })
1552 
1554  if (D->getTypeSourceInfo())
1555  TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1556  else
1557  TRY_TO(TraverseType(D->getType()));
1558  ShouldVisitChildren = false;
1559 })
1560 
1562  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1563  TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
1564 })
1565 
1567 
1569  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1570 })
1571 
1573 
1575 
1577  for (auto *I : D->varlists()) {
1578  TRY_TO(TraverseStmt(I));
1579  }
1580 })
1581 
1583  TRY_TO(TraverseStmt(D->getCombiner()));
1584  if (auto *Initializer = D->getInitializer())
1585  TRY_TO(TraverseStmt(Initializer));
1586  TRY_TO(TraverseType(D->getType()));
1587  return true;
1588 })
1589 
1590 DEF_TRAVERSE_DECL(OMPCapturedExprDecl, { TRY_TO(TraverseVarHelper(D)); })
1591 
1592 // A helper method for TemplateDecl's children.
1593 template <typename Derived>
1595  TemplateParameterList *TPL) {
1596  if (TPL) {
1597  for (TemplateParameterList::iterator I = TPL->begin(), E = TPL->end();
1598  I != E; ++I) {
1599  TRY_TO(TraverseDecl(*I));
1600  }
1601  }
1602  return true;
1603 }
1604 
1605 template <typename Derived>
1606 template <typename T>
1608  for (unsigned i = 0; i < D->getNumTemplateParameterLists(); i++) {
1609  TemplateParameterList *TPL = D->getTemplateParameterList(i);
1610  TraverseTemplateParameterListHelper(TPL);
1611  }
1612  return true;
1613 }
1614 
1615 template <typename Derived>
1617  ClassTemplateDecl *D) {
1618  for (auto *SD : D->specializations()) {
1619  for (auto *RD : SD->redecls()) {
1620  // We don't want to visit injected-class-names in this traversal.
1621  if (cast<CXXRecordDecl>(RD)->isInjectedClassName())
1622  continue;
1623 
1624  switch (
1625  cast<ClassTemplateSpecializationDecl>(RD)->getSpecializationKind()) {
1626  // Visit the implicit instantiations with the requested pattern.
1627  case TSK_Undeclared:
1629  TRY_TO(TraverseDecl(RD));
1630  break;
1631 
1632  // We don't need to do anything on an explicit instantiation
1633  // or explicit specialization because there will be an explicit
1634  // node for it elsewhere.
1638  break;
1639  }
1640  }
1641  }
1642 
1643  return true;
1644 }
1645 
1646 template <typename Derived>
1648  VarTemplateDecl *D) {
1649  for (auto *SD : D->specializations()) {
1650  for (auto *RD : SD->redecls()) {
1651  switch (
1652  cast<VarTemplateSpecializationDecl>(RD)->getSpecializationKind()) {
1653  case TSK_Undeclared:
1655  TRY_TO(TraverseDecl(RD));
1656  break;
1657 
1661  break;
1662  }
1663  }
1664  }
1665 
1666  return true;
1667 }
1668 
1669 // A helper method for traversing the instantiations of a
1670 // function while skipping its specializations.
1671 template <typename Derived>
1673  FunctionTemplateDecl *D) {
1674  for (auto *FD : D->specializations()) {
1675  for (auto *RD : FD->redecls()) {
1676  switch (RD->getTemplateSpecializationKind()) {
1677  case TSK_Undeclared:
1679  // We don't know what kind of FunctionDecl this is.
1680  TRY_TO(TraverseDecl(RD));
1681  break;
1682 
1683  // FIXME: For now traverse explicit instantiations here. Change that
1684  // once they are represented as dedicated nodes in the AST.
1687  TRY_TO(TraverseDecl(RD));
1688  break;
1689 
1691  break;
1692  }
1693  }
1694  }
1695 
1696  return true;
1697 }
1698 
1699 // This macro unifies the traversal of class, variable and function
1700 // template declarations.
1701 #define DEF_TRAVERSE_TMPL_DECL(TMPLDECLKIND) \
1702  DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateDecl, { \
1703  TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \
1704  TRY_TO(TraverseDecl(D->getTemplatedDecl())); \
1705  \
1706  /* By default, we do not traverse the instantiations of \
1707  class templates since they do not appear in the user code. The \
1708  following code optionally traverses them. \
1709  \
1710  We only traverse the class instantiations when we see the canonical \
1711  declaration of the template, to ensure we only visit them once. */ \
1712  if (getDerived().shouldVisitTemplateInstantiations() && \
1713  D == D->getCanonicalDecl()) \
1714  TRY_TO(TraverseTemplateInstantiations(D)); \
1715  \
1716  /* Note that getInstantiatedFromMemberTemplate() is just a link \
1717  from a template instantiation back to the template from which \
1718  it was instantiated, and thus should not be traversed. */ \
1719  })
1720 
1723 DEF_TRAVERSE_TMPL_DECL(Function)
1724 
1726  // D is the "T" in something like
1727  // template <template <typename> class T> class container { };
1729  if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) {
1730  TRY_TO(TraverseTemplateArgumentLoc(D->getDefaultArgument()));
1731  }
1732  TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1733 })
1734 
1736  TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1737 })
1738 
1740  // D is the "T" in something like "template<typename T> class vector;"
1741  if (D->getTypeForDecl())
1742  TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
1743  if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
1744  TRY_TO(TraverseTypeLoc(D->getDefaultArgumentInfo()->getTypeLoc()));
1745 })
1746 
1748  TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1749  // We shouldn't traverse D->getTypeForDecl(); it's a result of
1750  // declaring the typedef, not something that was written in the
1751  // source.
1752 })
1753 
1755  TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1756  // We shouldn't traverse D->getTypeForDecl(); it's a result of
1757  // declaring the type alias, not something that was written in the
1758  // source.
1759 })
1760 
1763  TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1764 })
1765 
1767  // A dependent using declaration which was marked with 'typename'.
1768  // template<class T> class A : public B<T> { using typename B<T>::foo; };
1769  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1770  // We shouldn't traverse D->getTypeForDecl(); it's a result of
1771  // declaring the type, not something that was written in the
1772  // source.
1773 })
1774 
1776  TRY_TO(TraverseDeclTemplateParameterLists(D));
1777 
1778  if (D->getTypeForDecl())
1779  TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
1780 
1781  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1782  // The enumerators are already traversed by
1783  // decls_begin()/decls_end().
1784 })
1785 
1786 // Helper methods for RecordDecl and its children.
1787 template <typename Derived>
1789  // We shouldn't traverse D->getTypeForDecl(); it's a result of
1790  // declaring the type, not something that was written in the source.
1791 
1792  TRY_TO(TraverseDeclTemplateParameterLists(D));
1794  return true;
1795 }
1796 
1797 template <typename Derived>
1799  const CXXBaseSpecifier &Base) {
1801  return true;
1802 }
1803 
1804 template <typename Derived>
1806  if (!TraverseRecordHelper(D))
1807  return false;
1808  if (D->isCompleteDefinition()) {
1809  for (const auto &I : D->bases()) {
1811  }
1812  // We don't traverse the friends or the conversions, as they are
1813  // already in decls_begin()/decls_end().
1814  }
1815  return true;
1816 }
1817 
1818 DEF_TRAVERSE_DECL(RecordDecl, { TRY_TO(TraverseRecordHelper(D)); })
1819 
1820 DEF_TRAVERSE_DECL(CXXRecordDecl, { TRY_TO(TraverseCXXRecordHelper(D)); })
1821 
1822 #define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND) \
1823  DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateSpecializationDecl, { \
1824  /* For implicit instantiations ("set<int> x;"), we don't want to \
1825  recurse at all, since the instatiated template isn't written in \
1826  the source code anywhere. (Note the instatiated *type* -- \
1827  set<int> -- is written, and will still get a callback of \
1828  TemplateSpecializationType). For explicit instantiations \
1829  ("template set<int>;"), we do need a callback, since this \
1830  is the only callback that's made for this instantiation. \
1831  We use getTypeAsWritten() to distinguish. */ \
1832  if (TypeSourceInfo *TSI = D->getTypeAsWritten()) \
1833  TRY_TO(TraverseTypeLoc(TSI->getTypeLoc())); \
1834  \
1838  /* Returning from here skips traversing the \
1839  declaration context of the *TemplateSpecializationDecl \
1840  (embedded in the DEF_TRAVERSE_DECL() macro) \
1841  which contains the instantiated members of the template. */ \
1842  return true; \
1843  })
1844 
1847 
1848 template <typename Derived>
1850  const TemplateArgumentLoc *TAL, unsigned Count) {
1851  for (unsigned I = 0; I < Count; ++I) {
1853  }
1854  return true;
1855 }
1856 
1857 #define DEF_TRAVERSE_TMPL_PART_SPEC_DECL(TMPLDECLKIND, DECLKIND) \
1858  DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplatePartialSpecializationDecl, { \
1859  /* The partial specialization. */ \
1860  if (TemplateParameterList *TPL = D->getTemplateParameters()) { \
1861  for (TemplateParameterList::iterator I = TPL->begin(), E = TPL->end(); \
1862  I != E; ++I) { \
1863  TRY_TO(TraverseDecl(*I)); \
1864  } \
1865  } \
1866  /* The args that remains unspecialized. */ \
1867  TRY_TO(TraverseTemplateArgumentLocsHelper( \
1868  D->getTemplateArgsAsWritten()->getTemplateArgs(), \
1869  D->getTemplateArgsAsWritten()->NumTemplateArgs)); \
1870  \
1871  /* Don't need the *TemplatePartialSpecializationHelper, even \
1872  though that's our parent class -- we already visit all the \
1873  template args here. */ \
1874  TRY_TO(Traverse##DECLKIND##Helper(D)); \
1875  \
1876  /* Instantiations will have been visited with the primary template. */ \
1877  })
1878 
1879 DEF_TRAVERSE_TMPL_PART_SPEC_DECL(Class, CXXRecord)
1881 
1882 DEF_TRAVERSE_DECL(EnumConstantDecl, { TRY_TO(TraverseStmt(D->getInitExpr())); })
1883 
1885  // Like UnresolvedUsingTypenameDecl, but without the 'typename':
1886  // template <class T> Class A : public Base<T> { using Base<T>::foo; };
1888  TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
1889 })
1890 
1892 
1893 template <typename Derived>
1895  TRY_TO(TraverseDeclTemplateParameterLists(D));
1897  if (D->getTypeSourceInfo())
1899  else
1900  TRY_TO(TraverseType(D->getType()));
1901  return true;
1902 }
1903 
1905  TRY_TO(TraverseVarHelper(D));
1906  for (auto *Binding : D->bindings()) {
1907  TRY_TO(TraverseDecl(Binding));
1908  }
1909 })
1910 
1913  TRY_TO(TraverseStmt(D->getBinding()));
1914 })
1915 
1916 DEF_TRAVERSE_DECL(MSPropertyDecl, { TRY_TO(TraverseDeclaratorHelper(D)); })
1917 
1919  TRY_TO(TraverseDeclaratorHelper(D));
1920  if (D->isBitField())
1921  TRY_TO(TraverseStmt(D->getBitWidth()));
1922  else if (D->hasInClassInitializer())
1923  TRY_TO(TraverseStmt(D->getInClassInitializer()));
1924 })
1925 
1927  TRY_TO(TraverseDeclaratorHelper(D));
1928  if (D->isBitField())
1929  TRY_TO(TraverseStmt(D->getBitWidth()));
1930  // FIXME: implement the rest.
1931 })
1932 
1934  TRY_TO(TraverseDeclaratorHelper(D));
1935  if (D->isBitField())
1936  TRY_TO(TraverseStmt(D->getBitWidth()));
1937  // FIXME: implement the rest.
1938 })
1939 
1940 template <typename Derived>
1942  TRY_TO(TraverseDeclTemplateParameterLists(D));
1945 
1946  // If we're an explicit template specialization, iterate over the
1947  // template args that were explicitly specified. If we were doing
1948  // this in typing order, we'd do it between the return type and
1949  // the function args, but both are handled by the FunctionTypeLoc
1950  // above, so we have to choose one side. I've decided to do before.
1951  if (const FunctionTemplateSpecializationInfo *FTSI =
1953  if (FTSI->getTemplateSpecializationKind() != TSK_Undeclared &&
1954  FTSI->getTemplateSpecializationKind() != TSK_ImplicitInstantiation) {
1955  // A specialization might not have explicit template arguments if it has
1956  // a templated return type and concrete arguments.
1957  if (const ASTTemplateArgumentListInfo *TALI =
1958  FTSI->TemplateArgumentsAsWritten) {
1959  TRY_TO(TraverseTemplateArgumentLocsHelper(TALI->getTemplateArgs(),
1960  TALI->NumTemplateArgs));
1961  }
1962  }
1963  }
1964 
1965  // Visit the function type itself, which can be either
1966  // FunctionNoProtoType or FunctionProtoType, or a typedef. This
1967  // also covers the return type and the function parameters,
1968  // including exception specifications.
1969  if (TypeSourceInfo *TSI = D->getTypeSourceInfo()) {
1970  TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
1971  } else if (getDerived().shouldVisitImplicitCode()) {
1972  // Visit parameter variable declarations of the implicit function
1973  // if the traverser is visiting implicit code. Parameter variable
1974  // declarations do not have valid TypeSourceInfo, so to visit them
1975  // we need to traverse the declarations explicitly.
1976  for (ParmVarDecl *Parameter : D->parameters()) {
1978  }
1979  }
1980 
1981  if (CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(D)) {
1982  // Constructor initializers.
1983  for (auto *I : Ctor->inits()) {
1985  }
1986  }
1987 
1988  if (D->isThisDeclarationADefinition()) {
1989  TRY_TO(TraverseStmt(D->getBody())); // Function body.
1990  }
1991  return true;
1992 }
1993 
1995  // We skip decls_begin/decls_end, which are already covered by
1996  // TraverseFunctionHelper().
1997  ShouldVisitChildren = false;
1998  ReturnValue = TraverseFunctionHelper(D);
1999 })
2000 
2002  // We skip decls_begin/decls_end, which are already covered by
2003  // TraverseFunctionHelper().
2004  ShouldVisitChildren = false;
2005  ReturnValue = TraverseFunctionHelper(D);
2006 })
2007 
2009  // We skip decls_begin/decls_end, which are already covered by
2010  // TraverseFunctionHelper().
2011  ShouldVisitChildren = false;
2012  ReturnValue = TraverseFunctionHelper(D);
2013 })
2014 
2016  // We skip decls_begin/decls_end, which are already covered by
2017  // TraverseFunctionHelper().
2018  ShouldVisitChildren = false;
2019  ReturnValue = TraverseFunctionHelper(D);
2020 })
2021 
2022 // CXXConversionDecl is the declaration of a type conversion operator.
2023 // It's not a cast expression.
2025  // We skip decls_begin/decls_end, which are already covered by
2026  // TraverseFunctionHelper().
2027  ShouldVisitChildren = false;
2028  ReturnValue = TraverseFunctionHelper(D);
2029 })
2030 
2032  // We skip decls_begin/decls_end, which are already covered by
2033  // TraverseFunctionHelper().
2034  ShouldVisitChildren = false;
2035  ReturnValue = TraverseFunctionHelper(D);
2036 })
2037 
2038 template <typename Derived>
2040  TRY_TO(TraverseDeclaratorHelper(D));
2041  // Default params are taken care of when we traverse the ParmVarDecl.
2042  if (!isa<ParmVarDecl>(D) &&
2043  (!D->isCXXForRangeDecl() || getDerived().shouldVisitImplicitCode()))
2044  TRY_TO(TraverseStmt(D->getInit()));
2045  return true;
2046 }
2047 
2048 DEF_TRAVERSE_DECL(VarDecl, { TRY_TO(TraverseVarHelper(D)); })
2049 
2050 DEF_TRAVERSE_DECL(ImplicitParamDecl, { TRY_TO(TraverseVarHelper(D)); })
2051 
2053  // A non-type template parameter, e.g. "S" in template<int S> class Foo ...
2054  TRY_TO(TraverseDeclaratorHelper(D));
2055  if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
2056  TRY_TO(TraverseStmt(D->getDefaultArgument()));
2057 })
2058 
2060  TRY_TO(TraverseVarHelper(D));
2061 
2062  if (D->hasDefaultArg() && D->hasUninstantiatedDefaultArg() &&
2063  !D->hasUnparsedDefaultArg())
2064  TRY_TO(TraverseStmt(D->getUninstantiatedDefaultArg()));
2065 
2066  if (D->hasDefaultArg() && !D->hasUninstantiatedDefaultArg() &&
2067  !D->hasUnparsedDefaultArg())
2068  TRY_TO(TraverseStmt(D->getDefaultArg()));
2069 })
2070 
2071 #undef DEF_TRAVERSE_DECL
2072 
2073 // ----------------- Stmt traversal -----------------
2074 //
2075 // For stmts, we automate (in the DEF_TRAVERSE_STMT macro) iterating
2076 // over the children defined in children() (every stmt defines these,
2077 // though sometimes the range is empty). Each individual Traverse*
2078 // method only needs to worry about children other than those. To see
2079 // what children() does for a given class, see, e.g.,
2080 // http://clang.llvm.org/doxygen/Stmt_8cpp_source.html
2081 
2082 // This macro makes available a variable S, the passed-in stmt.
2083 #define DEF_TRAVERSE_STMT(STMT, CODE) \
2084  template <typename Derived> \
2086  STMT *S, DataRecursionQueue *Queue) { \
2087  bool ShouldVisitChildren = true; \
2088  bool ReturnValue = true; \
2090  TRY_TO(WalkUpFrom##STMT(S)); \
2091  { CODE; } \
2092  if (ShouldVisitChildren) { \
2093  for (Stmt * SubStmt : getDerived().getStmtChildren(S)) { \
2094  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(SubStmt); \
2095  } \
2096  } \
2097  if (!Queue && ReturnValue && getDerived().shouldTraversePostOrder()) \
2098  TRY_TO(WalkUpFrom##STMT(S)); \
2099  return ReturnValue; \
2100  }
2101 
2103  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getAsmString());
2104  for (unsigned I = 0, E = S->getNumInputs(); I < E; ++I) {
2105  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getInputConstraintLiteral(I));
2106  }
2107  for (unsigned I = 0, E = S->getNumOutputs(); I < E; ++I) {
2108  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOutputConstraintLiteral(I));
2109  }
2110  for (unsigned I = 0, E = S->getNumClobbers(); I < E; ++I) {
2111  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getClobberStringLiteral(I));
2112  }
2113  // children() iterates over inputExpr and outputExpr.
2114 })
2115 
2117  MSAsmStmt,
2118  {// FIXME: MS Asm doesn't currently parse Constraints, Clobbers, etc. Once
2119  // added this needs to be implemented.
2120  })
2121 
2123  TRY_TO(TraverseDecl(S->getExceptionDecl()));
2124  // children() iterates over the handler block.
2125 })
2126 
2128  for (auto *I : S->decls()) {
2129  TRY_TO(TraverseDecl(I));
2130  }
2131  // Suppress the default iteration over children() by
2132  // returning. Here's why: A DeclStmt looks like 'type var [=
2133  // initializer]'. The decls above already traverse over the
2134  // initializers, so we don't have to do it again (which
2135  // children() would do).
2136  ShouldVisitChildren = false;
2137 })
2138 
2139 // These non-expr stmts (most of them), do not need any action except
2140 // iterating over the children.
2162 
2165  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLoopVarStmt());
2166  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRangeInit());
2167  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getBody());
2168  // Visit everything else only if shouldVisitImplicitCode().
2169  ShouldVisitChildren = false;
2170  }
2171 })
2172 
2174  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2175  TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2176 })
2177 
2181 
2183  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2184  TRY_TO(TraverseDeclarationNameInfo(S->getMemberNameInfo()));
2185  if (S->hasExplicitTemplateArgs()) {
2186  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2187  S->getNumTemplateArgs()));
2188  }
2189 })
2190 
2192  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2193  TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2194  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2195  S->getNumTemplateArgs()));
2196 })
2197 
2199  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2200  TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2201  if (S->hasExplicitTemplateArgs()) {
2202  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2203  S->getNumTemplateArgs()));
2204  }
2205 })
2206 
2208  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2209  TRY_TO(TraverseDeclarationNameInfo(S->getMemberNameInfo()));
2210  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2211  S->getNumTemplateArgs()));
2212 })
2213 
2216  {// We don't traverse the cast type, as it's not written in the
2217  // source code.
2218  })
2219 
2221  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2222 })
2223 
2225  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2226 })
2227 
2229  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2230 })
2231 
2233  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2234 })
2235 
2237  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2238 })
2239 
2241  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2242 })
2243 
2244 template <typename Derived>
2246  InitListExpr *S, DataRecursionQueue *Queue) {
2247  if (S) {
2248  // Skip this if we traverse postorder. We will visit it later
2249  // in PostVisitStmt.
2250  if (!getDerived().shouldTraversePostOrder())
2251  TRY_TO(WalkUpFromInitListExpr(S));
2252 
2253  // All we need are the default actions. FIXME: use a helper function.
2254  for (Stmt *SubStmt : S->children()) {
2256  }
2257  }
2258  return true;
2259 }
2260 
2261 // This method is called once for each pair of syntactic and semantic
2262 // InitListExpr, and it traverses the subtrees defined by the two forms. This
2263 // may cause some of the children to be visited twice, if they appear both in
2264 // the syntactic and the semantic form.
2265 //
2266 // There is no guarantee about which form \p S takes when this method is called.
2267 template <typename Derived>
2269  InitListExpr *S, DataRecursionQueue *Queue) {
2271  S->isSemanticForm() ? S->getSyntacticForm() : S, Queue));
2273  S->isSemanticForm() ? S : S->getSemanticForm(), Queue));
2274  return true;
2275 }
2276 
2277 // GenericSelectionExpr is a special case because the types and expressions
2278 // are interleaved. We also need to watch out for null types (default
2279 // generic associations).
2281  TRY_TO(TraverseStmt(S->getControllingExpr()));
2282  for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
2283  if (TypeSourceInfo *TS = S->getAssocTypeSourceInfo(i))
2284  TRY_TO(TraverseTypeLoc(TS->getTypeLoc()));
2285  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getAssocExpr(i));
2286  }
2287  ShouldVisitChildren = false;
2288 })
2289 
2290 // PseudoObjectExpr is a special case because of the weirdness with
2291 // syntactic expressions and opaque values.
2294  for (PseudoObjectExpr::semantics_iterator i = S->semantics_begin(),
2295  e = S->semantics_end();
2296  i != e; ++i) {
2297  Expr *sub = *i;
2298  if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(sub))
2299  sub = OVE->getSourceExpr();
2301  }
2302  ShouldVisitChildren = false;
2303 })
2304 
2306  // This is called for code like 'return T()' where T is a built-in
2307  // (i.e. non-class) type.
2308  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2309 })
2310 
2312  // The child-iterator will pick up the other arguments.
2313  TRY_TO(TraverseTypeLoc(S->getAllocatedTypeSourceInfo()->getTypeLoc()));
2314 })
2315 
2317  // The child-iterator will pick up the expression representing
2318  // the field.
2319  // FIMXE: for code like offsetof(Foo, a.b.c), should we get
2320  // making a MemberExpr callbacks for Foo.a, Foo.a.b, and Foo.a.b.c?
2321  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2322 })
2323 
2325  // The child-iterator will pick up the arg if it's an expression,
2326  // but not if it's a type.
2327  if (S->isArgumentType())
2328  TRY_TO(TraverseTypeLoc(S->getArgumentTypeInfo()->getTypeLoc()));
2329 })
2330 
2332  // The child-iterator will pick up the arg if it's an expression,
2333  // but not if it's a type.
2334  if (S->isTypeOperand())
2335  TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
2336 })
2337 
2339  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2340 })
2341 
2343 
2345  // The child-iterator will pick up the arg if it's an expression,
2346  // but not if it's a type.
2347  if (S->isTypeOperand())
2348  TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
2349 })
2350 
2352  for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
2353  TRY_TO(TraverseTypeLoc(S->getArg(I)->getTypeLoc()));
2354 })
2355 
2357  TRY_TO(TraverseTypeLoc(S->getQueriedTypeSourceInfo()->getTypeLoc()));
2358 })
2359 
2361  { TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getQueriedExpression()); })
2362 
2364  // The child-iterator will pick up the expression argument.
2365  TRY_TO(TraverseTypeLoc(S->getWrittenTypeInfo()->getTypeLoc()));
2366 })
2367 
2369  // This is called for code like 'return T()' where T is a class type.
2370  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2371 })
2372 
2373 // Walk only the visible parts of lambda expressions.
2375  for (unsigned I = 0, N = S->capture_size(); I != N; ++I) {
2376  const LambdaCapture *C = S->capture_begin() + I;
2377  if (C->isExplicit() || getDerived().shouldVisitImplicitCode()) {
2378  TRY_TO(TraverseLambdaCapture(S, C, S->capture_init_begin()[I]));
2379  }
2380  }
2381 
2382  TypeLoc TL = S->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
2384 
2385  if (S->hasExplicitParameters() && S->hasExplicitResultType()) {
2386  // Visit the whole type.
2387  TRY_TO(TraverseTypeLoc(TL));
2388  } else {
2389  if (S->hasExplicitParameters()) {
2390  // Visit parameters.
2391  for (unsigned I = 0, N = Proto.getNumParams(); I != N; ++I) {
2392  TRY_TO(TraverseDecl(Proto.getParam(I)));
2393  }
2394  } else if (S->hasExplicitResultType()) {
2396  }
2397 
2398  auto *T = Proto.getTypePtr();
2399  for (const auto &E : T->exceptions()) {
2400  TRY_TO(TraverseType(E));
2401  }
2402 
2403  if (Expr *NE = T->getNoexceptExpr())
2405  }
2406 
2407  ReturnValue = TRAVERSE_STMT_BASE(LambdaBody, LambdaExpr, S, Queue);
2408  ShouldVisitChildren = false;
2409 })
2410 
2412  // This is called for code like 'T()', where T is a template argument.
2413  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2414 })
2415 
2416 // These expressions all might take explicit template arguments.
2417 // We traverse those if so. FIXME: implement these.
2421 
2422 // These exprs (most of them), do not need any action except iterating
2423 // over the children.
2427 
2429  TRY_TO(TraverseDecl(S->getBlockDecl()));
2430  return true; // no child statements to loop through.
2431 })
2432 
2435  TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2436 })
2439 
2442  TRY_TO(TraverseStmt(S->getExpr()));
2443 })
2444 
2451 
2453  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2454  if (TypeSourceInfo *ScopeInfo = S->getScopeTypeInfo())
2455  TRY_TO(TraverseTypeLoc(ScopeInfo->getTypeLoc()));
2456  if (TypeSourceInfo *DestroyedTypeInfo = S->getDestroyedTypeInfo())
2457  TRY_TO(TraverseTypeLoc(DestroyedTypeInfo->getTypeLoc()));
2458 })
2459 
2470  // FIXME: The source expression of the OVE should be listed as
2471  // a child of the ArrayInitLoopExpr.
2472  if (OpaqueValueExpr *OVE = S->getCommonExpr())
2473  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(OVE->getSourceExpr());
2474 })
2477 
2479  if (TypeSourceInfo *TInfo = S->getEncodedTypeSourceInfo())
2480  TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
2481 })
2482 
2485 
2487  if (TypeSourceInfo *TInfo = S->getClassReceiverTypeInfo())
2488  TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
2489 })
2490 
2496 
2498  TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2499 })
2500 
2509  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2510  if (S->hasExplicitTemplateArgs()) {
2511  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2512  S->getNumTemplateArgs()));
2513  }
2514 })
2515 
2517  TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2518  if (S->hasExplicitTemplateArgs()) {
2519  TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2520  S->getNumTemplateArgs()));
2521  }
2522 })
2523 
2528 DEF_TRAVERSE_STMT(CapturedStmt, { TRY_TO(TraverseDecl(S->getCapturedDecl())); })
2529 
2534 
2535 // These operators (all of them) do not need any action except
2536 // iterating over the children.
2551 
2552 // For coroutines expressions, traverse either the operand
2553 // as written or the implied calls, depending on what the
2554 // derived class requests.
2557  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getBody());
2558  ShouldVisitChildren = false;
2559  }
2560 })
2562  if (!getDerived().shouldVisitImplicitCode()) {
2563  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand());
2564  ShouldVisitChildren = false;
2565  }
2566 })
2568  if (!getDerived().shouldVisitImplicitCode()) {
2569  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand());
2570  ShouldVisitChildren = false;
2571  }
2572 })
2574  if (!getDerived().shouldVisitImplicitCode()) {
2575  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand());
2576  ShouldVisitChildren = false;
2577  }
2578 })
2580  if (!getDerived().shouldVisitImplicitCode()) {
2581  TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getOperand());
2582  ShouldVisitChildren = false;
2583  }
2584 })
2585 
2586 // These literals (all of them) do not need any action.
2596 
2597 // Traverse OpenCL: AsType, Convert.
2599 
2600 // OpenMP directives.
2601 template <typename Derived>
2604  for (auto *C : S->clauses()) {
2605  TRY_TO(TraverseOMPClause(C));
2606  }
2607  return true;
2608 }
2609 
2610 template <typename Derived>
2611 bool
2613  return TraverseOMPExecutableDirective(S);
2614 }
2615 
2617  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2618 
2620  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2621 
2623  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2624 
2626  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2627 
2629  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2630 
2632  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2633 
2635  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2636 
2638  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2639 
2641  TRY_TO(TraverseDeclarationNameInfo(S->getDirectiveName()));
2642  TRY_TO(TraverseOMPExecutableDirective(S));
2643 })
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(TraverseOMPExecutableDirective(S)); })
2665 
2667  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2668 
2670  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2671 
2673  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2674 
2676  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2677 
2679  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2680 
2682  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2683 
2685  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2686 
2688  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2689 
2691  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2692 
2694  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2695 
2697  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2698 
2700  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2701 
2703  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2704 
2706  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2707 
2709  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2710 
2712  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2713 
2715  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2716 
2718  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2719 
2721  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2722 
2724  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2725 
2727  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2728 
2730  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2731 
2733  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2734 
2736  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2737 
2739  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2740 
2742  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2743 
2745  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2746 
2748  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2749 
2751  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2752 
2754  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2755 
2757  { TRY_TO(TraverseOMPExecutableDirective(S)); })
2758 
2759 // OpenMP clauses.
2760 template <typename Derived>
2762  if (!C)
2763  return true;
2764  switch (C->getClauseKind()) {
2765 #define OPENMP_CLAUSE(Name, Class) \
2766  case OMPC_##Name: \
2767  TRY_TO(Visit##Class(static_cast<Class *>(C))); \
2768  break;
2769 #include "clang/Basic/OpenMPKinds.def"
2770  case OMPC_threadprivate:
2771  case OMPC_uniform:
2772  case OMPC_unknown:
2773  break;
2774  }
2775  return true;
2776 }
2777 
2778 template <typename Derived>
2782  return true;
2783 }
2784 
2785 template <typename Derived>
2787  OMPClauseWithPostUpdate *Node) {
2788  TRY_TO(VisitOMPClauseWithPreInit(Node));
2790  return true;
2791 }
2792 
2793 template <typename Derived>
2795  TRY_TO(VisitOMPClauseWithPreInit(C));
2797  return true;
2798 }
2799 
2800 template <typename Derived>
2803  return true;
2804 }
2805 
2806 template <typename Derived>
2807 bool
2809  TRY_TO(VisitOMPClauseWithPreInit(C));
2811  return true;
2812 }
2813 
2814 template <typename Derived>
2817  return true;
2818 }
2819 
2820 template <typename Derived>
2823  return true;
2824 }
2825 
2826 template <typename Derived>
2827 bool
2830  return true;
2831 }
2832 
2833 template <typename Derived>
2835  return true;
2836 }
2837 
2838 template <typename Derived>
2840  return true;
2841 }
2842 
2843 template <typename Derived>
2844 bool
2846  TRY_TO(VisitOMPClauseWithPreInit(C));
2848  return true;
2849 }
2850 
2851 template <typename Derived>
2854  return true;
2855 }
2856 
2857 template <typename Derived>
2859  return true;
2860 }
2861 
2862 template <typename Derived>
2864  return true;
2865 }
2866 
2867 template <typename Derived>
2868 bool
2870  return true;
2871 }
2872 
2873 template <typename Derived>
2875  return true;
2876 }
2877 
2878 template <typename Derived>
2880  return true;
2881 }
2882 
2883 template <typename Derived>
2885  return true;
2886 }
2887 
2888 template <typename Derived>
2890  return true;
2891 }
2892 
2893 template <typename Derived>
2895  return true;
2896 }
2897 
2898 template <typename Derived>
2900  return true;
2901 }
2902 
2903 template <typename Derived>
2905  return true;
2906 }
2907 
2908 template <typename Derived>
2910  return true;
2911 }
2912 
2913 template <typename Derived>
2914 template <typename T>
2916  for (auto *E : Node->varlists()) {
2917  TRY_TO(TraverseStmt(E));
2918  }
2919  return true;
2920 }
2921 
2922 template <typename Derived>
2924  TRY_TO(VisitOMPClauseList(C));
2925  for (auto *E : C->private_copies()) {
2926  TRY_TO(TraverseStmt(E));
2927  }
2928  return true;
2929 }
2930 
2931 template <typename Derived>
2933  OMPFirstprivateClause *C) {
2934  TRY_TO(VisitOMPClauseList(C));
2935  TRY_TO(VisitOMPClauseWithPreInit(C));
2936  for (auto *E : C->private_copies()) {
2937  TRY_TO(TraverseStmt(E));
2938  }
2939  for (auto *E : C->inits()) {
2940  TRY_TO(TraverseStmt(E));
2941  }
2942  return true;
2943 }
2944 
2945 template <typename Derived>
2947  OMPLastprivateClause *C) {
2948  TRY_TO(VisitOMPClauseList(C));
2949  TRY_TO(VisitOMPClauseWithPostUpdate(C));
2950  for (auto *E : C->private_copies()) {
2951  TRY_TO(TraverseStmt(E));
2952  }
2953  for (auto *E : C->source_exprs()) {
2954  TRY_TO(TraverseStmt(E));
2955  }
2956  for (auto *E : C->destination_exprs()) {
2957  TRY_TO(TraverseStmt(E));
2958  }
2959  for (auto *E : C->assignment_ops()) {
2960  TRY_TO(TraverseStmt(E));
2961  }
2962  return true;
2963 }
2964 
2965 template <typename Derived>
2967  TRY_TO(VisitOMPClauseList(C));
2968  return true;
2969 }
2970 
2971 template <typename Derived>
2973  TRY_TO(TraverseStmt(C->getStep()));
2974  TRY_TO(TraverseStmt(C->getCalcStep()));
2975  TRY_TO(VisitOMPClauseList(C));
2976  TRY_TO(VisitOMPClauseWithPostUpdate(C));
2977  for (auto *E : C->privates()) {
2978  TRY_TO(TraverseStmt(E));
2979  }
2980  for (auto *E : C->inits()) {
2981  TRY_TO(TraverseStmt(E));
2982  }
2983  for (auto *E : C->updates()) {
2984  TRY_TO(TraverseStmt(E));
2985  }
2986  for (auto *E : C->finals()) {
2987  TRY_TO(TraverseStmt(E));
2988  }
2989  return true;
2990 }
2991 
2992 template <typename Derived>
2995  TRY_TO(VisitOMPClauseList(C));
2996  return true;
2997 }
2998 
2999 template <typename Derived>
3001  TRY_TO(VisitOMPClauseList(C));
3002  for (auto *E : C->source_exprs()) {
3003  TRY_TO(TraverseStmt(E));
3004  }
3005  for (auto *E : C->destination_exprs()) {
3006  TRY_TO(TraverseStmt(E));
3007  }
3008  for (auto *E : C->assignment_ops()) {
3009  TRY_TO(TraverseStmt(E));
3010  }
3011  return true;
3012 }
3013 
3014 template <typename Derived>
3016  OMPCopyprivateClause *C) {
3017  TRY_TO(VisitOMPClauseList(C));
3018  for (auto *E : C->source_exprs()) {
3019  TRY_TO(TraverseStmt(E));
3020  }
3021  for (auto *E : C->destination_exprs()) {
3022  TRY_TO(TraverseStmt(E));
3023  }
3024  for (auto *E : C->assignment_ops()) {
3025  TRY_TO(TraverseStmt(E));
3026  }
3027  return true;
3028 }
3029 
3030 template <typename Derived>
3031 bool
3035  TRY_TO(VisitOMPClauseList(C));
3036  TRY_TO(VisitOMPClauseWithPostUpdate(C));
3037  for (auto *E : C->privates()) {
3038  TRY_TO(TraverseStmt(E));
3039  }
3040  for (auto *E : C->lhs_exprs()) {
3041  TRY_TO(TraverseStmt(E));
3042  }
3043  for (auto *E : C->rhs_exprs()) {
3044  TRY_TO(TraverseStmt(E));
3045  }
3046  for (auto *E : C->reduction_ops()) {
3047  TRY_TO(TraverseStmt(E));
3048  }
3049  return true;
3050 }
3051 
3052 template <typename Derived>
3057  TRY_TO(VisitOMPClauseList(C));
3058  TRY_TO(VisitOMPClauseWithPostUpdate(C));
3059  for (auto *E : C->privates()) {
3060  TRY_TO(TraverseStmt(E));
3061  }
3062  for (auto *E : C->lhs_exprs()) {
3063  TRY_TO(TraverseStmt(E));
3064  }
3065  for (auto *E : C->rhs_exprs()) {
3066  TRY_TO(TraverseStmt(E));
3067  }
3068  for (auto *E : C->reduction_ops()) {
3069  TRY_TO(TraverseStmt(E));
3070  }
3071  return true;
3072 }
3073 
3074 template <typename Derived>
3076  OMPInReductionClause *C) {
3079  TRY_TO(VisitOMPClauseList(C));
3080  TRY_TO(VisitOMPClauseWithPostUpdate(C));
3081  for (auto *E : C->privates()) {
3082  TRY_TO(TraverseStmt(E));
3083  }
3084  for (auto *E : C->lhs_exprs()) {
3085  TRY_TO(TraverseStmt(E));
3086  }
3087  for (auto *E : C->rhs_exprs()) {
3088  TRY_TO(TraverseStmt(E));
3089  }
3090  for (auto *E : C->reduction_ops()) {
3091  TRY_TO(TraverseStmt(E));
3092  }
3093  for (auto *E : C->taskgroup_descriptors())
3094  TRY_TO(TraverseStmt(E));
3095  return true;
3096 }
3097 
3098 template <typename Derived>
3100  TRY_TO(VisitOMPClauseList(C));
3101  return true;
3102 }
3103 
3104 template <typename Derived>
3106  TRY_TO(VisitOMPClauseList(C));
3107  return true;
3108 }
3109 
3110 template <typename Derived>
3112  TRY_TO(VisitOMPClauseWithPreInit(C));
3113  TRY_TO(TraverseStmt(C->getDevice()));
3114  return true;
3115 }
3116 
3117 template <typename Derived>
3119  TRY_TO(VisitOMPClauseList(C));
3120  return true;
3121 }
3122 
3123 template <typename Derived>
3125  OMPNumTeamsClause *C) {
3126  TRY_TO(VisitOMPClauseWithPreInit(C));
3128  return true;
3129 }
3130 
3131 template <typename Derived>
3133  OMPThreadLimitClause *C) {
3134  TRY_TO(VisitOMPClauseWithPreInit(C));
3136  return true;
3137 }
3138 
3139 template <typename Derived>
3141  OMPPriorityClause *C) {
3143  return true;
3144 }
3145 
3146 template <typename Derived>
3148  OMPGrainsizeClause *C) {
3150  return true;
3151 }
3152 
3153 template <typename Derived>
3155  OMPNumTasksClause *C) {
3157  return true;
3158 }
3159 
3160 template <typename Derived>
3162  TRY_TO(TraverseStmt(C->getHint()));
3163  return true;
3164 }
3165 
3166 template <typename Derived>
3168  OMPDistScheduleClause *C) {
3169  TRY_TO(VisitOMPClauseWithPreInit(C));
3171  return true;
3172 }
3173 
3174 template <typename Derived>
3175 bool
3177  return true;
3178 }
3179 
3180 template <typename Derived>
3182  TRY_TO(VisitOMPClauseList(C));
3183  return true;
3184 }
3185 
3186 template <typename Derived>
3188  TRY_TO(VisitOMPClauseList(C));
3189  return true;
3190 }
3191 
3192 template <typename Derived>
3194  OMPUseDevicePtrClause *C) {
3195  TRY_TO(VisitOMPClauseList(C));
3196  return true;
3197 }
3198 
3199 template <typename Derived>
3201  OMPIsDevicePtrClause *C) {
3202  TRY_TO(VisitOMPClauseList(C));
3203  return true;
3204 }
3205 
3206 // FIXME: look at the following tricky-seeming exprs to see if we
3207 // need to recurse on anything. These are ones that have methods
3208 // returning decls or qualtypes or nestednamespecifier -- though I'm
3209 // not sure if they own them -- or just seemed very complicated, or
3210 // had lots of sub-types to explore.
3211 //
3212 // VisitOverloadExpr and its children: recurse on template args? etc?
3213 
3214 // FIXME: go through all the stmts and exprs again, and see which of them
3215 // create new types, and recurse on the types (TypeLocs?) of those.
3216 // Candidates:
3217 //
3218 // http://clang.llvm.org/doxygen/classclang_1_1CXXTypeidExpr.html
3219 // http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html
3220 // http://clang.llvm.org/doxygen/classclang_1_1TypesCompatibleExpr.html
3221 // Every class that has getQualifier.
3222 
3223 #undef DEF_TRAVERSE_STMT
3224 #undef TRAVERSE_STMT
3225 #undef TRAVERSE_STMT_BASE
3226 
3227 #undef TRY_TO
3228 
3229 } // end namespace clang
3230 
3231 #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:1517
This represents &#39;#pragma omp distribute simd&#39; composite directive.
Definition: StmtOpenMP.h:3188
This represents &#39;#pragma omp master&#39; directive.
Definition: StmtOpenMP.h:1371
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
Definition: Type.h:4786
VarDecl * getCapturedVar() const
Retrieve the declaration of the local variable being captured.
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:565
This represents &#39;#pragma omp task&#39; directive.
Definition: StmtOpenMP.h:1711
This represents a GCC inline-assembly statement extension.
Definition: Stmt.h:1616
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1698
Represents a &#39;co_await&#39; expression while the type of the promise is dependent.
Definition: ExprCXX.h:4340
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:2367
bool TraverseLambdaBody(LambdaExpr *LE, DataRecursionQueue *Queue=nullptr)
Recursively visit the body of a lambda expression.
bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier &Base)
Recursively visit a base specifier.
helper_expr_const_range lhs_exprs() const
This represents clause &#39;copyin&#39; in the &#39;#pragma omp ...&#39; directives.
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:497
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2285
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
Definition: Type.h:3729
A (possibly-)qualified type.
Definition: Type.h:653
base_class_range bases()
Definition: DeclCXX.h:773
#define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND)
ArrayRef< OMPClause * > clauses()
Definition: StmtOpenMP.h:235
bool shouldWalkTypesOfTypeLocs() const
Return whether this visitor should recurse into the types of TypeLocs.
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:404
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2339
DEF_TRAVERSE_TYPE(ComplexType, { TRY_TO(TraverseType(T->getElementType()));}) DEF_TRAVERSE_TYPE(PointerType
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Definition: TemplateBase.h:526
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:974
helper_expr_const_range rhs_exprs() const
private_copies_range private_copies()
Expr *const * semantics_iterator
Definition: Expr.h:5035
Represents a &#39;co_return&#39; statement in the C++ Coroutines TS.
Definition: StmtCXX.h:432
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:929
#define UNARYOP_LIST()
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
Definition: Type.cpp:456
Class that handles pre-initialization statement for some clauses, like &#39;shedule&#39;, &#39;firstprivate&#39; etc...
Definition: OpenMPClause.h:99
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
Definition: Decl.h:2665
TypedefDecl - Represents the declaration of a typedef-name via the &#39;typedef&#39; type specifier...
Definition: Decl.h:2892
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:4851
This represents &#39;#pragma omp for simd&#39; directive.
Definition: StmtOpenMP.h:1121
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:86
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:3599
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition: Expr.h:4545
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:2736
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:2337
StringRef P
Represents a C++11 auto or C++14 decltype(auto) type.
Definition: Type.h:4403
Represents an attribute applied to a statement.
Definition: Stmt.h:878
ParenExpr - This represents a parethesized expression, e.g.
Definition: Expr.h:1665
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:1328
This represents &#39;priority&#39; clause in the &#39;#pragma omp ...&#39; directive.
The base class of the type hierarchy.
Definition: Type.h:1353
Represents an empty-declaration.
Definition: Decl.h:4075
helper_expr_const_range lhs_exprs() const
This represents &#39;#pragma omp target teams distribute&#39; combined directive.
Definition: StmtOpenMP.h:3736
Represents Objective-C&#39;s @throw statement.
Definition: StmtObjC.h:313
bool isSemanticForm() const
Definition: Expr.h:4022
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:443
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
NamespaceDecl - Represent a C++ namespace.
Definition: Decl.h:506
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1239
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition: ExprObjC.h:802
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent...
Definition: ExprCXX.h:2423
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:365
A container of type source information.
Definition: Decl.h:86
This represents &#39;update&#39; clause in the &#39;#pragma omp atomic&#39; directive.
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:308
This represents &#39;#pragma omp parallel for&#39; directive.
Definition: StmtOpenMP.h:1492
MS property subscript expression.
Definition: ExprCXX.h:797
This represents &#39;#pragma omp target teams distribute parallel for&#39; combined directive.
Definition: StmtOpenMP.h:3804
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:2397
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:4035
Expr * getAlignment()
Returns alignment.
Expr * getNumForLoops() const
Return the number of associated for-loops.
Definition: OpenMPClause.h:960
QualType getElementType() const
Definition: Type.h:2595
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
Definition: Decl.h:3091
Represents a #pragma comment line.
Definition: Decl.h:139
An identifier, stored as an IdentifierInfo*.
This represents &#39;#pragma omp target exit data&#39; directive.
Definition: StmtOpenMP.h:2403
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()))
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:807
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:1436
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:2637
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
Definition: TypeLoc.h:272
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:1576
Declaration context for names declared as extern "C" in C++.
Definition: Decl.h:221
Represents a C++17 deduced template specialization type.
Definition: Type.h:4439
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:595
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:594
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:985
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
Definition: ExprCXX.h:3000
ParmVarDecl - Represents a parameter to a function.
Definition: Decl.h:1514
Represents the result of substituting a type for a template type parameter.
Definition: Type.h:4258
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...
const Type * getTypePtr() const
Definition: TypeLoc.h:134
This represents &#39;safelen&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:447
PipeType - OpenCL20.
Definition: Type.h:5650
A C++ static_cast expression (C++ [expr.static.cast]).
Definition: ExprCXX.h:302
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:56
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:839
RecordDecl - Represents a struct/union/class.
Definition: Decl.h:3482
Represents a C99 designated initializer expression.
Definition: Expr.h:4106
This represents &#39;#pragma omp parallel&#39; directive.
Definition: StmtOpenMP.h:251
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition: Expr.h:3533
Represents a class type in Objective C.
Definition: Type.h:5186
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:330
A C++ nested-name-specifier augmented with source location information.
Represents a dependent template name that cannot be resolved prior to template instantiation.
Definition: TemplateName.h:422
This represents &#39;simd&#39; clause in the &#39;#pragma omp ...&#39; directive.
TypeSourceInfo * getTypeSourceInfo() const
Definition: TemplateBase.h:501
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)
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2461
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:2299
Represents a place-holder for an object not to be initialized by anything.
Definition: Expr.h:4400
CompoundStmt * getBody() const
Retrieve the body of the lambda.
Definition: ExprCXX.cpp:1014
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:3744
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.
Represents the result of substituting a set of types for a template type parameter pack...
Definition: Type.h:4314
ParmVarDecl * getParam(unsigned i) const
Definition: TypeLoc.h:1477
This represents &#39;#pragma omp target simd&#39; directive.
Definition: StmtOpenMP.h:3324
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
Definition: ExprCXX.h:3439
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:4790
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.
Represents an access specifier followed by colon &#39;:&#39;.
Definition: DeclCXX.h:131
This represents &#39;#pragma omp barrier&#39; directive.
Definition: StmtOpenMP.h:1823
Wrapper of type source information for a type with no direct qualifiers.
Definition: TypeLoc.h:246
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:313
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:3894
This represents &#39;#pragma omp critical&#39; directive.
Definition: StmtOpenMP.h:1418
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:2164
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:507
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:1308
Describes an C or C++ initializer list.
Definition: Expr.h:3872
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition: ExprCXX.h:638
Represents a C++ using-declaration.
Definition: DeclCXX.h:3275
This represents &#39;#pragma omp distribute parallel for&#39; composite directive.
Definition: StmtOpenMP.h:3039
This represents &#39;#pragma omp teams distribute parallel for simd&#39; composite directive.
Definition: StmtOpenMP.h:3528
An rvalue reference type, per C++11 [dcl.ref].
Definition: Type.h:2486
ForStmt - This represents a &#39;for (init;cond;inc)&#39; stmt.
Definition: Stmt.h:1203
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
Stmt * getBody(const FunctionDecl *&Definition) const
getBody - Retrieve the body (definition) of the function.
Definition: Decl.cpp:2612
A convenient class for passing around template argument information.
Definition: TemplateBase.h:546
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.
#define DEF_TRAVERSE_DECL(DECL, CODE)
const Stmt * getPreInitStmt() const
Get pre-initialization statement for the clause.
Definition: OpenMPClause.h:121
child_range children()
Definition: Stmt.cpp:226
Represents a typeof (or typeof) expression (a GCC extension).
Definition: Type.h:3784
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:2985
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
Definition: Decl.h:746
CXXForRangeStmt - This represents C++0x [stmt.ranged]&#39;s ranged for statement, represented as &#39;for (ra...
Definition: StmtCXX.h:128
bool isNull() const
Definition: TypeLoc.h:118
child_range children()
Definition: Expr.h:4055
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:570
This represents &#39;#pragma omp cancellation point&#39; directive.
Definition: StmtOpenMP.h:2658
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
Definition: Decl.cpp:3337
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
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
Definition: Expr.h:5232
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:2601
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:3458
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2083
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1196
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1580
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:3202
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...
This represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:3860
Represents an ObjC class declaration.
Definition: DeclObjC.h:1191
#define DEF_TRAVERSE_TMPL_PART_SPEC_DECL(TMPLDECLKIND, DECLKIND)
Represents a linkage specification.
Definition: DeclCXX.h:2743
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda&#39;s captures is an init-capture.
Definition: ExprCXX.cpp:956
A binding in a decomposition declaration.
Definition: DeclCXX.h:3718
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
helper_expr_const_range source_exprs() const
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1042
Represents an extended vector type where either the type or size is dependent.
Definition: Type.h:2876
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:945
Represents a K&R-style &#39;int foo()&#39; function, which has no information available about its arguments...
Definition: Type.h:3235
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2778
helper_expr_const_range reduction_ops() const
This represents &#39;#pragma omp target parallel for simd&#39; directive.
Definition: StmtOpenMP.h:3256
OpenMP 4.0 [2.4, Array Sections].
Definition: ExprOpenMP.h:45
ConditionalOperator - The ?: ternary operator.
Definition: Expr.h:3269
#define CAO_LIST()
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition: ExprCXX.h:2197
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x alias-declaration.
Definition: Decl.h:2912
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:595
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3270
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:1911
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:1386
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:681
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:2031
helper_expr_const_range private_copies() const
This represents clause &#39;task_reduction&#39; in the &#39;#pragma omp taskgroup&#39; directives.
Represents a call to the builtin function __builtin_va_arg.
Definition: Expr.h:3778
helper_expr_const_range destination_exprs() const
spec_range specializations() const
This represents &#39;#pragma omp distribute&#39; directive.
Definition: StmtOpenMP.h:2912
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
Represents an array type in C++ whose size is a value-dependent expression.
Definition: Type.h:2774
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:1802
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition: DeclCXX.h:3163
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
Definition: Decl.h:3689
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.
Expr - This represents one expression.
Definition: Expr.h:106
bool TraverseConstructorInitializer(CXXCtorInitializer *Init)
Recursively visit a constructor initializer.
const FunctionProtoType * T
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:321
Represents a C++ functional cast expression that builds a temporary object.
Definition: ExprCXX.h:1530
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:420
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:4851
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2620
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
Definition: Decl.h:1969
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:551
This represents &#39;#pragma omp target teams distribute parallel for simd&#39; combined directive.
Definition: StmtOpenMP.h:3888
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:3724
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:4896
bool VisitQualifiedTypeLoc(QualifiedTypeLoc TL)
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
Definition: TemplateName.h:178
Represents the type decltype(expr) (C++11).
Definition: Type.h:3854
This represents &#39;#pragma omp target teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:3961
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.
Definition: OpenMPClause.h:925
This represents &#39;#pragma omp for&#39; directive.
Definition: StmtOpenMP.h:1044
A unary type transform, which is a type constructed from another.
Definition: Type.h:3897
Declaration of an alias template.
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4145
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
Definition: Stmt.h:1413
This represents &#39;#pragma omp target teams&#39; directive.
Definition: StmtOpenMP.h:3677
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:903
This represents a Microsoft inline-assembly statement extension.
Definition: Stmt.h:1795
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:1717
Represents a GCC generic vector type.
Definition: Type.h:2916
A member reference to an MSPropertyDecl.
Definition: ExprCXX.h:728
An lvalue reference type, per C++11 [dcl.ref].
Definition: Type.h:2468
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:3838
Expr * getDevice()
Return device number.
This represents &#39;#pragma omp cancel&#39; directive.
Definition: StmtOpenMP.h:2716
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:1911
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2682
This template specialization was implicitly instantiated from a template.
Definition: Specifiers.h:149
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:2922
bool isNull() const
Return true if this QualType doesn&#39;t point to a type yet.
Definition: Type.h:719
return TraverseArrayTypeLocHelper(TL)
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLock is not of the desire...
Definition: TypeLoc.h:2348
TypeLoc getReturnLoc() const
Definition: TypeLoc.h:1480
This file defines OpenMP AST classes for clauses.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
Definition: Expr.h:1463
This represents &#39;#pragma omp flush&#39; directive.
Definition: StmtOpenMP.h:1984
This represents &#39;#pragma omp parallel for simd&#39; directive.
Definition: StmtOpenMP.h:1572
DoStmt - This represents a &#39;do/while&#39; stmt.
Definition: Stmt.h:1154
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;#pragma omp target enter data&#39; directive.
Definition: StmtOpenMP.h:2344
Wrapper for source info for arrays.
Definition: TypeLoc.h:1529
Represents a C++ Modules TS module export declaration.
Definition: Decl.h:4030
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:338
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Definition: Expr.h:868
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition: Expr.h:3601
This captures a statement into a function.
Definition: Stmt.h:2054
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition: ExprCXX.h:1400
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:4969
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:1316
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Sugar for parentheses used when specifying types.
Definition: Type.h:2255
This represents &#39;hint&#39; clause in the &#39;#pragma omp ...&#39; directive.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Definition: Type.h:4004
This represents &#39;#pragma omp declare reduction ...&#39; directive.
Definition: DeclOpenMP.h:102
Pseudo declaration for capturing expressions.
Definition: DeclOpenMP.h:187
Represents typeof(type), a GCC extension.
Definition: Type.h:3827
Interfaces are the core concept in Objective-C for object oriented design.
Definition: Type.h:5386
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:1842
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit...
Definition: ExprCXX.h:457
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:744
Represents a call to a member function that may be written either with member call syntax (e...
Definition: ExprCXX.h:164
#define TRAVERSE_STMT_BASE(NAME, CLASS, VAR, QUEUE)
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Definition: Stmt.h:487
LabelDecl - Represents the declaration of a label.
Definition: Decl.h:460
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:3494
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:1964
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:1867
This file defines OpenMP nodes for declarative directives.
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2299
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:5103
Expr * getNoexceptExpr() const
Definition: Type.h:3577
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:746
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:2822
This represents &#39;#pragma omp target&#39; directive.
Definition: StmtOpenMP.h:2228
Expr * getNumForLoops() const
Return the number of associated for-loops.
Definition: OpenMPClause.h:590
TypeClass getTypeClass() const
Definition: Type.h:1615
This template specialization was instantiated from a template due to an explicit instantiation defini...
Definition: Specifiers.h:161
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
Definition: Specifiers.h:146
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:2493
DeclarationNameInfo getNameInfo() const
Definition: Decl.h:1902
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3669
This represents &#39;#pragma omp ordered&#39; directive.
Definition: StmtOpenMP.h:2039
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition: Expr.h:3488
This represents &#39;#pragma omp target update&#39; directive.
Definition: StmtOpenMP.h:2980
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:295
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:240
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:3965
Represents a pointer type decayed from an array or function type.
Definition: Type.h:2370
The injected class name of a C++ class template or class template partial specialization.
Definition: Type.h:4635
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:2854
TypeLoc getElementLoc() const
Definition: TypeLoc.h:1562
Represents a pack expansion of types.
Definition: Type.h:4996
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:3191
Defines various enumerations that describe declaration and type specifiers.
Represents a C11 generic selection.
Definition: Expr.h:4684
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
Definition: Decl.h:3198
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:3444
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers...
Definition: ExprObjC.h:1572
ast_type_traits::DynTypedNode Node
Represents a reference to a function parameter pack that has been substituted but not yet expanded...
Definition: ExprCXX.h:3957
Represents a template argument.
Definition: TemplateBase.h:51
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons...
Definition: Type.h:2333
Represents a template name that was expressed as a qualified name.
Definition: TemplateName.h:366
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition: Stmt.h:556
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:493
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1188
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1252
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:2071
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:494
This represents &#39;#pragma omp section&#39; directive.
Definition: StmtOpenMP.h:1254
This represents &#39;#pragma omp teams distribute&#39; directive.
Definition: StmtOpenMP.h:3390
#define DEF_TRAVERSE_TMPL_INST(TMPLDECLKIND)
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
Definition: Decl.h:2705
Expr * getSourceExpression() const
Definition: TemplateBase.h:506
const Expr * getInit() const
Definition: Decl.h:1213
A runtime availability query.
Definition: ExprObjC.h:1633
A decomposition declaration.
Definition: DeclCXX.h:3766
This template specialization was instantiated from a template due to an explicit instantiation declar...
Definition: Specifiers.h:157
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition: ExprCXX.h:380
This represents &#39;#pragma omp simd&#39; directive.
Definition: StmtOpenMP.h:979
Represents a &#39;co_yield&#39; expression.
Definition: ExprCXX.h:4387
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3590
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:576
ArrayRef< QualType > exceptions() const
Definition: Type.h:3653
Kind getKind() const
Definition: DeclBase.h:419
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:3652
This represents clause &#39;linear&#39; in the &#39;#pragma omp ...&#39; directives.
EnumDecl - Represents an enum.
Definition: Decl.h:3233
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2504
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
This represents &#39;#pragma omp atomic&#39; directive.
Definition: StmtOpenMP.h:2094
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:2019
unsigned getNumParams() const
Definition: TypeLoc.h:1471
Represents a pointer to an Objective C object.
Definition: Type.h:5442
helper_expr_const_range privates() const
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition: ExprCXX.h:3600
SwitchStmt - This represents a &#39;switch&#39; stmt.
Definition: Stmt.h:1007
Pointer to a block type.
Definition: Type.h:2387
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2571
Represents the body of a coroutine.
Definition: StmtCXX.h:299
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:3978
Complex values, per C99 6.2.5p11.
Definition: Type.h:2225
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:450
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2121
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:2172
This template specialization was declared or defined by an explicit specialization (C++ [temp...
Definition: Specifiers.h:153
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:203
Represents a &#39;co_await&#39; expression.
Definition: ExprCXX.h:4304
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:708
ExtVectorType - Extended vector type.
Definition: Type.h:2990
Expr * getSizeExpr() const
Definition: TypeLoc.h:1554
TypeLocClass getTypeLocClass() const
Definition: TypeLoc.h:113
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:191
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:276
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3087
GotoStmt - This represents a direct goto.
Definition: Stmt.h:1274
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1113
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition: TypeLoc.h:239
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:4033
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
QualType getParamType(unsigned i) const
Definition: Type.h:3493
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
Represents a type parameter type in Objective C.
Definition: Type.h:5112
Represents a field declaration created by an @defs(...).
Definition: DeclObjC.h:2031
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:2387
This represents &#39;#pragma omp target parallel&#39; directive.
Definition: StmtOpenMP.h:2461
This represents &#39;nowait&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:975
Represents a C++ struct/union/class.
Definition: DeclCXX.h:299
Represents a template specialization type whose template cannot be resolved, e.g. ...
Definition: Type.h:4903
ContinueStmt - This represents a continue.
Definition: Stmt.h:1351
Represents a loop initializing the elements of an array.
Definition: Expr.h:4490
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
Represents a C array with an unspecified size.
Definition: Type.h:2674
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition: Expr.h:3664
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition: Expr.h:3342
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:1471
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:1964
WhileStmt - This represents a &#39;while&#39; stmt.
Definition: Stmt.h:1098
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:654
This class is used for builtin types like &#39;int&#39;.
Definition: Type.h:2145
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:2846
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1509
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2209
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:1186
Expr * getHint() const
Returns number of threads.
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition: ExprObjC.h:82
TranslationUnitDecl - The top declaration context.
Definition: Decl.h:107
This represents &#39;#pragma omp target data&#39; directive.
Definition: StmtOpenMP.h:2286
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:956
Represents an extended address space qualifier where the input address space value is dependent...
Definition: Type.h:2834
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:4495
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
BreakStmt - This represents a break.
Definition: Stmt.h:1377
Expr * getChunkSize()
Get chunk size.
Definition: OpenMPClause.h:903
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:3835
QualType getType() const
Definition: Decl.h:639
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:1779
NamedDecl - This represents a decl with a name.
Definition: Decl.h:245
This represents &#39;#pragma omp distribute parallel for simd&#39; composite directive.
Definition: StmtOpenMP.h:3119
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:530
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Definition: Expr.h:1926
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:2719
This represents &#39;#pragma omp parallel sections&#39; directive.
Definition: StmtOpenMP.h:1640
Represents a C++ namespace alias.
Definition: DeclCXX.h:2947
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:856
bool VisitUnqualTypeLoc(UnqualTypeLoc TL)
Declaration of a friend template.
Represents C++ using-directive.
Definition: DeclCXX.h:2843
Represents a #pragma detect_mismatch line.
Definition: Decl.h:173
const Expr * getPostUpdateExpr() const
Get post-update expression for the clause.
Definition: OpenMPClause.h:151
The global specifier &#39;::&#39;. There is no stored value.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
Definition: TemplateBase.h:288
Represents Objective-C&#39;s @autoreleasepool Statement.
Definition: StmtObjC.h:345
This represents &#39;#pragma omp threadprivate ...&#39; directive.
Definition: DeclOpenMP.h:39
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
Definition: DeclObjC.h:2518
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:2620
InitListExpr * getSyntacticForm() const
Definition: Expr.h:4029
Declaration of a template function.
Definition: DeclTemplate.h:958
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:4580
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:2521
Attr - This represents one attribute.
Definition: Attr.h:43
This represents clause &#39;use_device_ptr&#39; in the &#39;#pragma omp ...&#39; directives.
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Definition: DeclCXX.h:3066
Represents a pack of using declarations that a single using-declarator pack-expanded into...
Definition: DeclCXX.h:3425
InitListExpr * getSemanticForm() const
Definition: Expr.h:4023
Defines the LambdaCapture class.
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition: DeclObjC.h:2748
#define STMT(CLASS, PARENT)
This represents &#39;#pragma omp taskloop&#39; directive.
Definition: StmtOpenMP.h:2781