LCOV - code coverage report
Current view: top level - clang/AST - RecursiveASTVisitor.h (source / functions) Hit Total Coverage
Test: clang.info Lines: 183 987 18.5 %
Date: 2016-01-31 12:01:00 Functions: 61 526 11.6 %

          Line data    Source code
       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"
      19             : #include "clang/AST/DeclCXX.h"
      20             : #include "clang/AST/DeclFriend.h"
      21             : #include "clang/AST/DeclObjC.h"
      22             : #include "clang/AST/DeclOpenMP.h"
      23          22 : #include "clang/AST/DeclTemplate.h"
      24             : #include "clang/AST/Expr.h"
      25             : #include "clang/AST/ExprCXX.h"
      26             : #include "clang/AST/ExprObjC.h"
      27           0 : #include "clang/AST/NestedNameSpecifier.h"
      28             : #include "clang/AST/Stmt.h"
      29           0 : #include "clang/AST/StmtCXX.h"
      30             : #include "clang/AST/StmtObjC.h"
      31             : #include "clang/AST/StmtOpenMP.h"
      32           7 : #include "clang/AST/TemplateBase.h"
      33           0 : #include "clang/AST/TemplateName.h"
      34             : #include "clang/AST/Type.h"
      35           0 : #include "clang/AST/TypeLoc.h"
      36             : 
      37             : // The following three macros are used for meta programming.  The code
      38             : // using them is responsible for defining macro OPERATOR().
      39             : 
      40             : // All unary operators.
      41           0 : #define UNARYOP_LIST()                                                         \
      42             :   OPERATOR(PostInc) OPERATOR(PostDec) OPERATOR(PreInc) OPERATOR(PreDec)        \
      43           0 :       OPERATOR(AddrOf) OPERATOR(Deref) OPERATOR(Plus) OPERATOR(Minus)          \
      44             :       OPERATOR(Not) OPERATOR(LNot) OPERATOR(Real) OPERATOR(Imag)               \
      45             :       OPERATOR(Extension)
      46             : 
      47           0 : // All binary operators (excluding compound assign operators).
      48             : #define BINOP_LIST()                                                           \
      49           0 :   OPERATOR(PtrMemD) OPERATOR(PtrMemI) OPERATOR(Mul) OPERATOR(Div)              \
      50             :       OPERATOR(Rem) OPERATOR(Add) OPERATOR(Sub) OPERATOR(Shl) OPERATOR(Shr)    \
      51             :       OPERATOR(LT) OPERATOR(GT) OPERATOR(LE) OPERATOR(GE) OPERATOR(EQ)         \
      52             :       OPERATOR(NE) OPERATOR(And) OPERATOR(Xor) OPERATOR(Or) OPERATOR(LAnd)     \
      53           0 :       OPERATOR(LOr) OPERATOR(Assign) OPERATOR(Comma)
      54             : 
      55           0 : // All compound assign operators.
      56             : #define CAO_LIST()                                                             \
      57             :   OPERATOR(Mul) OPERATOR(Div) OPERATOR(Rem) OPERATOR(Add) OPERATOR(Sub)        \
      58             :       OPERATOR(Shl) OPERATOR(Shr) OPERATOR(And) OPERATOR(Or) OPERATOR(Xor)
      59           0 : 
      60             : namespace clang {
      61           0 : 
      62          27 : // A helper macro to implement short-circuiting when recursing.  It
      63           0 : // invokes CALL_EXPR, which must be a method call, on the derived
      64           6 : // object (s.t. a user of RecursiveASTVisitor can override the method
      65           0 : // in CALL_EXPR).
      66             : #define TRY_TO(CALL_EXPR)                                                      \
      67           1 :   do {                                                                         \
      68           0 :     if (!getDerived().CALL_EXPR)                                               \
      69           0 :       return false;                                                            \
      70             :   } while (0)
      71           0 : 
      72           3 : /// \brief A class that does preorder depth-first traversal on the
      73           0 : /// entire Clang AST and visits each node.
      74           0 : ///
      75           0 : /// This class performs three distinct tasks:
      76           0 : ///   1. traverse the AST (i.e. go to each node);
      77           0 : ///   2. at a given node, walk up the class hierarchy, starting from
      78             : ///      the node's dynamic type, until the top-most class (e.g. Stmt,
      79          29 : ///      Decl, or Type) is reached.
      80           0 : ///   3. given a (node, class) combination, where 'class' is some base
      81           0 : ///      class of the dynamic type of 'node', call a user-overridable
      82           0 : ///      function to actually visit the node.
      83           0 : ///
      84           0 : /// These tasks are done by three groups of methods, respectively:
      85           0 : ///   1. TraverseDecl(Decl *x) does task #1.  It is the entry point
      86           0 : ///      for traversing an AST rooted at x.  This method simply
      87           0 : ///      dispatches (i.e. forwards) to TraverseFoo(Foo *x) where Foo
      88           0 : ///      is the dynamic type of *x, which calls WalkUpFromFoo(x) and
      89           0 : ///      then recursively visits the child nodes of x.
      90             : ///      TraverseStmt(Stmt *x) and TraverseType(QualType x) work
      91          19 : ///      similarly.
      92           0 : ///   2. WalkUpFromFoo(Foo *x) does task #2.  It does not try to visit
      93           0 : ///      any child node of x.  Instead, it first calls WalkUpFromBar(x)
      94           0 : ///      where Bar is the direct parent class of Foo (unless Foo has
      95           0 : ///      no parent), and then calls VisitFoo(x) (see the next list item).
      96           0 : ///   3. VisitFoo(Foo *x) does task #3.
      97           0 : ///
      98           0 : /// These three method groups are tiered (Traverse* > WalkUpFrom* >
      99           0 : /// Visit*).  A method (e.g. Traverse*) may call methods from the same
     100           0 : /// tier (e.g. other Traverse*) or one tier lower (e.g. WalkUpFrom*).
     101           0 : /// It may not call methods from a higher tier.
     102           0 : ///
     103           0 : /// Note that since WalkUpFromFoo() calls WalkUpFromBar() (where Bar
     104           0 : /// is Foo's super class) before calling VisitFoo(), the result is
     105           0 : /// that the Visit*() methods for a given node are called in the
     106           0 : /// top-down order (e.g. for a node of type NamespaceDecl, the order will
     107           0 : /// be VisitDecl(), VisitNamedDecl(), and then VisitNamespaceDecl()).
     108           0 : ///
     109           0 : /// This scheme guarantees that all Visit*() calls for the same AST
     110           0 : /// node are grouped together.  In other words, Visit*() methods for
     111           0 : /// different nodes are never interleaved.
     112           0 : ///
     113           0 : /// Clients of this visitor should subclass the visitor (providing
     114           0 : /// themselves as the template argument, using the curiously recurring
     115           0 : /// template pattern) and override any of the Traverse*, WalkUpFrom*,
     116           0 : /// and Visit* methods for declarations, types, statements,
     117           0 : /// expressions, or other AST nodes where the visitor should customize
     118           0 : /// behavior.  Most users only need to override Visit*.  Advanced
     119           0 : /// users may override Traverse* and WalkUpFrom* to implement custom
     120           0 : /// traversal strategies.  Returning false from one of these overridden
     121           0 : /// functions will abort the entire traversal.
     122           0 : ///
     123           0 : /// By default, this visitor tries to visit every part of the explicit
     124           0 : /// source code exactly once.  The default policy towards templates
     125           0 : /// is to descend into the 'pattern' class or function body, not any
     126           0 : /// explicit or implicit instantiations.  Explicit specializations
     127           0 : /// are still visited, and the patterns of partial specializations
     128           0 : /// are visited separately.  This behavior can be changed by
     129           0 : /// overriding shouldVisitTemplateInstantiations() in the derived class
     130           0 : /// to return true, in which case all known implicit and explicit
     131           0 : /// instantiations will be visited at the same time as the pattern
     132             : /// from which they were produced.
     133           0 : template <typename Derived> class RecursiveASTVisitor {
     134             : public:
     135             :   /// \brief Return a reference to the derived class.
     136        2652 :   Derived &getDerived() { return *static_cast<Derived *>(this); }
     137           0 : 
     138             :   /// \brief Return whether this visitor should recurse into
     139           0 :   /// template instantiations.
     140           0 :   bool shouldVisitTemplateInstantiations() const { return false; }
     141             : 
     142             :   /// \brief Return whether this visitor should recurse into the types of
     143             :   /// TypeLocs.
     144          66 :   bool shouldWalkTypesOfTypeLocs() const { return true; }
     145           0 : 
     146             :   /// \brief Return whether this visitor should recurse into implicit
     147           0 :   /// code, e.g., implicit constructors and destructors.
     148         133 :   bool shouldVisitImplicitCode() const { return false; }
     149             : 
     150             :   /// \brief Return whether \param S should be traversed using data recursion
     151           0 :   /// to avoid a stack overflow with extreme cases.
     152             :   bool shouldUseDataRecursionFor(Stmt *S) const {
     153         236 :     return isa<BinaryOperator>(S) || isa<UnaryOperator>(S) ||
     154         146 :            isa<CaseStmt>(S) || isa<CXXOperatorCallExpr>(S);
     155             :   }
     156             : 
     157           0 :   /// \brief Recursively visit a statement or expression, by
     158             :   /// dispatching to Traverse*() based on the argument's dynamic type.
     159             :   ///
     160             :   /// \returns false if the visitation was terminated early, true
     161           0 :   /// otherwise (including when the argument is NULL).
     162             :   bool TraverseStmt(Stmt *S);
     163           0 : 
     164             :   /// \brief Recursively visit a type, by dispatching to
     165             :   /// Traverse*Type() based on the argument's getTypeClass() property.
     166             :   ///
     167             :   /// \returns false if the visitation was terminated early, true
     168             :   /// otherwise (including when the argument is a Null type).
     169           0 :   bool TraverseType(QualType T);
     170             : 
     171           0 :   /// \brief Recursively visit a type with location, by dispatching to
     172             :   /// Traverse*TypeLoc() based on the argument type's getTypeClass() property.
     173             :   ///
     174             :   /// \returns false if the visitation was terminated early, true
     175             :   /// otherwise (including when the argument is a Null type location).
     176             :   bool TraverseTypeLoc(TypeLoc TL);
     177           0 : 
     178             :   /// \brief Recursively visit an attribute, by dispatching to
     179             :   /// Traverse*Attr() based on the argument's dynamic type.
     180             :   ///
     181             :   /// \returns false if the visitation was terminated early, true
     182             :   /// otherwise (including when the argument is a Null type location).
     183           0 :   bool TraverseAttr(Attr *At);
     184             : 
     185             :   /// \brief Recursively visit a declaration, by dispatching to
     186             :   /// Traverse*Decl() based on the argument's dynamic type.
     187             :   ///
     188             :   /// \returns false if the visitation was terminated early, true
     189           3 :   /// otherwise (including when the argument is NULL).
     190             :   bool TraverseDecl(Decl *D);
     191             : 
     192             :   /// \brief Recursively visit a C++ nested-name-specifier.
     193           0 :   ///
     194             :   /// \returns false if the visitation was terminated early, true otherwise.
     195           0 :   bool TraverseNestedNameSpecifier(NestedNameSpecifier *NNS);
     196             : 
     197             :   /// \brief Recursively visit a C++ nested-name-specifier with location
     198             :   /// information.
     199             :   ///
     200             :   /// \returns false if the visitation was terminated early, true otherwise.
     201           0 :   bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS);
     202             : 
     203           0 :   /// \brief Recursively visit a name with its location information.
     204             :   ///
     205             :   /// \returns false if the visitation was terminated early, true otherwise.
     206             :   bool TraverseDeclarationNameInfo(DeclarationNameInfo NameInfo);
     207             : 
     208             :   /// \brief Recursively visit a template name and dispatch to the
     209           0 :   /// appropriate method.
     210             :   ///
     211           0 :   /// \returns false if the visitation was terminated early, true otherwise.
     212             :   bool TraverseTemplateName(TemplateName Template);
     213             : 
     214             :   /// \brief Recursively visit a template argument and dispatch to the
     215           0 :   /// appropriate method for the argument type.
     216             :   ///
     217             :   /// \returns false if the visitation was terminated early, true otherwise.
     218             :   // FIXME: migrate callers to TemplateArgumentLoc instead.
     219             :   bool TraverseTemplateArgument(const TemplateArgument &Arg);
     220             : 
     221           0 :   /// \brief Recursively visit a template argument location and dispatch to the
     222             :   /// appropriate method for the argument type.
     223             :   ///
     224             :   /// \returns false if the visitation was terminated early, true otherwise.
     225             :   bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc);
     226             : 
     227           0 :   /// \brief Recursively visit a set of template arguments.
     228             :   /// This can be overridden by a subclass, but it's not expected that
     229           0 :   /// will be needed -- this visitor always dispatches to another.
     230             :   ///
     231             :   /// \returns false if the visitation was terminated early, true otherwise.
     232             :   // FIXME: take a TemplateArgumentLoc* (or TemplateArgumentListInfo) instead.
     233           1 :   bool TraverseTemplateArguments(const TemplateArgument *Args,
     234             :                                  unsigned NumArgs);
     235           0 : 
     236             :   /// \brief Recursively visit a constructor initializer.  This
     237             :   /// automatically dispatches to another visitor for the initializer
     238             :   /// expression, but not for the name of the initializer, so may
     239          26 :   /// be overridden for clients that need access to the name.
     240             :   ///
     241             :   /// \returns false if the visitation was terminated early, true otherwise.
     242             :   bool TraverseConstructorInitializer(CXXCtorInitializer *Init);
     243           0 : 
     244             :   /// \brief Recursively visit a lambda capture.
     245           0 :   ///
     246             :   /// \returns false if the visitation was terminated early, true otherwise.
     247           0 :   bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C);
     248             : 
     249             :   /// \brief Recursively visit the body of a lambda expression.
     250             :   ///
     251           0 :   /// This provides a hook for visitors that need more context when visiting
     252             :   /// \c LE->getBody().
     253             :   ///
     254             :   /// \returns false if the visitation was terminated early, true otherwise.
     255             :   bool TraverseLambdaBody(LambdaExpr *LE);
     256             : 
     257           0 :   // ---- Methods on Attrs ----
     258             : 
     259             :   // \brief Visit an attribute.
     260           0 :   bool VisitAttr(Attr *A) { return true; }
     261             : 
     262             : // Declare Traverse* and empty Visit* for all Attr classes.
     263           0 : #define ATTR_VISITOR_DECLS_ONLY
     264             : #include "clang/AST/AttrVisitor.inc"
     265             : #undef ATTR_VISITOR_DECLS_ONLY
     266             : 
     267             : // ---- Methods on Stmts ----
     268             : 
     269           0 : // Declare Traverse*() for all concrete Stmt classes.
     270             : #define ABSTRACT_STMT(STMT)
     271             : #define STMT(CLASS, PARENT) bool Traverse##CLASS(CLASS *S);
     272             : #include "clang/AST/StmtNodes.inc"
     273             :   // The above header #undefs ABSTRACT_STMT and STMT upon exit.
     274             : 
     275           0 :   // Define WalkUpFrom*() and empty Visit*() for all Stmt classes.
     276          72 :   bool WalkUpFromStmt(Stmt *S) { return getDerived().VisitStmt(S); }
     277          72 :   bool VisitStmt(Stmt *S) { return true; }
     278             : #define STMT(CLASS, PARENT)                                                    \
     279           0 :   bool WalkUpFrom##CLASS(CLASS *S) {                                           \
     280             :     TRY_TO(WalkUpFrom##PARENT(S));                                             \
     281           0 :     TRY_TO(Visit##CLASS(S));                                                   \
     282             :     return true;                                                               \
     283             :   }                                                                            \
     284             :   bool Visit##CLASS(CLASS *S) { return true; }
     285           0 : #include "clang/AST/StmtNodes.inc"
     286             : 
     287           0 : // Define Traverse*(), WalkUpFrom*(), and Visit*() for unary
     288             : // operator methods.  Unary operators are not classes in themselves
     289             : // (they're all opcodes in UnaryOperator) but do have visitors.
     290             : #define OPERATOR(NAME)                                                         \
     291           0 :   bool TraverseUnary##NAME(UnaryOperator *S) {                                 \
     292             :     TRY_TO(WalkUpFromUnary##NAME(S));                                          \
     293           0 :     TRY_TO(TraverseStmt(S->getSubExpr()));                                     \
     294             :     return true;                                                               \
     295             :   }                                                                            \
     296             :   bool WalkUpFromUnary##NAME(UnaryOperator *S) {                               \
     297             :     TRY_TO(WalkUpFromUnaryOperator(S));                                        \
     298             :     TRY_TO(VisitUnary##NAME(S));                                               \
     299           2 :     return true;                                                               \
     300             :   }                                                                            \
     301           0 :   bool VisitUnary##NAME(UnaryOperator *S) { return true; }
     302             : 
     303           9 :   UNARYOP_LIST()
     304             : #undef OPERATOR
     305             : 
     306             : // Define Traverse*(), WalkUpFrom*(), and Visit*() for binary
     307             : // operator methods.  Binary operators are not classes in themselves
     308             : // (they're all opcodes in BinaryOperator) but do have visitors.
     309           3 : #define GENERAL_BINOP_FALLBACK(NAME, BINOP_TYPE)                               \
     310             :   bool TraverseBin##NAME(BINOP_TYPE *S) {                                      \
     311           0 :     TRY_TO(WalkUpFromBin##NAME(S));                                            \
     312             :     TRY_TO(TraverseStmt(S->getLHS()));                                         \
     313             :     TRY_TO(TraverseStmt(S->getRHS()));                                         \
     314             :     return true;                                                               \
     315           0 :   }                                                                            \
     316             :   bool WalkUpFromBin##NAME(BINOP_TYPE *S) {                                    \
     317           0 :     TRY_TO(WalkUpFrom##BINOP_TYPE(S));                                         \
     318             :     TRY_TO(VisitBin##NAME(S));                                                 \
     319             :     return true;                                                               \
     320             :   }                                                                            \
     321           0 :   bool VisitBin##NAME(BINOP_TYPE *S) { return true; }
     322             : 
     323           0 : #define OPERATOR(NAME) GENERAL_BINOP_FALLBACK(NAME, BinaryOperator)
     324           9 :   BINOP_LIST()
     325             : #undef OPERATOR
     326             : 
     327             : // Define Traverse*(), WalkUpFrom*(), and Visit*() for compound
     328             : // assignment methods.  Compound assignment operators are not
     329             : // classes in themselves (they're all opcodes in
     330             : // CompoundAssignOperator) but do have visitors.
     331             : #define OPERATOR(NAME)                                                         \
     332             :   GENERAL_BINOP_FALLBACK(NAME##Assign, CompoundAssignOperator)
     333             : 
     334           0 :   CAO_LIST()
     335             : #undef OPERATOR
     336             : #undef GENERAL_BINOP_FALLBACK
     337          12 : 
     338             : // ---- Methods on Types ----
     339           0 : // FIXME: revamp to take TypeLoc's rather than Types.
     340             : 
     341           0 : // Declare Traverse*() for all concrete Type classes.
     342             : #define ABSTRACT_TYPE(CLASS, BASE)
     343             : #define TYPE(CLASS, BASE) bool Traverse##CLASS##Type(CLASS##Type *T);
     344             : #include "clang/AST/TypeNodes.def"
     345           0 :   // The above header #undefs ABSTRACT_TYPE and TYPE upon exit.
     346             : 
     347           0 :   // Define WalkUpFrom*() and empty Visit*() for all Type classes.
     348          66 :   bool WalkUpFromType(Type *T) { return getDerived().VisitType(T); }
     349          66 :   bool VisitType(Type *T) { return true; }
     350             : #define TYPE(CLASS, BASE)                                                      \
     351             :   bool WalkUpFrom##CLASS##Type(CLASS##Type *T) {                               \
     352             :     TRY_TO(WalkUpFrom##BASE(T));                                               \
     353             :     TRY_TO(Visit##CLASS##Type(T));                                             \
     354             :     return true;                                                               \
     355           0 :   }                                                                            \
     356             :   bool Visit##CLASS##Type(CLASS##Type *T) { return true; }
     357          16 : #include "clang/AST/TypeNodes.def"
     358             : 
     359             : // ---- Methods on TypeLocs ----
     360             : // FIXME: this currently just calls the matching Type methods
     361           8 : 
     362             : // Declare Traverse*() for all concrete TypeLoc classes.
     363             : #define ABSTRACT_TYPELOC(CLASS, BASE)
     364             : #define TYPELOC(CLASS, BASE) bool Traverse##CLASS##TypeLoc(CLASS##TypeLoc TL);
     365           8 : #include "clang/AST/TypeLocNodes.def"
     366             :   // The above header #undefs ABSTRACT_TYPELOC and TYPELOC upon exit.
     367           0 : 
     368             :   // Define WalkUpFrom*() and empty Visit*() for all TypeLoc classes.
     369          66 :   bool WalkUpFromTypeLoc(TypeLoc TL) { return getDerived().VisitTypeLoc(TL); }
     370          66 :   bool VisitTypeLoc(TypeLoc TL) { return true; }
     371           0 : 
     372             :   // QualifiedTypeLoc and UnqualTypeLoc are not declared in
     373           2 :   // TypeNodes.def and thus need to be handled specially.
     374             :   bool WalkUpFromQualifiedTypeLoc(QualifiedTypeLoc TL) {
     375             :     return getDerived().VisitUnqualTypeLoc(TL.getUnqualifiedLoc());
     376             :   }
     377           0 :   bool VisitQualifiedTypeLoc(QualifiedTypeLoc TL) { return true; }
     378             :   bool WalkUpFromUnqualTypeLoc(UnqualTypeLoc TL) {
     379             :     return getDerived().VisitUnqualTypeLoc(TL.getUnqualifiedLoc());
     380             :   }
     381             :   bool VisitUnqualTypeLoc(UnqualTypeLoc TL) { return true; }
     382             : 
     383           0 : // Note that BASE includes trailing 'Type' which CLASS doesn't.
     384             : #define TYPE(CLASS, BASE)                                                      \
     385             :   bool WalkUpFrom##CLASS##TypeLoc(CLASS##TypeLoc TL) {                         \
     386             :     TRY_TO(WalkUpFrom##BASE##Loc(TL));                                         \
     387             :     TRY_TO(Visit##CLASS##TypeLoc(TL));                                         \
     388             :     return true;                                                               \
     389             :   }                                                                            \
     390             :   bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TL) { return true; }
     391           0 : #include "clang/AST/TypeNodes.def"
     392             : 
     393          11 : // ---- Methods on Decls ----
     394             : 
     395             : // Declare Traverse*() for all concrete Decl classes.
     396             : #define ABSTRACT_DECL(DECL)
     397           0 : #define DECL(CLASS, BASE) bool Traverse##CLASS##Decl(CLASS##Decl *D);
     398             : #include "clang/AST/DeclNodes.inc"
     399             :   // The above header #undefs ABSTRACT_DECL and DECL upon exit.
     400             : 
     401             :   // Define WalkUpFrom*() and empty Visit*() for all Decl classes.
     402          69 :   bool WalkUpFromDecl(Decl *D) { return getDerived().VisitDecl(D); }
     403          87 :   bool VisitDecl(Decl *D) { return true; }
     404             : #define DECL(CLASS, BASE)                                                      \
     405             :   bool WalkUpFrom##CLASS##Decl(CLASS##Decl *D) {                               \
     406             :     TRY_TO(WalkUpFrom##BASE(D));                                               \
     407           0 :     TRY_TO(Visit##CLASS##Decl(D));                                             \
     408             :     return true;                                                               \
     409           0 :   }                                                                            \
     410             :   bool Visit##CLASS##Decl(CLASS##Decl *D) { return true; }
     411             : #include "clang/AST/DeclNodes.inc"
     412             : 
     413           4 : private:
     414             :   // These are helper methods used by more than one Traverse* method.
     415           0 :   bool TraverseTemplateParameterListHelper(TemplateParameterList *TPL);
     416             : #define DEF_TRAVERSE_TMPL_INST(TMPLDECLKIND)                                   \
     417             :   bool TraverseTemplateInstantiations(TMPLDECLKIND##TemplateDecl *D);
     418             :   DEF_TRAVERSE_TMPL_INST(Class)
     419           0 :   DEF_TRAVERSE_TMPL_INST(Var)
     420             :   DEF_TRAVERSE_TMPL_INST(Function)
     421           0 : #undef DEF_TRAVERSE_TMPL_INST
     422             :   bool TraverseTemplateArgumentLocsHelper(const TemplateArgumentLoc *TAL,
     423           0 :                                           unsigned Count);
     424             :   bool TraverseArrayTypeLocHelper(ArrayTypeLoc TL);
     425             :   bool TraverseRecordHelper(RecordDecl *D);
     426             :   bool TraverseCXXRecordHelper(CXXRecordDecl *D);
     427           9 :   bool TraverseDeclaratorHelper(DeclaratorDecl *D);
     428             :   bool TraverseDeclContextHelper(DeclContext *DC);
     429             :   bool TraverseFunctionHelper(FunctionDecl *D);
     430             :   bool TraverseVarHelper(VarDecl *D);
     431             :   bool TraverseOMPExecutableDirective(OMPExecutableDirective *S);
     432             :   bool TraverseOMPLoopDirective(OMPLoopDirective *S);
     433           0 :   bool TraverseOMPClause(OMPClause *C);
     434             : #define OPENMP_CLAUSE(Name, Class) bool Visit##Class(Class *C);
     435             : #include "clang/Basic/OpenMPKinds.def"
     436             :   /// \brief Process clauses with list of variables.
     437             :   template <typename T> bool VisitOMPClauseList(T *Node);
     438             : 
     439           0 :   struct EnqueueJob {
     440             :     Stmt *S;
     441           0 :     Stmt::child_iterator StmtIt;
     442             : 
     443           5 :     EnqueueJob(Stmt *S) : S(S), StmtIt() {}
     444             :   };
     445           0 :   bool dataTraverse(Stmt *S);
     446             :   bool dataTraverseNode(Stmt *S, bool &EnqueueChildren);
     447           0 : };
     448             : 
     449             : template <typename Derived>
     450             : bool RecursiveASTVisitor<Derived>::dataTraverse(Stmt *S) {
     451           0 : 
     452           2 :   SmallVector<EnqueueJob, 16> Queue;
     453           4 :   Queue.push_back(S);
     454             : 
     455          25 :   while (!Queue.empty()) {
     456          16 :     EnqueueJob &job = Queue.back();
     457           8 :     Stmt *CurrS = job.S;
     458           8 :     if (!CurrS) {
     459           0 :       Queue.pop_back();
     460           0 :       continue;
     461             :     }
     462             : 
     463          24 :     if (getDerived().shouldUseDataRecursionFor(CurrS)) {
     464          15 :       if (job.StmtIt == Stmt::child_iterator()) {
     465           2 :         bool EnqueueChildren = true;
     466           4 :         if (!dataTraverseNode(CurrS, EnqueueChildren))
     467           0 :           return false;
     468           2 :         if (!EnqueueChildren) {
     469           0 :           Queue.pop_back();
     470           0 :           continue;
     471             :         }
     472           4 :         job.StmtIt = CurrS->child_begin();
     473           2 :       } else {
     474           3 :         ++job.StmtIt;
     475           0 :       }
     476             : 
     477          15 :       if (job.StmtIt != CurrS->child_end())
     478          12 :         Queue.push_back(*job.StmtIt);
     479           0 :       else
     480           2 :         Queue.pop_back();
     481           5 :       continue;
     482             :     }
     483             : 
     484           3 :     Queue.pop_back();
     485          42 :     TRY_TO(TraverseStmt(CurrS));
     486             :   }
     487           0 : 
     488           2 :   return true;
     489           2 : }
     490             : 
     491             : template <typename Derived>
     492             : bool RecursiveASTVisitor<Derived>::dataTraverseNode(Stmt *S,
     493           0 :                                                     bool &EnqueueChildren) {
     494             : 
     495             : // Dispatch to the corresponding WalkUpFrom* function only if the derived
     496             : // class didn't override Traverse* (and thus the traversal is trivial).
     497             : #define DISPATCH_WALK(NAME, CLASS, VAR)                                        \
     498             :   {                                                                            \
     499           0 :     bool (Derived::*DerivedFn)(CLASS *) = &Derived::Traverse##NAME;            \
     500             :     bool (Derived::*BaseFn)(CLASS *) = &RecursiveASTVisitor::Traverse##NAME;   \
     501             :     if (DerivedFn == BaseFn)                                                   \
     502             :       return getDerived().WalkUpFrom##NAME(static_cast<CLASS *>(VAR));         \
     503             :   }                                                                            \
     504             :   EnqueueChildren = false;                                                     \
     505           0 :   return getDerived().Traverse##NAME(static_cast<CLASS *>(VAR));
     506             : 
     507           2 :   if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(S)) {
     508           1 :     switch (BinOp->getOpcode()) {
     509             : #define OPERATOR(NAME)                                                         \
     510             :   case BO_##NAME:                                                              \
     511           9 :     DISPATCH_WALK(Bin##NAME, BinaryOperator, S);
     512             : 
     513           2 :       BINOP_LIST()
     514             : #undef OPERATOR
     515             : 
     516             : #define OPERATOR(NAME)                                                         \
     517           0 :   case BO_##NAME##Assign:                                                      \
     518             :     DISPATCH_WALK(Bin##NAME##Assign, CompoundAssignOperator, S);
     519             : 
     520           0 :       CAO_LIST()
     521             : #undef OPERATOR
     522             :     }
     523           1 :   } else if (UnaryOperator *UnOp = dyn_cast<UnaryOperator>(S)) {
     524           1 :     switch (UnOp->getOpcode()) {
     525             : #define OPERATOR(NAME)                                                         \
     526             :   case UO_##NAME:                                                              \
     527             :     DISPATCH_WALK(Unary##NAME, UnaryOperator, S);
     528             : 
     529           2 :       UNARYOP_LIST()
     530             : #undef OPERATOR
     531             :     }
     532           0 :   }
     533             : 
     534             :   // Top switch stmt: dispatch to TraverseFooStmt for each concrete FooStmt.
     535           6 :   switch (S->getStmtClass()) {
     536             :   case Stmt::NoStmtClass:
     537           0 :     break;
     538             : #define ABSTRACT_STMT(STMT)
     539             : #define STMT(CLASS, PARENT)                                                    \
     540             :   case Stmt::CLASS##Class:                                                     \
     541           0 :     DISPATCH_WALK(CLASS, CLASS, S);
     542             : #include "clang/AST/StmtNodes.inc"
     543             :   }
     544             : 
     545             : #undef DISPATCH_WALK
     546             : 
     547           0 :   return true;
     548           2 : }
     549             : 
     550             : #define DISPATCH(NAME, CLASS, VAR)                                             \
     551             :   return getDerived().Traverse##NAME(static_cast<CLASS *>(VAR))
     552             : 
     553           0 : template <typename Derived>
     554             : bool RecursiveASTVisitor<Derived>::TraverseStmt(Stmt *S) {
     555          78 :   if (!S)
     556           6 :     return true;
     557             : 
     558             : #define DISPATCH_STMT(NAME, CLASS, VAR) DISPATCH(NAME, CLASS, VAR)
     559           0 : 
     560          72 :   if (getDerived().shouldUseDataRecursionFor(S))
     561           2 :     return dataTraverse(S);
     562             : 
     563             :   // If we have a binary expr, dispatch to the subcode of the binop.  A smart
     564             :   // optimizer (e.g. LLVM) will fold this comparison into the switch stmt
     565           0 :   // below.
     566          70 :   if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(S)) {
     567           0 :     switch (BinOp->getOpcode()) {
     568             : #define OPERATOR(NAME)                                                         \
     569             :   case BO_##NAME:                                                              \
     570             :     DISPATCH_STMT(Bin##NAME, BinaryOperator, S);
     571           0 : 
     572           0 :       BINOP_LIST()
     573             : #undef OPERATOR
     574             : #undef BINOP_LIST
     575             : 
     576             : #define OPERATOR(NAME)                                                         \
     577           0 :   case BO_##NAME##Assign:                                                      \
     578             :     DISPATCH_STMT(Bin##NAME##Assign, CompoundAssignOperator, S);
     579             : 
     580           0 :       CAO_LIST()
     581             : #undef OPERATOR
     582             : #undef CAO_LIST
     583           0 :     }
     584          70 :   } else if (UnaryOperator *UnOp = dyn_cast<UnaryOperator>(S)) {
     585           0 :     switch (UnOp->getOpcode()) {
     586             : #define OPERATOR(NAME)                                                         \
     587             :   case UO_##NAME:                                                              \
     588             :     DISPATCH_STMT(Unary##NAME, UnaryOperator, S);
     589           0 : 
     590           0 :       UNARYOP_LIST()
     591             : #undef OPERATOR
     592             : #undef UNARYOP_LIST
     593             :     }
     594           0 :   }
     595           0 : 
     596             :   // Top switch stmt: dispatch to TraverseFooStmt for each concrete FooStmt.
     597          70 :   switch (S->getStmtClass()) {
     598             :   case Stmt::NoStmtClass:
     599           0 :     break;
     600             : #define ABSTRACT_STMT(STMT)
     601           0 : #define STMT(CLASS, PARENT)                                                    \
     602             :   case Stmt::CLASS##Class:                                                     \
     603             :     DISPATCH_STMT(CLASS, CLASS, S);
     604             : #include "clang/AST/StmtNodes.inc"
     605             :   }
     606             : 
     607           0 :   return true;
     608          78 : }
     609             : 
     610             : #undef DISPATCH_STMT
     611             : 
     612             : template <typename Derived>
     613           0 : bool RecursiveASTVisitor<Derived>::TraverseType(QualType T) {
     614           0 :   if (T.isNull())
     615           0 :     return true;
     616             : 
     617           0 :   switch (T->getTypeClass()) {
     618             : #define ABSTRACT_TYPE(CLASS, BASE)
     619           0 : #define TYPE(CLASS, BASE)                                                      \
     620             :   case Type::CLASS:                                                            \
     621             :     DISPATCH(CLASS##Type, CLASS##Type, const_cast<Type *>(T.getTypePtr()));
     622             : #include "clang/AST/TypeNodes.def"
     623             :   }
     624             : 
     625           0 :   return true;
     626           0 : }
     627             : 
     628             : template <typename Derived>
     629             : bool RecursiveASTVisitor<Derived>::TraverseTypeLoc(TypeLoc TL) {
     630          73 :   if (TL.isNull())
     631           0 :     return true;
     632             : 
     633          73 :   switch (TL.getTypeLocClass()) {
     634             : #define ABSTRACT_TYPELOC(CLASS, BASE)
     635             : #define TYPELOC(CLASS, BASE)                                                   \
     636             :   case TypeLoc::CLASS:                                                         \
     637           0 :     return getDerived().Traverse##CLASS##TypeLoc(TL.castAs<CLASS##TypeLoc>());
     638             : #include "clang/AST/TypeLocNodes.def"
     639             :   }
     640             : 
     641           0 :   return true;
     642          73 : }
     643             : 
     644             : // Define the Traverse*Attr(Attr* A) methods
     645             : #define VISITORCLASS RecursiveASTVisitor
     646             : #include "clang/AST/AttrVisitor.inc"
     647           0 : #undef VISITORCLASS
     648             : 
     649             : template <typename Derived>
     650             : bool RecursiveASTVisitor<Derived>::TraverseDecl(Decl *D) {
     651         132 :   if (!D)
     652           0 :     return true;
     653           0 : 
     654             :   // As a syntax visitor, by default we want to ignore declarations for
     655             :   // implicit declarations (ones not typed explicitly by the user).
     656         264 :   if (!getDerived().shouldVisitImplicitCode() && D->isImplicit())
     657          63 :     return true;
     658             : 
     659         138 :   switch (D->getKind()) {
     660             : #define ABSTRACT_DECL(DECL)
     661             : #define DECL(CLASS, BASE)                                                      \
     662             :   case Decl::CLASS:                                                            \
     663           0 :     if (!getDerived().Traverse##CLASS##Decl(static_cast<CLASS##Decl *>(D)))    \
     664             :       return false;                                                            \
     665             :     break;
     666             : #include "clang/AST/DeclNodes.inc"
     667             :   }
     668             : 
     669           0 :   // Visit any attributes attached to this declaration.
     670         138 :   for (auto *I : D->attrs()) {
     671           0 :     if (!getDerived().TraverseAttr(I))
     672           0 :       return false;
     673             :   }
     674          69 :   return true;
     675         132 : }
     676             : 
     677             : #undef DISPATCH
     678             : 
     679             : template <typename Derived>
     680             : bool RecursiveASTVisitor<Derived>::TraverseNestedNameSpecifier(
     681           0 :     NestedNameSpecifier *NNS) {
     682           0 :   if (!NNS)
     683           0 :     return true;
     684             : 
     685           0 :   if (NNS->getPrefix())
     686           0 :     TRY_TO(TraverseNestedNameSpecifier(NNS->getPrefix()));
     687           0 : 
     688           0 :   switch (NNS->getKind()) {
     689             :   case NestedNameSpecifier::Identifier:
     690             :   case NestedNameSpecifier::Namespace:
     691             :   case NestedNameSpecifier::NamespaceAlias:
     692             :   case NestedNameSpecifier::Global:
     693           0 :   case NestedNameSpecifier::Super:
     694           0 :     return true;
     695             : 
     696             :   case NestedNameSpecifier::TypeSpec:
     697             :   case NestedNameSpecifier::TypeSpecWithTemplate:
     698           0 :     TRY_TO(TraverseType(QualType(NNS->getAsType(), 0)));
     699           0 :   }
     700             : 
     701           0 :   return true;
     702           0 : }
     703             : 
     704             : template <typename Derived>
     705           0 : bool RecursiveASTVisitor<Derived>::TraverseNestedNameSpecifierLoc(
     706             :     NestedNameSpecifierLoc NNS) {
     707          61 :   if (!NNS)
     708          57 :     return true;
     709             : 
     710           4 :   if (NestedNameSpecifierLoc Prefix = NNS.getPrefix())
     711           0 :     TRY_TO(TraverseNestedNameSpecifierLoc(Prefix));
     712             : 
     713           8 :   switch (NNS.getNestedNameSpecifier()->getKind()) {
     714             :   case NestedNameSpecifier::Identifier:
     715             :   case NestedNameSpecifier::Namespace:
     716             :   case NestedNameSpecifier::NamespaceAlias:
     717           0 :   case NestedNameSpecifier::Global:
     718             :   case NestedNameSpecifier::Super:
     719           0 :     return true;
     720             : 
     721             :   case NestedNameSpecifier::TypeSpec:
     722             :   case NestedNameSpecifier::TypeSpecWithTemplate:
     723          12 :     TRY_TO(TraverseTypeLoc(NNS.getTypeLoc()));
     724           4 :     break;
     725             :   }
     726             : 
     727           4 :   return true;
     728          61 : }
     729           0 : 
     730             : template <typename Derived>
     731             : bool RecursiveASTVisitor<Derived>::TraverseDeclarationNameInfo(
     732             :     DeclarationNameInfo NameInfo) {
     733          62 :   switch (NameInfo.getName().getNameKind()) {
     734             :   case DeclarationName::CXXConstructorName:
     735           0 :   case DeclarationName::CXXDestructorName:
     736             :   case DeclarationName::CXXConversionFunctionName:
     737           4 :     if (TypeSourceInfo *TSInfo = NameInfo.getNamedTypeInfo())
     738           0 :       TRY_TO(TraverseTypeLoc(TSInfo->getTypeLoc()));
     739             : 
     740           4 :     break;
     741           0 : 
     742             :   case DeclarationName::Identifier:
     743             :   case DeclarationName::ObjCZeroArgSelector:
     744             :   case DeclarationName::ObjCOneArgSelector:
     745             :   case DeclarationName::ObjCMultiArgSelector:
     746             :   case DeclarationName::CXXOperatorName:
     747           0 :   case DeclarationName::CXXLiteralOperatorName:
     748             :   case DeclarationName::CXXUsingDirective:
     749          27 :     break;
     750             :   }
     751             : 
     752          31 :   return true;
     753          31 : }
     754             : 
     755             : template <typename Derived>
     756             : bool RecursiveASTVisitor<Derived>::TraverseTemplateName(TemplateName Template) {
     757           0 :   if (DependentTemplateName *DTN = Template.getAsDependentTemplateName())
     758           0 :     TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier()));
     759           0 :   else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
     760           0 :     TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
     761             : 
     762           0 :   return true;
     763           0 : }
     764             : 
     765             : template <typename Derived>
     766             : bool RecursiveASTVisitor<Derived>::TraverseTemplateArgument(
     767             :     const TemplateArgument &Arg) {
     768           0 :   switch (Arg.getKind()) {
     769           0 :   case TemplateArgument::Null:
     770             :   case TemplateArgument::Declaration:
     771             :   case TemplateArgument::Integral:
     772             :   case TemplateArgument::NullPtr:
     773           0 :     return true;
     774             : 
     775           0 :   case TemplateArgument::Type:
     776           0 :     return getDerived().TraverseType(Arg.getAsType());
     777             : 
     778             :   case TemplateArgument::Template:
     779             :   case TemplateArgument::TemplateExpansion:
     780           0 :     return getDerived().TraverseTemplateName(
     781           0 :         Arg.getAsTemplateOrTemplatePattern());
     782             : 
     783             :   case TemplateArgument::Expression:
     784           0 :     return getDerived().TraverseStmt(Arg.getAsExpr());
     785             : 
     786             :   case TemplateArgument::Pack:
     787           0 :     return getDerived().TraverseTemplateArguments(Arg.pack_begin(),
     788           0 :                                                   Arg.pack_size());
     789             :   }
     790             : 
     791           0 :   return true;
     792           0 : }
     793           0 : 
     794             : // FIXME: no template name location?
     795             : // FIXME: no source locations for a template argument pack?
     796             : template <typename Derived>
     797             : bool RecursiveASTVisitor<Derived>::TraverseTemplateArgumentLoc(
     798             :     const TemplateArgumentLoc &ArgLoc) {
     799           0 :   const TemplateArgument &Arg = ArgLoc.getArgument();
     800             : 
     801           0 :   switch (Arg.getKind()) {
     802             :   case TemplateArgument::Null:
     803             :   case TemplateArgument::Declaration:
     804             :   case TemplateArgument::Integral:
     805             :   case TemplateArgument::NullPtr:
     806           0 :     return true;
     807             : 
     808             :   case TemplateArgument::Type: {
     809           0 :     // FIXME: how can TSI ever be NULL?
     810           0 :     if (TypeSourceInfo *TSI = ArgLoc.getTypeSourceInfo())
     811           0 :       return getDerived().TraverseTypeLoc(TSI->getTypeLoc());
     812             :     else
     813           0 :       return getDerived().TraverseType(Arg.getAsType());
     814             :   }
     815           0 : 
     816             :   case TemplateArgument::Template:
     817             :   case TemplateArgument::TemplateExpansion:
     818           0 :     if (ArgLoc.getTemplateQualifierLoc())
     819           0 :       TRY_TO(getDerived().TraverseNestedNameSpecifierLoc(
     820             :           ArgLoc.getTemplateQualifierLoc()));
     821           0 :     return getDerived().TraverseTemplateName(
     822           0 :         Arg.getAsTemplateOrTemplatePattern());
     823             : 
     824             :   case TemplateArgument::Expression:
     825           0 :     return getDerived().TraverseStmt(ArgLoc.getSourceExpression());
     826             : 
     827           0 :   case TemplateArgument::Pack:
     828           0 :     return getDerived().TraverseTemplateArguments(Arg.pack_begin(),
     829           0 :                                                   Arg.pack_size());
     830             :   }
     831             : 
     832           0 :   return true;
     833           0 : }
     834             : 
     835             : template <typename Derived>
     836             : bool RecursiveASTVisitor<Derived>::TraverseTemplateArguments(
     837             :     const TemplateArgument *Args, unsigned NumArgs) {
     838           0 :   for (unsigned I = 0; I != NumArgs; ++I) {
     839           0 :     TRY_TO(TraverseTemplateArgument(Args[I]));
     840           0 :   }
     841             : 
     842           0 :   return true;
     843           0 : }
     844             : 
     845             : template <typename Derived>
     846             : bool RecursiveASTVisitor<Derived>::TraverseConstructorInitializer(
     847             :     CXXCtorInitializer *Init) {
     848           2 :   if (TypeSourceInfo *TInfo = Init->getTypeSourceInfo())
     849           0 :     TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
     850             : 
     851           3 :   if (Init->isWritten() || getDerived().shouldVisitImplicitCode())
     852           4 :     TRY_TO(TraverseStmt(Init->getInit()));
     853           2 :   return true;
     854           2 : }
     855           0 : 
     856             : template <typename Derived>
     857             : bool
     858             : RecursiveASTVisitor<Derived>::TraverseLambdaCapture(LambdaExpr *LE,
     859             :                                                     const LambdaCapture *C) {
     860           0 :   if (LE->isInitCapture(C))
     861           0 :     TRY_TO(TraverseDecl(C->getCapturedVar()));
     862           0 :   return true;
     863           0 : }
     864             : 
     865             : template <typename Derived>
     866             : bool RecursiveASTVisitor<Derived>::TraverseLambdaBody(LambdaExpr *LE) {
     867           0 :   TRY_TO(TraverseStmt(LE->getBody()));
     868           0 :   return true;
     869           0 : }
     870             : 
     871             : // ----------------- Type traversal -----------------
     872             : 
     873           0 : // This macro makes available a variable T, the passed-in type.
     874             : #define DEF_TRAVERSE_TYPE(TYPE, CODE)                                          \
     875             :   template <typename Derived>                                                  \
     876             :   bool RecursiveASTVisitor<Derived>::Traverse##TYPE(TYPE *T) {                 \
     877             :     TRY_TO(WalkUpFrom##TYPE(T));                                               \
     878             :     { CODE; }                                                                  \
     879             :     return true;                                                               \
     880             :   }
     881             : 
     882           0 : DEF_TRAVERSE_TYPE(BuiltinType, {})
     883           0 : 
     884           0 : DEF_TRAVERSE_TYPE(ComplexType, { TRY_TO(TraverseType(T->getElementType())); })
     885             : 
     886           0 : DEF_TRAVERSE_TYPE(PointerType, { TRY_TO(TraverseType(T->getPointeeType())); })
     887             : 
     888           0 : DEF_TRAVERSE_TYPE(BlockPointerType,
     889           0 :                   { TRY_TO(TraverseType(T->getPointeeType())); })
     890             : 
     891           0 : DEF_TRAVERSE_TYPE(LValueReferenceType,
     892             :                   { TRY_TO(TraverseType(T->getPointeeType())); })
     893             : 
     894           0 : DEF_TRAVERSE_TYPE(RValueReferenceType,
     895           0 :                   { TRY_TO(TraverseType(T->getPointeeType())); })
     896             : 
     897           0 : DEF_TRAVERSE_TYPE(MemberPointerType, {
     898             :   TRY_TO(TraverseType(QualType(T->getClass(), 0)));
     899             :   TRY_TO(TraverseType(T->getPointeeType()));
     900             : })
     901           0 : 
     902           0 : DEF_TRAVERSE_TYPE(AdjustedType, { TRY_TO(TraverseType(T->getOriginalType())); })
     903             : 
     904           0 : DEF_TRAVERSE_TYPE(DecayedType, { TRY_TO(TraverseType(T->getOriginalType())); })
     905             : 
     906           0 : DEF_TRAVERSE_TYPE(ConstantArrayType,
     907           0 :                   { TRY_TO(TraverseType(T->getElementType())); })
     908             : 
     909           0 : DEF_TRAVERSE_TYPE(IncompleteArrayType,
     910             :                   { TRY_TO(TraverseType(T->getElementType())); })
     911             : 
     912           0 : DEF_TRAVERSE_TYPE(VariableArrayType, {
     913           0 :   TRY_TO(TraverseType(T->getElementType()));
     914             :   TRY_TO(TraverseStmt(T->getSizeExpr()));
     915             : })
     916             : 
     917           0 : DEF_TRAVERSE_TYPE(DependentSizedArrayType, {
     918             :   TRY_TO(TraverseType(T->getElementType()));
     919           0 :   if (T->getSizeExpr())
     920             :     TRY_TO(TraverseStmt(T->getSizeExpr()));
     921             : })
     922             : 
     923           0 : DEF_TRAVERSE_TYPE(DependentSizedExtVectorType, {
     924             :   if (T->getSizeExpr())
     925           0 :     TRY_TO(TraverseStmt(T->getSizeExpr()));
     926             :   TRY_TO(TraverseType(T->getElementType()));
     927             : })
     928             : 
     929           0 : DEF_TRAVERSE_TYPE(VectorType, { TRY_TO(TraverseType(T->getElementType())); })
     930             : 
     931           0 : DEF_TRAVERSE_TYPE(ExtVectorType, { TRY_TO(TraverseType(T->getElementType())); })
     932             : 
     933           0 : DEF_TRAVERSE_TYPE(FunctionNoProtoType,
     934             :                   { TRY_TO(TraverseType(T->getReturnType())); })
     935             : 
     936           0 : DEF_TRAVERSE_TYPE(FunctionProtoType, {
     937           0 :   TRY_TO(TraverseType(T->getReturnType()));
     938             : 
     939             :   for (const auto &A : T->param_types()) {
     940             :     TRY_TO(TraverseType(A));
     941             :   }
     942             : 
     943           0 :   for (const auto &E : T->exceptions()) {
     944             :     TRY_TO(TraverseType(E));
     945             :   }
     946             : 
     947             :   if (Expr *NE = T->getNoexceptExpr())
     948             :     TRY_TO(TraverseStmt(NE));
     949           0 : })
     950             : 
     951           0 : DEF_TRAVERSE_TYPE(UnresolvedUsingType, {})
     952           0 : DEF_TRAVERSE_TYPE(TypedefType, {})
     953             : 
     954           0 : DEF_TRAVERSE_TYPE(TypeOfExprType,
     955           0 :                   { TRY_TO(TraverseStmt(T->getUnderlyingExpr())); })
     956             : 
     957           0 : DEF_TRAVERSE_TYPE(TypeOfType, { TRY_TO(TraverseType(T->getUnderlyingType())); })
     958             : 
     959           0 : DEF_TRAVERSE_TYPE(DecltypeType,
     960             :                   { TRY_TO(TraverseStmt(T->getUnderlyingExpr())); })
     961             : 
     962           0 : DEF_TRAVERSE_TYPE(UnaryTransformType, {
     963             :   TRY_TO(TraverseType(T->getBaseType()));
     964             :   TRY_TO(TraverseType(T->getUnderlyingType()));
     965           0 : })
     966             : 
     967           0 : DEF_TRAVERSE_TYPE(AutoType, { TRY_TO(TraverseType(T->getDeducedType())); })
     968             : 
     969           0 : DEF_TRAVERSE_TYPE(RecordType, {})
     970           0 : DEF_TRAVERSE_TYPE(EnumType, {})
     971           0 : DEF_TRAVERSE_TYPE(TemplateTypeParmType, {})
     972           0 : DEF_TRAVERSE_TYPE(SubstTemplateTypeParmType, {})
     973           0 : DEF_TRAVERSE_TYPE(SubstTemplateTypeParmPackType, {})
     974             : 
     975           0 : DEF_TRAVERSE_TYPE(TemplateSpecializationType, {
     976             :   TRY_TO(TraverseTemplateName(T->getTemplateName()));
     977           0 :   TRY_TO(TraverseTemplateArguments(T->getArgs(), T->getNumArgs()));
     978             : })
     979             : 
     980           0 : DEF_TRAVERSE_TYPE(InjectedClassNameType, {})
     981             : 
     982           0 : DEF_TRAVERSE_TYPE(AttributedType,
     983           0 :                   { TRY_TO(TraverseType(T->getModifiedType())); })
     984             : 
     985           0 : DEF_TRAVERSE_TYPE(ParenType, { TRY_TO(TraverseType(T->getInnerType())); })
     986             : 
     987           0 : DEF_TRAVERSE_TYPE(ElaboratedType, {
     988             :   if (T->getQualifier()) {
     989           0 :     TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
     990             :   }
     991             :   TRY_TO(TraverseType(T->getNamedType()));
     992             : })
     993             : 
     994           0 : DEF_TRAVERSE_TYPE(DependentNameType,
     995           0 :                   { TRY_TO(TraverseNestedNameSpecifier(T->getQualifier())); })
     996             : 
     997           0 : DEF_TRAVERSE_TYPE(DependentTemplateSpecializationType, {
     998             :   TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
     999             :   TRY_TO(TraverseTemplateArguments(T->getArgs(), T->getNumArgs()));
    1000             : })
    1001           0 : 
    1002           0 : DEF_TRAVERSE_TYPE(PackExpansionType, { TRY_TO(TraverseType(T->getPattern())); })
    1003             : 
    1004           0 : DEF_TRAVERSE_TYPE(ObjCInterfaceType, {})
    1005             : 
    1006           0 : DEF_TRAVERSE_TYPE(ObjCObjectType, {
    1007           5 :   // We have to watch out here because an ObjCInterfaceType's base
    1008             :   // type is itself.
    1009             :   if (T->getBaseType().getTypePtr() != T)
    1010             :     TRY_TO(TraverseType(T->getBaseType()));
    1011             :   for (auto typeArg : T->getTypeArgsAsWritten()) {
    1012             :     TRY_TO(TraverseType(typeArg));
    1013           0 :   }
    1014             : })
    1015             : 
    1016           0 : DEF_TRAVERSE_TYPE(ObjCObjectPointerType,
    1017             :                   { TRY_TO(TraverseType(T->getPointeeType())); })
    1018             : 
    1019           0 : DEF_TRAVERSE_TYPE(AtomicType, { TRY_TO(TraverseType(T->getValueType())); })
    1020             : 
    1021             : #undef DEF_TRAVERSE_TYPE
    1022             : 
    1023             : // ----------------- TypeLoc traversal -----------------
    1024             : 
    1025           0 : // This macro makes available a variable TL, the passed-in TypeLoc.
    1026             : // If requested, it calls WalkUpFrom* for the Type in the given TypeLoc,
    1027             : // in addition to WalkUpFrom* for the TypeLoc itself, such that existing
    1028             : // clients that override the WalkUpFrom*Type() and/or Visit*Type() methods
    1029             : // continue to work.
    1030             : #define DEF_TRAVERSE_TYPELOC(TYPE, CODE)                                       \
    1031           0 :   template <typename Derived>                                                  \
    1032             :   bool RecursiveASTVisitor<Derived>::Traverse##TYPE##Loc(TYPE##Loc TL) {       \
    1033             :     if (getDerived().shouldWalkTypesOfTypeLocs())                              \
    1034             :       TRY_TO(WalkUpFrom##TYPE(const_cast<TYPE *>(TL.getTypePtr())));           \
    1035             :     TRY_TO(WalkUpFrom##TYPE##Loc(TL));                                         \
    1036             :     { CODE; }                                                                  \
    1037             :     return true;                                                               \
    1038             :   }
    1039             : 
    1040             : template <typename Derived>
    1041           0 : bool
    1042             : RecursiveASTVisitor<Derived>::TraverseQualifiedTypeLoc(QualifiedTypeLoc TL) {
    1043             :   // Move this over to the 'main' typeloc tree.  Note that this is a
    1044             :   // move -- we pretend that we were really looking at the unqualified
    1045             :   // typeloc all along -- rather than a recursion, so we don't follow
    1046             :   // the normal CRTP plan of going through
    1047           0 :   // getDerived().TraverseTypeLoc.  If we did, we'd be traversing
    1048             :   // twice for the same type (once as a QualifiedTypeLoc version of
    1049             :   // the type, once as an UnqualifiedTypeLoc version of the type),
    1050             :   // which in effect means we'd call VisitTypeLoc twice with the
    1051             :   // 'same' type.  This solves that problem, at the cost of never
    1052             :   // seeing the qualified version of the type (unless the client
    1053             :   // subclasses TraverseQualifiedTypeLoc themselves).  It's not a
    1054             :   // perfect solution.  A perfect solution probably requires making
    1055             :   // QualifiedTypeLoc a wrapper around TypeLoc -- like QualType is a
    1056             :   // wrapper around Type* -- rather than being its own class in the
    1057           0 :   // type hierarchy.
    1058           7 :   return TraverseTypeLoc(TL.getUnqualifiedLoc());
    1059             : }
    1060             : 
    1061         270 : DEF_TRAVERSE_TYPELOC(BuiltinType, {})
    1062             : 
    1063           0 : // FIXME: ComplexTypeLoc is unfinished
    1064           0 : DEF_TRAVERSE_TYPELOC(ComplexType, {
    1065             :   TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
    1066             : })
    1067             : 
    1068          78 : DEF_TRAVERSE_TYPELOC(PointerType,
    1069             :                      { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
    1070             : 
    1071           0 : DEF_TRAVERSE_TYPELOC(BlockPointerType,
    1072             :                      { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
    1073             : 
    1074          13 : DEF_TRAVERSE_TYPELOC(LValueReferenceType,
    1075             :                      { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
    1076             : 
    1077           0 : DEF_TRAVERSE_TYPELOC(RValueReferenceType,
    1078             :                      { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
    1079             : 
    1080             : // FIXME: location of base class?
    1081             : // We traverse this in the type case as well, but how is it not reached through
    1082             : // the pointee type?
    1083           0 : DEF_TRAVERSE_TYPELOC(MemberPointerType, {
    1084             :   TRY_TO(TraverseType(QualType(TL.getTypePtr()->getClass(), 0)));
    1085             :   TRY_TO(TraverseTypeLoc(TL.getPointeeLoc()));
    1086             : })
    1087             : 
    1088           0 : DEF_TRAVERSE_TYPELOC(AdjustedType,
    1089             :                      { TRY_TO(TraverseTypeLoc(TL.getOriginalLoc())); })
    1090             : 
    1091           0 : DEF_TRAVERSE_TYPELOC(DecayedType,
    1092             :                      { TRY_TO(TraverseTypeLoc(TL.getOriginalLoc())); })
    1093             : 
    1094             : template <typename Derived>
    1095             : bool RecursiveASTVisitor<Derived>::TraverseArrayTypeLocHelper(ArrayTypeLoc TL) {
    1096             :   // This isn't available for ArrayType, but is for the ArrayTypeLoc.
    1097           9 :   TRY_TO(TraverseStmt(TL.getSizeExpr()));
    1098           3 :   return true;
    1099           3 : }
    1100             : 
    1101           0 : DEF_TRAVERSE_TYPELOC(ConstantArrayType, {
    1102             :   TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
    1103             :   return TraverseArrayTypeLocHelper(TL);
    1104             : })
    1105             : 
    1106          39 : DEF_TRAVERSE_TYPELOC(IncompleteArrayType, {
    1107             :   TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
    1108             :   return TraverseArrayTypeLocHelper(TL);
    1109             : })
    1110             : 
    1111           0 : DEF_TRAVERSE_TYPELOC(VariableArrayType, {
    1112             :   TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
    1113             :   return TraverseArrayTypeLocHelper(TL);
    1114             : })
    1115             : 
    1116           0 : DEF_TRAVERSE_TYPELOC(DependentSizedArrayType, {
    1117             :   TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
    1118             :   return TraverseArrayTypeLocHelper(TL);
    1119             : })
    1120             : 
    1121             : // FIXME: order? why not size expr first?
    1122             : // FIXME: base VectorTypeLoc is unfinished
    1123           0 : DEF_TRAVERSE_TYPELOC(DependentSizedExtVectorType, {
    1124             :   if (TL.getTypePtr()->getSizeExpr())
    1125             :     TRY_TO(TraverseStmt(TL.getTypePtr()->getSizeExpr()));
    1126             :   TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
    1127             : })
    1128             : 
    1129             : // FIXME: VectorTypeLoc is unfinished
    1130           0 : DEF_TRAVERSE_TYPELOC(VectorType, {
    1131             :   TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
    1132             : })
    1133             : 
    1134             : // FIXME: size and attributes
    1135             : // FIXME: base VectorTypeLoc is unfinished
    1136           0 : DEF_TRAVERSE_TYPELOC(ExtVectorType, {
    1137             :   TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
    1138             : })
    1139             : 
    1140           0 : DEF_TRAVERSE_TYPELOC(FunctionNoProtoType,
    1141             :                      { TRY_TO(TraverseTypeLoc(TL.getReturnLoc())); })
    1142             : 
    1143             : // FIXME: location of exception specifications (attributes?)
    1144         304 : DEF_TRAVERSE_TYPELOC(FunctionProtoType, {
    1145             :   TRY_TO(TraverseTypeLoc(TL.getReturnLoc()));
    1146             : 
    1147             :   const FunctionProtoType *T = TL.getTypePtr();
    1148             : 
    1149             :   for (unsigned I = 0, E = TL.getNumParams(); I != E; ++I) {
    1150             :     if (TL.getParam(I)) {
    1151             :       TRY_TO(TraverseDecl(TL.getParam(I)));
    1152             :     } else if (I < T->getNumParams()) {
    1153             :       TRY_TO(TraverseType(T->getParamType(I)));
    1154             :     }
    1155             :   }
    1156             : 
    1157             :   for (const auto &E : T->exceptions()) {
    1158             :     TRY_TO(TraverseType(E));
    1159             :   }
    1160             : 
    1161             :   if (Expr *NE = T->getNoexceptExpr())
    1162             :     TRY_TO(TraverseStmt(NE));
    1163             : })
    1164             : 
    1165           0 : DEF_TRAVERSE_TYPELOC(UnresolvedUsingType, {})
    1166           0 : DEF_TRAVERSE_TYPELOC(TypedefType, {})
    1167             : 
    1168           0 : DEF_TRAVERSE_TYPELOC(TypeOfExprType,
    1169             :                      { TRY_TO(TraverseStmt(TL.getUnderlyingExpr())); })
    1170             : 
    1171           0 : DEF_TRAVERSE_TYPELOC(TypeOfType, {
    1172             :   TRY_TO(TraverseTypeLoc(TL.getUnderlyingTInfo()->getTypeLoc()));
    1173             : })
    1174             : 
    1175             : // FIXME: location of underlying expr
    1176           0 : DEF_TRAVERSE_TYPELOC(DecltypeType, {
    1177             :   TRY_TO(TraverseStmt(TL.getTypePtr()->getUnderlyingExpr()));
    1178             : })
    1179             : 
    1180           0 : DEF_TRAVERSE_TYPELOC(UnaryTransformType, {
    1181             :   TRY_TO(TraverseTypeLoc(TL.getUnderlyingTInfo()->getTypeLoc()));
    1182             : })
    1183             : 
    1184           0 : DEF_TRAVERSE_TYPELOC(AutoType, {
    1185             :   TRY_TO(TraverseType(TL.getTypePtr()->getDeducedType()));
    1186             : })
    1187             : 
    1188         130 : DEF_TRAVERSE_TYPELOC(RecordType, {})
    1189           0 : DEF_TRAVERSE_TYPELOC(EnumType, {})
    1190           0 : DEF_TRAVERSE_TYPELOC(TemplateTypeParmType, {})
    1191           0 : DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmType, {})
    1192           0 : DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmPackType, {})
    1193             : 
    1194             : // FIXME: use the loc for the template name?
    1195           0 : DEF_TRAVERSE_TYPELOC(TemplateSpecializationType, {
    1196             :   TRY_TO(TraverseTemplateName(TL.getTypePtr()->getTemplateName()));
    1197             :   for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) {
    1198             :     TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(I)));
    1199             :   }
    1200             : })
    1201             : 
    1202           0 : DEF_TRAVERSE_TYPELOC(InjectedClassNameType, {})
    1203             : 
    1204           0 : DEF_TRAVERSE_TYPELOC(ParenType, { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
    1205             : 
    1206           0 : DEF_TRAVERSE_TYPELOC(AttributedType,
    1207             :                      { TRY_TO(TraverseTypeLoc(TL.getModifiedLoc())); })
    1208             : 
    1209           0 : DEF_TRAVERSE_TYPELOC(ElaboratedType, {
    1210             :   if (TL.getQualifierLoc()) {
    1211             :     TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
    1212             :   }
    1213             :   TRY_TO(TraverseTypeLoc(TL.getNamedTypeLoc()));
    1214             : })
    1215             : 
    1216           0 : DEF_TRAVERSE_TYPELOC(DependentNameType, {
    1217             :   TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
    1218             : })
    1219             : 
    1220           0 : DEF_TRAVERSE_TYPELOC(DependentTemplateSpecializationType, {
    1221             :   if (TL.getQualifierLoc()) {
    1222             :     TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
    1223             :   }
    1224             : 
    1225             :   for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) {
    1226             :     TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(I)));
    1227             :   }
    1228             : })
    1229             : 
    1230           0 : DEF_TRAVERSE_TYPELOC(PackExpansionType,
    1231             :                      { TRY_TO(TraverseTypeLoc(TL.getPatternLoc())); })
    1232             : 
    1233           0 : DEF_TRAVERSE_TYPELOC(ObjCInterfaceType, {})
    1234             : 
    1235           0 : DEF_TRAVERSE_TYPELOC(ObjCObjectType, {
    1236             :   // We have to watch out here because an ObjCInterfaceType's base
    1237             :   // type is itself.
    1238             :   if (TL.getTypePtr()->getBaseType().getTypePtr() != TL.getTypePtr())
    1239             :     TRY_TO(TraverseTypeLoc(TL.getBaseLoc()));
    1240             :   for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
    1241             :     TRY_TO(TraverseTypeLoc(TL.getTypeArgTInfo(i)->getTypeLoc()));
    1242             : })
    1243             : 
    1244           0 : DEF_TRAVERSE_TYPELOC(ObjCObjectPointerType,
    1245             :                      { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
    1246             : 
    1247           0 : DEF_TRAVERSE_TYPELOC(AtomicType, { TRY_TO(TraverseTypeLoc(TL.getValueLoc())); })
    1248             : 
    1249             : #undef DEF_TRAVERSE_TYPELOC
    1250             : 
    1251             : // ----------------- Decl traversal -----------------
    1252             : //
    1253             : // For a Decl, we automate (in the DEF_TRAVERSE_DECL macro) traversing
    1254             : // the children that come from the DeclContext associated with it.
    1255             : // Therefore each Traverse* only needs to worry about children other
    1256             : // than those.
    1257             : 
    1258             : template <typename Derived>
    1259             : bool RecursiveASTVisitor<Derived>::TraverseDeclContextHelper(DeclContext *DC) {
    1260          53 :   if (!DC)
    1261          28 :     return true;
    1262             : 
    1263         498 :   for (auto *Child : DC->decls()) {
    1264             :     // BlockDecls and CapturedDecls are traversed through BlockExprs and
    1265             :     // CapturedStmts respectively.
    1266         224 :     if (!isa<BlockDecl>(Child) && !isa<CapturedDecl>(Child))
    1267         448 :       TRY_TO(TraverseDecl(Child));
    1268             :   }
    1269             : 
    1270          25 :   return true;
    1271          53 : }
    1272             : 
    1273             : // This macro makes available a variable D, the passed-in decl.
    1274             : #define DEF_TRAVERSE_DECL(DECL, CODE)                                          \
    1275             :   template <typename Derived>                                                  \
    1276             :   bool RecursiveASTVisitor<Derived>::Traverse##DECL(DECL *D) {                 \
    1277             :     TRY_TO(WalkUpFrom##DECL(D));                                               \
    1278             :     { CODE; }                                                                  \
    1279             :     TRY_TO(TraverseDeclContextHelper(dyn_cast<DeclContext>(D)));               \
    1280             :     return true;                                                               \
    1281             :   }
    1282             : 
    1283          88 : DEF_TRAVERSE_DECL(AccessSpecDecl, {})
    1284             : 
    1285           0 : DEF_TRAVERSE_DECL(BlockDecl, {
    1286             :   if (TypeSourceInfo *TInfo = D->getSignatureAsWritten())
    1287             :     TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
    1288             :   TRY_TO(TraverseStmt(D->getBody()));
    1289             :   for (const auto &I : D->captures()) {
    1290             :     if (I.hasCopyExpr()) {
    1291             :       TRY_TO(TraverseStmt(I.getCopyExpr()));
    1292             :     }
    1293             :   }
    1294             :   // This return statement makes sure the traversal of nodes in
    1295             :   // decls_begin()/decls_end() (done in the DEF_TRAVERSE_DECL macro)
    1296             :   // is skipped - don't remove it.
    1297             :   return true;
    1298             : })
    1299             : 
    1300           0 : DEF_TRAVERSE_DECL(CapturedDecl, {
    1301             :   TRY_TO(TraverseStmt(D->getBody()));
    1302             :   // This return statement makes sure the traversal of nodes in
    1303             :   // decls_begin()/decls_end() (done in the DEF_TRAVERSE_DECL macro)
    1304             :   // is skipped - don't remove it.
    1305             :   return true;
    1306             : })
    1307             : 
    1308           0 : DEF_TRAVERSE_DECL(EmptyDecl, {})
    1309             : 
    1310           0 : DEF_TRAVERSE_DECL(FileScopeAsmDecl,
    1311             :                   { TRY_TO(TraverseStmt(D->getAsmString())); })
    1312             : 
    1313           0 : DEF_TRAVERSE_DECL(ImportDecl, {})
    1314             : 
    1315           0 : DEF_TRAVERSE_DECL(FriendDecl, {
    1316             :   // Friend is either decl or a type.
    1317             :   if (D->getFriendType())
    1318             :     TRY_TO(TraverseTypeLoc(D->getFriendType()->getTypeLoc()));
    1319             :   else
    1320             :     TRY_TO(TraverseDecl(D->getFriendDecl()));
    1321             : })
    1322             : 
    1323           0 : DEF_TRAVERSE_DECL(FriendTemplateDecl, {
    1324             :   if (D->getFriendType())
    1325             :     TRY_TO(TraverseTypeLoc(D->getFriendType()->getTypeLoc()));
    1326             :   else
    1327             :     TRY_TO(TraverseDecl(D->getFriendDecl()));
    1328             :   for (unsigned I = 0, E = D->getNumTemplateParameters(); I < E; ++I) {
    1329             :     TemplateParameterList *TPL = D->getTemplateParameterList(I);
    1330             :     for (TemplateParameterList::iterator ITPL = TPL->begin(), ETPL = TPL->end();
    1331             :          ITPL != ETPL; ++ITPL) {
    1332             :       TRY_TO(TraverseDecl(*ITPL));
    1333             :     }
    1334             :   }
    1335             : })
    1336             : 
    1337           0 : DEF_TRAVERSE_DECL(ClassScopeFunctionSpecializationDecl, {
    1338             :   TRY_TO(TraverseDecl(D->getSpecialization()));
    1339             : 
    1340             :   if (D->hasExplicitTemplateArgs()) {
    1341             :     const TemplateArgumentListInfo &args = D->templateArgs();
    1342             :     TRY_TO(TraverseTemplateArgumentLocsHelper(args.getArgumentArray(),
    1343             :                                               args.size()));
    1344             :   }
    1345             : })
    1346             : 
    1347           0 : DEF_TRAVERSE_DECL(LinkageSpecDecl, {})
    1348             : 
    1349           0 : DEF_TRAVERSE_DECL(ObjCPropertyImplDecl, {// FIXME: implement this
    1350             :                                         })
    1351             : 
    1352           0 : DEF_TRAVERSE_DECL(StaticAssertDecl, {
    1353             :   TRY_TO(TraverseStmt(D->getAssertExpr()));
    1354             :   TRY_TO(TraverseStmt(D->getMessage()));
    1355             : })
    1356             : 
    1357          96 : DEF_TRAVERSE_DECL(
    1358             :     TranslationUnitDecl,
    1359             :     {// Code in an unnamed namespace shows up automatically in
    1360             :      // decls_begin()/decls_end().  Thus we don't need to recurse on
    1361             :      // D->getAnonymousNamespace().
    1362             :     })
    1363             : 
    1364           0 : DEF_TRAVERSE_DECL(ExternCContextDecl, {})
    1365             : 
    1366           0 : DEF_TRAVERSE_DECL(NamespaceAliasDecl, {
    1367             :   // We shouldn't traverse an aliased namespace, since it will be
    1368             :   // defined (and, therefore, traversed) somewhere else.
    1369             :   //
    1370             :   // This return statement makes sure the traversal of nodes in
    1371             :   // decls_begin()/decls_end() (done in the DEF_TRAVERSE_DECL macro)
    1372             :   // is skipped - don't remove it.
    1373             :   return true;
    1374             : })
    1375             : 
    1376           0 : DEF_TRAVERSE_DECL(LabelDecl, {// There is no code in a LabelDecl.
    1377             :                              })
    1378             : 
    1379           0 : DEF_TRAVERSE_DECL(
    1380             :     NamespaceDecl,
    1381             :     {// Code in an unnamed namespace shows up automatically in
    1382             :      // decls_begin()/decls_end().  Thus we don't need to recurse on
    1383             :      // D->getAnonymousNamespace().
    1384             :     })
    1385             : 
    1386           0 : DEF_TRAVERSE_DECL(ObjCCompatibleAliasDecl, {// FIXME: implement
    1387             :                                            })
    1388             : 
    1389           0 : DEF_TRAVERSE_DECL(ObjCCategoryDecl, {// FIXME: implement
    1390             :   if (ObjCTypeParamList *typeParamList = D->getTypeParamList()) {
    1391             :     for (auto typeParam : *typeParamList) {
    1392             :       TRY_TO(TraverseObjCTypeParamDecl(typeParam));
    1393             :     }
    1394             :   }
    1395             : })
    1396             : 
    1397           0 : DEF_TRAVERSE_DECL(ObjCCategoryImplDecl, {// FIXME: implement
    1398             :                                         })
    1399             : 
    1400           0 : DEF_TRAVERSE_DECL(ObjCImplementationDecl, {// FIXME: implement
    1401             :                                           })
    1402             : 
    1403           0 : DEF_TRAVERSE_DECL(ObjCInterfaceDecl, {// FIXME: implement
    1404             :   if (ObjCTypeParamList *typeParamList = D->getTypeParamListAsWritten()) {
    1405             :     for (auto typeParam : *typeParamList) {
    1406             :       TRY_TO(TraverseObjCTypeParamDecl(typeParam));
    1407             :     }
    1408             :   }
    1409             : 
    1410             :   if (TypeSourceInfo *superTInfo = D->getSuperClassTInfo()) {
    1411             :     TRY_TO(TraverseTypeLoc(superTInfo->getTypeLoc()));
    1412             :   }
    1413             : })
    1414             : 
    1415           0 : DEF_TRAVERSE_DECL(ObjCProtocolDecl, {// FIXME: implement
    1416             :                                     })
    1417             : 
    1418           0 : DEF_TRAVERSE_DECL(ObjCMethodDecl, {
    1419             :   if (D->getReturnTypeSourceInfo()) {
    1420             :     TRY_TO(TraverseTypeLoc(D->getReturnTypeSourceInfo()->getTypeLoc()));
    1421             :   }
    1422             :   for (ObjCMethodDecl::param_iterator I = D->param_begin(), E = D->param_end();
    1423             :        I != E; ++I) {
    1424             :     TRY_TO(TraverseDecl(*I));
    1425             :   }
    1426             :   if (D->isThisDeclarationADefinition()) {
    1427             :     TRY_TO(TraverseStmt(D->getBody()));
    1428             :   }
    1429             :   return true;
    1430             : })
    1431             : 
    1432           0 : DEF_TRAVERSE_DECL(ObjCTypeParamDecl, {
    1433             :   if (D->hasExplicitBound()) {
    1434             :     TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
    1435             :     // We shouldn't traverse D->getTypeForDecl(); it's a result of
    1436             :     // declaring the type alias, not something that was written in the
    1437             :     // source.
    1438             :   }
    1439             : })
    1440             : 
    1441           0 : DEF_TRAVERSE_DECL(ObjCPropertyDecl, {
    1442             :   if (D->getTypeSourceInfo())
    1443             :     TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
    1444             :   else
    1445             :     TRY_TO(TraverseType(D->getType()));
    1446             :   return true;
    1447             : })
    1448             : 
    1449           0 : DEF_TRAVERSE_DECL(UsingDecl, {
    1450             :   TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
    1451             :   TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
    1452             : })
    1453             : 
    1454           0 : DEF_TRAVERSE_DECL(UsingDirectiveDecl, {
    1455             :   TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
    1456             : })
    1457             : 
    1458           0 : DEF_TRAVERSE_DECL(UsingShadowDecl, {})
    1459             : 
    1460           0 : DEF_TRAVERSE_DECL(OMPThreadPrivateDecl, {
    1461             :   for (auto *I : D->varlists()) {
    1462             :     TRY_TO(TraverseStmt(I));
    1463             :   }
    1464             : })
    1465             : 
    1466             : // A helper method for TemplateDecl's children.
    1467             : template <typename Derived>
    1468             : bool RecursiveASTVisitor<Derived>::TraverseTemplateParameterListHelper(
    1469             :     TemplateParameterList *TPL) {
    1470           0 :   if (TPL) {
    1471           0 :     for (TemplateParameterList::iterator I = TPL->begin(), E = TPL->end();
    1472           0 :          I != E; ++I) {
    1473           0 :       TRY_TO(TraverseDecl(*I));
    1474           0 :     }
    1475           0 :   }
    1476           0 :   return true;
    1477           0 : }
    1478             : 
    1479             : template <typename Derived>
    1480             : bool RecursiveASTVisitor<Derived>::TraverseTemplateInstantiations(
    1481             :     ClassTemplateDecl *D) {
    1482           0 :   for (auto *SD : D->specializations()) {
    1483           0 :     for (auto *RD : SD->redecls()) {
    1484             :       // We don't want to visit injected-class-names in this traversal.
    1485           0 :       if (cast<CXXRecordDecl>(RD)->isInjectedClassName())
    1486           0 :         continue;
    1487             : 
    1488           0 :       switch (
    1489           0 :           cast<ClassTemplateSpecializationDecl>(RD)->getSpecializationKind()) {
    1490             :       // Visit the implicit instantiations with the requested pattern.
    1491             :       case TSK_Undeclared:
    1492             :       case TSK_ImplicitInstantiation:
    1493           0 :         TRY_TO(TraverseDecl(RD));
    1494           0 :         break;
    1495             : 
    1496             :       // We don't need to do anything on an explicit instantiation
    1497             :       // or explicit specialization because there will be an explicit
    1498             :       // node for it elsewhere.
    1499             :       case TSK_ExplicitInstantiationDeclaration:
    1500             :       case TSK_ExplicitInstantiationDefinition:
    1501             :       case TSK_ExplicitSpecialization:
    1502           0 :         break;
    1503             :       }
    1504             :     }
    1505             :   }
    1506             : 
    1507           0 :   return true;
    1508           0 : }
    1509             : 
    1510             : template <typename Derived>
    1511             : bool RecursiveASTVisitor<Derived>::TraverseTemplateInstantiations(
    1512             :     VarTemplateDecl *D) {
    1513           0 :   for (auto *SD : D->specializations()) {
    1514           0 :     for (auto *RD : SD->redecls()) {
    1515           0 :       switch (
    1516           0 :           cast<VarTemplateSpecializationDecl>(RD)->getSpecializationKind()) {
    1517             :       case TSK_Undeclared:
    1518             :       case TSK_ImplicitInstantiation:
    1519           0 :         TRY_TO(TraverseDecl(RD));
    1520           0 :         break;
    1521             : 
    1522             :       case TSK_ExplicitInstantiationDeclaration:
    1523             :       case TSK_ExplicitInstantiationDefinition:
    1524             :       case TSK_ExplicitSpecialization:
    1525           0 :         break;
    1526             :       }
    1527             :     }
    1528             :   }
    1529             : 
    1530           0 :   return true;
    1531           0 : }
    1532             : 
    1533             : // A helper method for traversing the instantiations of a
    1534             : // function while skipping its specializations.
    1535             : template <typename Derived>
    1536             : bool RecursiveASTVisitor<Derived>::TraverseTemplateInstantiations(
    1537             :     FunctionTemplateDecl *D) {
    1538           0 :   for (auto *FD : D->specializations()) {
    1539           0 :     for (auto *RD : FD->redecls()) {
    1540           0 :       switch (RD->getTemplateSpecializationKind()) {
    1541             :       case TSK_Undeclared:
    1542             :       case TSK_ImplicitInstantiation:
    1543             :         // We don't know what kind of FunctionDecl this is.
    1544           0 :         TRY_TO(TraverseDecl(RD));
    1545           0 :         break;
    1546             : 
    1547             :       // FIXME: For now traverse explicit instantiations here. Change that
    1548             :       // once they are represented as dedicated nodes in the AST.
    1549             :       case TSK_ExplicitInstantiationDeclaration:
    1550             :       case TSK_ExplicitInstantiationDefinition:
    1551           0 :         TRY_TO(TraverseDecl(RD));
    1552           0 :         break;
    1553             : 
    1554             :       case TSK_ExplicitSpecialization:
    1555           0 :         break;
    1556             :       }
    1557             :     }
    1558             :   }
    1559             : 
    1560           0 :   return true;
    1561           0 : }
    1562             : 
    1563             : // This macro unifies the traversal of class, variable and function
    1564             : // template declarations.
    1565             : #define DEF_TRAVERSE_TMPL_DECL(TMPLDECLKIND)                                   \
    1566             :   DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateDecl, {                              \
    1567             :     TRY_TO(TraverseDecl(D->getTemplatedDecl()));                               \
    1568             :     TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));   \
    1569             :                                                                                \
    1570             :     /* By default, we do not traverse the instantiations of                    \
    1571             :        class templates since they do not appear in the user code. The          \
    1572             :        following code optionally traverses them.                               \
    1573             :                                                                                \
    1574             :        We only traverse the class instantiations when we see the canonical     \
    1575             :        declaration of the template, to ensure we only visit them once. */      \
    1576             :     if (getDerived().shouldVisitTemplateInstantiations() &&                    \
    1577             :         D == D->getCanonicalDecl())                                            \
    1578             :       TRY_TO(TraverseTemplateInstantiations(D));                               \
    1579             :                                                                                \
    1580             :     /* Note that getInstantiatedFromMemberTemplate() is just a link            \
    1581             :        from a template instantiation back to the template from which           \
    1582             :        it was instantiated, and thus should not be traversed. */               \
    1583             :   })
    1584             : 
    1585           0 : DEF_TRAVERSE_TMPL_DECL(Class)
    1586           0 : DEF_TRAVERSE_TMPL_DECL(Var)
    1587           0 : DEF_TRAVERSE_TMPL_DECL(Function)
    1588             : 
    1589           0 : DEF_TRAVERSE_DECL(TemplateTemplateParmDecl, {
    1590             :   // D is the "T" in something like
    1591             :   //   template <template <typename> class T> class container { };
    1592             :   TRY_TO(TraverseDecl(D->getTemplatedDecl()));
    1593             :   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) {
    1594             :     TRY_TO(TraverseTemplateArgumentLoc(D->getDefaultArgument()));
    1595             :   }
    1596             :   TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
    1597             : })
    1598             : 
    1599           0 : DEF_TRAVERSE_DECL(TemplateTypeParmDecl, {
    1600             :   // D is the "T" in something like "template<typename T> class vector;"
    1601             :   if (D->getTypeForDecl())
    1602             :     TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
    1603             :   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
    1604             :     TRY_TO(TraverseTypeLoc(D->getDefaultArgumentInfo()->getTypeLoc()));
    1605             : })
    1606             : 
    1607           0 : DEF_TRAVERSE_DECL(TypedefDecl, {
    1608             :   TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
    1609             :   // We shouldn't traverse D->getTypeForDecl(); it's a result of
    1610             :   // declaring the typedef, not something that was written in the
    1611             :   // source.
    1612             : })
    1613             : 
    1614           0 : DEF_TRAVERSE_DECL(TypeAliasDecl, {
    1615             :   TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
    1616             :   // We shouldn't traverse D->getTypeForDecl(); it's a result of
    1617             :   // declaring the type alias, not something that was written in the
    1618             :   // source.
    1619             : })
    1620             : 
    1621           0 : DEF_TRAVERSE_DECL(TypeAliasTemplateDecl, {
    1622             :   TRY_TO(TraverseDecl(D->getTemplatedDecl()));
    1623             :   TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
    1624             : })
    1625             : 
    1626           0 : DEF_TRAVERSE_DECL(UnresolvedUsingTypenameDecl, {
    1627             :   // A dependent using declaration which was marked with 'typename'.
    1628             :   //   template<class T> class A : public B<T> { using typename B<T>::foo; };
    1629             :   TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
    1630             :   // We shouldn't traverse D->getTypeForDecl(); it's a result of
    1631             :   // declaring the type, not something that was written in the
    1632             :   // source.
    1633             : })
    1634             : 
    1635           0 : DEF_TRAVERSE_DECL(EnumDecl, {
    1636             :   if (D->getTypeForDecl())
    1637             :     TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
    1638             : 
    1639             :   TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
    1640             :   // The enumerators are already traversed by
    1641             :   // decls_begin()/decls_end().
    1642             : })
    1643             : 
    1644             : // Helper methods for RecordDecl and its children.
    1645             : template <typename Derived>
    1646             : bool RecursiveASTVisitor<Derived>::TraverseRecordHelper(RecordDecl *D) {
    1647             :   // We shouldn't traverse D->getTypeForDecl(); it's a result of
    1648             :   // declaring the type, not something that was written in the source.
    1649             : 
    1650          39 :   TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
    1651          13 :   return true;
    1652          13 : }
    1653             : 
    1654             : template <typename Derived>
    1655             : bool RecursiveASTVisitor<Derived>::TraverseCXXRecordHelper(CXXRecordDecl *D) {
    1656          13 :   if (!TraverseRecordHelper(D))
    1657           0 :     return false;
    1658          13 :   if (D->isCompleteDefinition()) {
    1659          26 :     for (const auto &I : D->bases()) {
    1660           0 :       TRY_TO(TraverseTypeLoc(I.getTypeSourceInfo()->getTypeLoc()));
    1661             :     }
    1662             :     // We don't traverse the friends or the conversions, as they are
    1663             :     // already in decls_begin()/decls_end().
    1664          13 :   }
    1665          13 :   return true;
    1666          13 : }
    1667             : 
    1668           0 : DEF_TRAVERSE_DECL(RecordDecl, { TRY_TO(TraverseRecordHelper(D)); })
    1669             : 
    1670         143 : DEF_TRAVERSE_DECL(CXXRecordDecl, { TRY_TO(TraverseCXXRecordHelper(D)); })
    1671             : 
    1672             : #define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND)                              \
    1673             :   DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateSpecializationDecl, {                \
    1674             :     /* For implicit instantiations ("set<int> x;"), we don't want to           \
    1675             :        recurse at all, since the instatiated template isn't written in         \
    1676             :        the source code anywhere.  (Note the instatiated *type* --              \
    1677             :        set<int> -- is written, and will still get a callback of                \
    1678             :        TemplateSpecializationType).  For explicit instantiations               \
    1679             :        ("template set<int>;"), we do need a callback, since this               \
    1680             :        is the only callback that's made for this instantiation.                \
    1681             :        We use getTypeAsWritten() to distinguish. */                            \
    1682             :     if (TypeSourceInfo *TSI = D->getTypeAsWritten())                           \
    1683             :       TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));                              \
    1684             :                                                                                \
    1685             :     if (!getDerived().shouldVisitTemplateInstantiations() &&                   \
    1686             :         D->getTemplateSpecializationKind() != TSK_ExplicitSpecialization)      \
    1687             :       /* Returning from here skips traversing the                              \
    1688             :          declaration context of the *TemplateSpecializationDecl                \
    1689             :          (embedded in the DEF_TRAVERSE_DECL() macro)                           \
    1690             :          which contains the instantiated members of the template. */           \
    1691             :       return true;                                                             \
    1692             :   })
    1693             : 
    1694           0 : DEF_TRAVERSE_TMPL_SPEC_DECL(Class)
    1695           0 : DEF_TRAVERSE_TMPL_SPEC_DECL(Var)
    1696             : 
    1697             : template <typename Derived>
    1698             : bool RecursiveASTVisitor<Derived>::TraverseTemplateArgumentLocsHelper(
    1699             :     const TemplateArgumentLoc *TAL, unsigned Count) {
    1700          30 :   for (unsigned I = 0; I < Count; ++I) {
    1701           0 :     TRY_TO(TraverseTemplateArgumentLoc(TAL[I]));
    1702           0 :   }
    1703          15 :   return true;
    1704          15 : }
    1705             : 
    1706             : #define DEF_TRAVERSE_TMPL_PART_SPEC_DECL(TMPLDECLKIND, DECLKIND)               \
    1707             :   DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplatePartialSpecializationDecl, {         \
    1708             :     /* The partial specialization. */                                          \
    1709             :     if (TemplateParameterList *TPL = D->getTemplateParameters()) {             \
    1710             :       for (TemplateParameterList::iterator I = TPL->begin(), E = TPL->end();   \
    1711             :            I != E; ++I) {                                                      \
    1712             :         TRY_TO(TraverseDecl(*I));                                              \
    1713             :       }                                                                        \
    1714             :     }                                                                          \
    1715             :     /* The args that remains unspecialized. */                                 \
    1716             :     TRY_TO(TraverseTemplateArgumentLocsHelper(                                 \
    1717             :         D->getTemplateArgsAsWritten()->getTemplateArgs(),                      \
    1718             :         D->getTemplateArgsAsWritten()->NumTemplateArgs));                      \
    1719             :                                                                                \
    1720             :     /* Don't need the *TemplatePartialSpecializationHelper, even               \
    1721             :        though that's our parent class -- we already visit all the              \
    1722             :        template args here. */                                                  \
    1723             :     TRY_TO(Traverse##DECLKIND##Helper(D));                                     \
    1724             :                                                                                \
    1725             :     /* Instantiations will have been visited with the primary template. */     \
    1726             :   })
    1727             : 
    1728           0 : DEF_TRAVERSE_TMPL_PART_SPEC_DECL(Class, CXXRecord)
    1729           0 : DEF_TRAVERSE_TMPL_PART_SPEC_DECL(Var, Var)
    1730             : 
    1731           0 : DEF_TRAVERSE_DECL(EnumConstantDecl, { TRY_TO(TraverseStmt(D->getInitExpr())); })
    1732             : 
    1733           0 : DEF_TRAVERSE_DECL(UnresolvedUsingValueDecl, {
    1734             :   // Like UnresolvedUsingTypenameDecl, but without the 'typename':
    1735             :   //    template <class T> Class A : public Base<T> { using Base<T>::foo; };
    1736             :   TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
    1737             :   TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
    1738             : })
    1739             : 
    1740           0 : DEF_TRAVERSE_DECL(IndirectFieldDecl, {})
    1741             : 
    1742             : template <typename Derived>
    1743             : bool RecursiveASTVisitor<Derived>::TraverseDeclaratorHelper(DeclaratorDecl *D) {
    1744          51 :   TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
    1745          17 :   if (D->getTypeSourceInfo())
    1746          68 :     TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
    1747             :   else
    1748           0 :     TRY_TO(TraverseType(D->getType()));
    1749          17 :   return true;
    1750          17 : }
    1751             : 
    1752           0 : DEF_TRAVERSE_DECL(MSPropertyDecl, { TRY_TO(TraverseDeclaratorHelper(D)); })
    1753             : 
    1754          78 : DEF_TRAVERSE_DECL(FieldDecl, {
    1755             :   TRY_TO(TraverseDeclaratorHelper(D));
    1756             :   if (D->isBitField())
    1757             :     TRY_TO(TraverseStmt(D->getBitWidth()));
    1758             :   else if (D->hasInClassInitializer())
    1759             :     TRY_TO(TraverseStmt(D->getInClassInitializer()));
    1760             : })
    1761             : 
    1762           0 : DEF_TRAVERSE_DECL(ObjCAtDefsFieldDecl, {
    1763             :   TRY_TO(TraverseDeclaratorHelper(D));
    1764             :   if (D->isBitField())
    1765             :     TRY_TO(TraverseStmt(D->getBitWidth()));
    1766             :   // FIXME: implement the rest.
    1767             : })
    1768             : 
    1769           0 : DEF_TRAVERSE_DECL(ObjCIvarDecl, {
    1770             :   TRY_TO(TraverseDeclaratorHelper(D));
    1771             :   if (D->isBitField())
    1772             :     TRY_TO(TraverseStmt(D->getBitWidth()));
    1773             :   // FIXME: implement the rest.
    1774             : })
    1775             : 
    1776             : template <typename Derived>
    1777             : bool RecursiveASTVisitor<Derived>::TraverseFunctionHelper(FunctionDecl *D) {
    1778          48 :   TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
    1779          48 :   TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
    1780             : 
    1781             :   // If we're an explicit template specialization, iterate over the
    1782             :   // template args that were explicitly specified.  If we were doing
    1783             :   // this in typing order, we'd do it between the return type and
    1784             :   // the function args, but both are handled by the FunctionTypeLoc
    1785             :   // above, so we have to choose one side.  I've decided to do before.
    1786          16 :   if (const FunctionTemplateSpecializationInfo *FTSI =
    1787          16 :           D->getTemplateSpecializationInfo()) {
    1788           0 :     if (FTSI->getTemplateSpecializationKind() != TSK_Undeclared &&
    1789           0 :         FTSI->getTemplateSpecializationKind() != TSK_ImplicitInstantiation) {
    1790             :       // A specialization might not have explicit template arguments if it has
    1791             :       // a templated return type and concrete arguments.
    1792           0 :       if (const ASTTemplateArgumentListInfo *TALI =
    1793           0 :               FTSI->TemplateArgumentsAsWritten) {
    1794           0 :         TRY_TO(TraverseTemplateArgumentLocsHelper(TALI->getTemplateArgs(),
    1795             :                                                   TALI->NumTemplateArgs));
    1796           0 :       }
    1797           0 :     }
    1798           0 :   }
    1799             : 
    1800             :   // Visit the function type itself, which can be either
    1801             :   // FunctionNoProtoType or FunctionProtoType, or a typedef.  This
    1802             :   // also covers the return type and the function parameters,
    1803             :   // including exception specifications.
    1804          16 :   if (TypeSourceInfo *TSI = D->getTypeSourceInfo()) {
    1805          48 :     TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
    1806          16 :   } else if (getDerived().shouldVisitImplicitCode()) {
    1807             :     // Visit parameter variable declarations of the implicit function
    1808             :     // if the traverser is visiting implicit code. Parameter variable
    1809             :     // declarations do not have valid TypeSourceInfo, so to visit them
    1810             :     // we need to traverse the declarations explicitly.
    1811           0 :     for (FunctionDecl::param_const_iterator I = D->param_begin(),
    1812           0 :                                             E = D->param_end();
    1813           0 :          I != E; ++I)
    1814           0 :       TRY_TO(TraverseDecl(*I));
    1815           0 :   }
    1816             : 
    1817          16 :   if (CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(D)) {
    1818             :     // Constructor initializers.
    1819          16 :     for (auto *I : Ctor->inits()) {
    1820           6 :       TRY_TO(TraverseConstructorInitializer(I));
    1821             :     }
    1822           4 :   }
    1823             : 
    1824          16 :   if (D->isThisDeclarationADefinition()) {
    1825          39 :     TRY_TO(TraverseStmt(D->getBody())); // Function body.
    1826          13 :   }
    1827          16 :   return true;
    1828          16 : }
    1829             : 
    1830          40 : DEF_TRAVERSE_DECL(FunctionDecl, {
    1831             :   // We skip decls_begin/decls_end, which are already covered by
    1832             :   // TraverseFunctionHelper().
    1833             :   return TraverseFunctionHelper(D);
    1834             : })
    1835             : 
    1836          20 : DEF_TRAVERSE_DECL(CXXMethodDecl, {
    1837             :   // We skip decls_begin/decls_end, which are already covered by
    1838             :   // TraverseFunctionHelper().
    1839             :   return TraverseFunctionHelper(D);
    1840             : })
    1841             : 
    1842          20 : DEF_TRAVERSE_DECL(CXXConstructorDecl, {
    1843             :   // We skip decls_begin/decls_end, which are already covered by
    1844             :   // TraverseFunctionHelper().
    1845             :   return TraverseFunctionHelper(D);
    1846             : })
    1847             : 
    1848             : // CXXConversionDecl is the declaration of a type conversion operator.
    1849             : // It's not a cast expression.
    1850           0 : DEF_TRAVERSE_DECL(CXXConversionDecl, {
    1851             :   // We skip decls_begin/decls_end, which are already covered by
    1852             :   // TraverseFunctionHelper().
    1853             :   return TraverseFunctionHelper(D);
    1854             : })
    1855             : 
    1856           0 : DEF_TRAVERSE_DECL(CXXDestructorDecl, {
    1857             :   // We skip decls_begin/decls_end, which are already covered by
    1858             :   // TraverseFunctionHelper().
    1859             :   return TraverseFunctionHelper(D);
    1860             : })
    1861             : 
    1862             : template <typename Derived>
    1863             : bool RecursiveASTVisitor<Derived>::TraverseVarHelper(VarDecl *D) {
    1864          33 :   TRY_TO(TraverseDeclaratorHelper(D));
    1865             :   // Default params are taken care of when we traverse the ParmVarDecl.
    1866          11 :   if (!isa<ParmVarDecl>(D) &&
    1867           9 :       (!D->isCXXForRangeDecl() || getDerived().shouldVisitImplicitCode()))
    1868          36 :     TRY_TO(TraverseStmt(D->getInit()));
    1869          11 :   return true;
    1870          11 : }
    1871             : 
    1872          99 : DEF_TRAVERSE_DECL(VarDecl, { TRY_TO(TraverseVarHelper(D)); })
    1873             : 
    1874           0 : DEF_TRAVERSE_DECL(ImplicitParamDecl, { TRY_TO(TraverseVarHelper(D)); })
    1875             : 
    1876           0 : DEF_TRAVERSE_DECL(NonTypeTemplateParmDecl, {
    1877             :   // A non-type template parameter, e.g. "S" in template<int S> class Foo ...
    1878             :   TRY_TO(TraverseDeclaratorHelper(D));
    1879             :   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
    1880             :     TRY_TO(TraverseStmt(D->getDefaultArgument()));
    1881             : })
    1882             : 
    1883          26 : DEF_TRAVERSE_DECL(ParmVarDecl, {
    1884             :   TRY_TO(TraverseVarHelper(D));
    1885             : 
    1886             :   if (D->hasDefaultArg() && D->hasUninstantiatedDefaultArg() &&
    1887             :       !D->hasUnparsedDefaultArg())
    1888             :     TRY_TO(TraverseStmt(D->getUninstantiatedDefaultArg()));
    1889             : 
    1890             :   if (D->hasDefaultArg() && !D->hasUninstantiatedDefaultArg() &&
    1891             :       !D->hasUnparsedDefaultArg())
    1892             :     TRY_TO(TraverseStmt(D->getDefaultArg()));
    1893             : })
    1894             : 
    1895             : #undef DEF_TRAVERSE_DECL
    1896             : 
    1897             : // ----------------- Stmt traversal -----------------
    1898             : //
    1899             : // For stmts, we automate (in the DEF_TRAVERSE_STMT macro) iterating
    1900             : // over the children defined in children() (every stmt defines these,
    1901             : // though sometimes the range is empty).  Each individual Traverse*
    1902             : // method only needs to worry about children other than those.  To see
    1903             : // what children() does for a given class, see, e.g.,
    1904             : //   http://clang.llvm.org/doxygen/Stmt_8cpp_source.html
    1905             : 
    1906             : // This macro makes available a variable S, the passed-in stmt.
    1907             : #define DEF_TRAVERSE_STMT(STMT, CODE)                                          \
    1908             :   template <typename Derived>                                                  \
    1909             :   bool RecursiveASTVisitor<Derived>::Traverse##STMT(STMT *S) {                 \
    1910             :     TRY_TO(WalkUpFrom##STMT(S));                                               \
    1911             :     { CODE; }                                                                  \
    1912             :     for (Stmt *SubStmt : S->children()) {                                      \
    1913             :       TRY_TO(TraverseStmt(SubStmt));                                           \
    1914             :     }                                                                          \
    1915             :     return true;                                                               \
    1916             :   }
    1917             : 
    1918           0 : DEF_TRAVERSE_STMT(GCCAsmStmt, {
    1919             :   TRY_TO(TraverseStmt(S->getAsmString()));
    1920             :   for (unsigned I = 0, E = S->getNumInputs(); I < E; ++I) {
    1921             :     TRY_TO(TraverseStmt(S->getInputConstraintLiteral(I)));
    1922             :   }
    1923             :   for (unsigned I = 0, E = S->getNumOutputs(); I < E; ++I) {
    1924             :     TRY_TO(TraverseStmt(S->getOutputConstraintLiteral(I)));
    1925             :   }
    1926             :   for (unsigned I = 0, E = S->getNumClobbers(); I < E; ++I) {
    1927             :     TRY_TO(TraverseStmt(S->getClobberStringLiteral(I)));
    1928             :   }
    1929             :   // children() iterates over inputExpr and outputExpr.
    1930             : })
    1931             : 
    1932           0 : DEF_TRAVERSE_STMT(
    1933             :     MSAsmStmt,
    1934             :     {// FIXME: MS Asm doesn't currently parse Constraints, Clobbers, etc.  Once
    1935             :      // added this needs to be implemented.
    1936             :     })
    1937             : 
    1938           0 : DEF_TRAVERSE_STMT(CXXCatchStmt, {
    1939             :   TRY_TO(TraverseDecl(S->getExceptionDecl()));
    1940             :   // children() iterates over the handler block.
    1941             : })
    1942             : 
    1943          78 : DEF_TRAVERSE_STMT(DeclStmt, {
    1944             :   for (auto *I : S->decls()) {
    1945             :     TRY_TO(TraverseDecl(I));
    1946             :   }
    1947             :   // Suppress the default iteration over children() by
    1948             :   // returning.  Here's why: A DeclStmt looks like 'type var [=
    1949             :   // initializer]'.  The decls above already traverse over the
    1950             :   // initializers, so we don't have to do it again (which
    1951             :   // children() would do).
    1952             :   return true;
    1953             : })
    1954             : 
    1955             : // These non-expr stmts (most of them), do not need any action except
    1956             : // iterating over the children.
    1957           0 : DEF_TRAVERSE_STMT(BreakStmt, {})
    1958           0 : DEF_TRAVERSE_STMT(CXXTryStmt, {})
    1959           0 : DEF_TRAVERSE_STMT(CaseStmt, {})
    1960         193 : DEF_TRAVERSE_STMT(CompoundStmt, {})
    1961           0 : DEF_TRAVERSE_STMT(ContinueStmt, {})
    1962           0 : DEF_TRAVERSE_STMT(DefaultStmt, {})
    1963           0 : DEF_TRAVERSE_STMT(DoStmt, {})
    1964           0 : DEF_TRAVERSE_STMT(ForStmt, {})
    1965           0 : DEF_TRAVERSE_STMT(GotoStmt, {})
    1966           0 : DEF_TRAVERSE_STMT(IfStmt, {})
    1967           0 : DEF_TRAVERSE_STMT(IndirectGotoStmt, {})
    1968           0 : DEF_TRAVERSE_STMT(LabelStmt, {})
    1969           0 : DEF_TRAVERSE_STMT(AttributedStmt, {})
    1970           0 : DEF_TRAVERSE_STMT(NullStmt, {})
    1971           0 : DEF_TRAVERSE_STMT(ObjCAtCatchStmt, {})
    1972           0 : DEF_TRAVERSE_STMT(ObjCAtFinallyStmt, {})
    1973           0 : DEF_TRAVERSE_STMT(ObjCAtSynchronizedStmt, {})
    1974           0 : DEF_TRAVERSE_STMT(ObjCAtThrowStmt, {})
    1975           0 : DEF_TRAVERSE_STMT(ObjCAtTryStmt, {})
    1976           0 : DEF_TRAVERSE_STMT(ObjCForCollectionStmt, {})
    1977           0 : DEF_TRAVERSE_STMT(ObjCAutoreleasePoolStmt, {})
    1978           0 : DEF_TRAVERSE_STMT(CXXForRangeStmt, {
    1979             :   if (!getDerived().shouldVisitImplicitCode()) {
    1980             :     TRY_TO(TraverseStmt(S->getLoopVarStmt()));
    1981             :     TRY_TO(TraverseStmt(S->getRangeInit()));
    1982             :     TRY_TO(TraverseStmt(S->getBody()));
    1983             :     // Visit everything else only if shouldVisitImplicitCode().
    1984             :     return true;
    1985             :   }
    1986             : })
    1987           0 : DEF_TRAVERSE_STMT(MSDependentExistsStmt, {
    1988             :   TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
    1989             :   TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
    1990             : })
    1991          65 : DEF_TRAVERSE_STMT(ReturnStmt, {})
    1992           0 : DEF_TRAVERSE_STMT(SwitchStmt, {})
    1993           0 : DEF_TRAVERSE_STMT(WhileStmt, {})
    1994             : 
    1995           0 : DEF_TRAVERSE_STMT(CXXDependentScopeMemberExpr, {
    1996             :   TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
    1997             :   TRY_TO(TraverseDeclarationNameInfo(S->getMemberNameInfo()));
    1998             :   if (S->hasExplicitTemplateArgs()) {
    1999             :     TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
    2000             :                                               S->getNumTemplateArgs()));
    2001             :   }
    2002             : })
    2003             : 
    2004         144 : DEF_TRAVERSE_STMT(DeclRefExpr, {
    2005             :   TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
    2006             :   TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
    2007             :   TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
    2008             :                                             S->getNumTemplateArgs()));
    2009             : })
    2010             : 
    2011           0 : DEF_TRAVERSE_STMT(DependentScopeDeclRefExpr, {
    2012             :   TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
    2013             :   TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
    2014             :   if (S->hasExplicitTemplateArgs()) {
    2015             :     TRY_TO(TraverseTemplateArgumentLocsHelper(
    2016             :         S->getExplicitTemplateArgs().getTemplateArgs(),
    2017             :         S->getNumTemplateArgs()));
    2018             :   }
    2019             : })
    2020             : 
    2021         132 : DEF_TRAVERSE_STMT(MemberExpr, {
    2022             :   TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
    2023             :   TRY_TO(TraverseDeclarationNameInfo(S->getMemberNameInfo()));
    2024             :   TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
    2025             :                                             S->getNumTemplateArgs()));
    2026             : })
    2027             : 
    2028         143 : DEF_TRAVERSE_STMT(
    2029             :     ImplicitCastExpr,
    2030             :     {// We don't traverse the cast type, as it's not written in the
    2031             :      // source code.
    2032             :     })
    2033             : 
    2034           0 : DEF_TRAVERSE_STMT(CStyleCastExpr, {
    2035             :   TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
    2036             : })
    2037             : 
    2038           0 : DEF_TRAVERSE_STMT(CXXFunctionalCastExpr, {
    2039             :   TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
    2040             : })
    2041             : 
    2042           0 : DEF_TRAVERSE_STMT(CXXConstCastExpr, {
    2043             :   TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
    2044             : })
    2045             : 
    2046           0 : DEF_TRAVERSE_STMT(CXXDynamicCastExpr, {
    2047             :   TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
    2048             : })
    2049             : 
    2050           0 : DEF_TRAVERSE_STMT(CXXReinterpretCastExpr, {
    2051             :   TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
    2052             : })
    2053             : 
    2054          32 : DEF_TRAVERSE_STMT(CXXStaticCastExpr, {
    2055             :   TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
    2056             : })
    2057             : 
    2058             : // InitListExpr is a tricky one, because we want to do all our work on
    2059             : // the syntactic form of the listexpr, but this method takes the
    2060             : // semantic form by default.  We can't use the macro helper because it
    2061             : // calls WalkUp*() on the semantic form, before our code can convert
    2062             : // to the syntactic form.
    2063             : template <typename Derived>
    2064             : bool RecursiveASTVisitor<Derived>::TraverseInitListExpr(InitListExpr *S) {
    2065           0 :   InitListExpr *Syn = S->isSemanticForm() ? S->getSyntacticForm() : S;
    2066           0 :   if (Syn) {
    2067           0 :     TRY_TO(WalkUpFromInitListExpr(Syn));
    2068             :     // All we need are the default actions.  FIXME: use a helper function.
    2069           0 :     for (Stmt *SubStmt : Syn->children()) {
    2070           0 :       TRY_TO(TraverseStmt(SubStmt));
    2071             :     }
    2072           0 :   }
    2073           0 :   InitListExpr *Sem = S->isSemanticForm() ? S : S->getSemanticForm();
    2074           0 :   if (Sem) {
    2075           0 :     TRY_TO(WalkUpFromInitListExpr(Sem));
    2076           0 :     for (Stmt *SubStmt : Sem->children()) {
    2077           0 :       TRY_TO(TraverseStmt(SubStmt));
    2078             :     }
    2079           0 :   }
    2080           0 :   return true;
    2081           0 : }
    2082             : 
    2083             : // GenericSelectionExpr is a special case because the types and expressions
    2084             : // are interleaved.  We also need to watch out for null types (default
    2085             : // generic associations).
    2086             : template <typename Derived>
    2087             : bool RecursiveASTVisitor<Derived>::TraverseGenericSelectionExpr(
    2088             :     GenericSelectionExpr *S) {
    2089           0 :   TRY_TO(WalkUpFromGenericSelectionExpr(S));
    2090           0 :   TRY_TO(TraverseStmt(S->getControllingExpr()));
    2091           0 :   for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
    2092           0 :     if (TypeSourceInfo *TS = S->getAssocTypeSourceInfo(i))
    2093           0 :       TRY_TO(TraverseTypeLoc(TS->getTypeLoc()));
    2094           0 :     TRY_TO(TraverseStmt(S->getAssocExpr(i)));
    2095           0 :   }
    2096           0 :   return true;
    2097           0 : }
    2098             : 
    2099             : // PseudoObjectExpr is a special case because of the wierdness with
    2100             : // syntactic expressions and opaque values.
    2101             : template <typename Derived>
    2102             : bool
    2103             : RecursiveASTVisitor<Derived>::TraversePseudoObjectExpr(PseudoObjectExpr *S) {
    2104           0 :   TRY_TO(WalkUpFromPseudoObjectExpr(S));
    2105           0 :   TRY_TO(TraverseStmt(S->getSyntacticForm()));
    2106           0 :   for (PseudoObjectExpr::semantics_iterator i = S->semantics_begin(),
    2107           0 :                                             e = S->semantics_end();
    2108           0 :        i != e; ++i) {
    2109           0 :     Expr *sub = *i;
    2110           0 :     if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(sub))
    2111           0 :       sub = OVE->getSourceExpr();
    2112           0 :     TRY_TO(TraverseStmt(sub));
    2113           0 :   }
    2114           0 :   return true;
    2115           0 : }
    2116             : 
    2117           0 : DEF_TRAVERSE_STMT(CXXScalarValueInitExpr, {
    2118             :   // This is called for code like 'return T()' where T is a built-in
    2119             :   // (i.e. non-class) type.
    2120             :   TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
    2121             : })
    2122             : 
    2123          16 : DEF_TRAVERSE_STMT(CXXNewExpr, {
    2124             :   // The child-iterator will pick up the other arguments.
    2125             :   TRY_TO(TraverseTypeLoc(S->getAllocatedTypeSourceInfo()->getTypeLoc()));
    2126             : })
    2127             : 
    2128           0 : DEF_TRAVERSE_STMT(OffsetOfExpr, {
    2129             :   // The child-iterator will pick up the expression representing
    2130             :   // the field.
    2131             :   // FIMXE: for code like offsetof(Foo, a.b.c), should we get
    2132             :   // making a MemberExpr callbacks for Foo.a, Foo.a.b, and Foo.a.b.c?
    2133             :   TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
    2134             : })
    2135             : 
    2136           0 : DEF_TRAVERSE_STMT(UnaryExprOrTypeTraitExpr, {
    2137             :   // The child-iterator will pick up the arg if it's an expression,
    2138             :   // but not if it's a type.
    2139             :   if (S->isArgumentType())
    2140             :     TRY_TO(TraverseTypeLoc(S->getArgumentTypeInfo()->getTypeLoc()));
    2141             : })
    2142             : 
    2143           0 : DEF_TRAVERSE_STMT(CXXTypeidExpr, {
    2144             :   // The child-iterator will pick up the arg if it's an expression,
    2145             :   // but not if it's a type.
    2146             :   if (S->isTypeOperand())
    2147             :     TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
    2148             : })
    2149             : 
    2150           0 : DEF_TRAVERSE_STMT(MSPropertyRefExpr, {
    2151             :   TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
    2152             : })
    2153             : 
    2154           0 : DEF_TRAVERSE_STMT(CXXUuidofExpr, {
    2155             :   // The child-iterator will pick up the arg if it's an expression,
    2156             :   // but not if it's a type.
    2157             :   if (S->isTypeOperand())
    2158             :     TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
    2159             : })
    2160             : 
    2161           0 : DEF_TRAVERSE_STMT(TypeTraitExpr, {
    2162             :   for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
    2163             :     TRY_TO(TraverseTypeLoc(S->getArg(I)->getTypeLoc()));
    2164             : })
    2165             : 
    2166           0 : DEF_TRAVERSE_STMT(ArrayTypeTraitExpr, {
    2167             :   TRY_TO(TraverseTypeLoc(S->getQueriedTypeSourceInfo()->getTypeLoc()));
    2168             : })
    2169             : 
    2170           0 : DEF_TRAVERSE_STMT(ExpressionTraitExpr,
    2171             :                   { TRY_TO(TraverseStmt(S->getQueriedExpression())); })
    2172             : 
    2173           0 : DEF_TRAVERSE_STMT(VAArgExpr, {
    2174             :   // The child-iterator will pick up the expression argument.
    2175             :   TRY_TO(TraverseTypeLoc(S->getWrittenTypeInfo()->getTypeLoc()));
    2176             : })
    2177             : 
    2178           0 : DEF_TRAVERSE_STMT(CXXTemporaryObjectExpr, {
    2179             :   // This is called for code like 'return T()' where T is a class type.
    2180             :   TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
    2181             : })
    2182             : 
    2183             : // Walk only the visible parts of lambda expressions.
    2184             : template <typename Derived>
    2185             : bool RecursiveASTVisitor<Derived>::TraverseLambdaExpr(LambdaExpr *S) {
    2186           0 :   TRY_TO(WalkUpFromLambdaExpr(S));
    2187             : 
    2188           0 :   for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(),
    2189           0 :                                     CEnd = S->explicit_capture_end();
    2190           0 :        C != CEnd; ++C) {
    2191           0 :     TRY_TO(TraverseLambdaCapture(S, C));
    2192           0 :   }
    2193             : 
    2194           0 :   TypeLoc TL = S->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
    2195           0 :   FunctionProtoTypeLoc Proto = TL.castAs<FunctionProtoTypeLoc>();
    2196             : 
    2197           0 :   if (S->hasExplicitParameters() && S->hasExplicitResultType()) {
    2198             :     // Visit the whole type.
    2199           0 :     TRY_TO(TraverseTypeLoc(TL));
    2200           0 :   } else {
    2201           0 :     if (S->hasExplicitParameters()) {
    2202             :       // Visit parameters.
    2203           0 :       for (unsigned I = 0, N = Proto.getNumParams(); I != N; ++I) {
    2204           0 :         TRY_TO(TraverseDecl(Proto.getParam(I)));
    2205           0 :       }
    2206           0 :     } else if (S->hasExplicitResultType()) {
    2207           0 :       TRY_TO(TraverseTypeLoc(Proto.getReturnLoc()));
    2208           0 :     }
    2209             : 
    2210           0 :     auto *T = Proto.getTypePtr();
    2211           0 :     for (const auto &E : T->exceptions()) {
    2212           0 :       TRY_TO(TraverseType(E));
    2213             :     }
    2214             : 
    2215           0 :     if (Expr *NE = T->getNoexceptExpr())
    2216           0 :       TRY_TO(TraverseStmt(NE));
    2217             :   }
    2218             : 
    2219           0 :   TRY_TO(TraverseLambdaBody(S));
    2220           0 :   return true;
    2221           0 : }
    2222             : 
    2223           0 : DEF_TRAVERSE_STMT(CXXUnresolvedConstructExpr, {
    2224             :   // This is called for code like 'T()', where T is a template argument.
    2225             :   TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
    2226             : })
    2227             : 
    2228             : // These expressions all might take explicit template arguments.
    2229             : // We traverse those if so.  FIXME: implement these.
    2230          21 : DEF_TRAVERSE_STMT(CXXConstructExpr, {})
    2231          38 : DEF_TRAVERSE_STMT(CallExpr, {})
    2232          39 : DEF_TRAVERSE_STMT(CXXMemberCallExpr, {})
    2233             : 
    2234             : // These exprs (most of them), do not need any action except iterating
    2235             : // over the children.
    2236           0 : DEF_TRAVERSE_STMT(AddrLabelExpr, {})
    2237           0 : DEF_TRAVERSE_STMT(ArraySubscriptExpr, {})
    2238           0 : DEF_TRAVERSE_STMT(BlockExpr, {
    2239             :   TRY_TO(TraverseDecl(S->getBlockDecl()));
    2240             :   return true; // no child statements to loop through.
    2241             : })
    2242           0 : DEF_TRAVERSE_STMT(ChooseExpr, {})
    2243           0 : DEF_TRAVERSE_STMT(CompoundLiteralExpr, {
    2244             :   TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
    2245             : })
    2246           0 : DEF_TRAVERSE_STMT(CXXBindTemporaryExpr, {})
    2247           0 : DEF_TRAVERSE_STMT(CXXBoolLiteralExpr, {})
    2248           0 : DEF_TRAVERSE_STMT(CXXDefaultArgExpr, {})
    2249           0 : DEF_TRAVERSE_STMT(CXXDefaultInitExpr, {})
    2250           0 : DEF_TRAVERSE_STMT(CXXDeleteExpr, {})
    2251           0 : DEF_TRAVERSE_STMT(ExprWithCleanups, {})
    2252           0 : DEF_TRAVERSE_STMT(CXXNullPtrLiteralExpr, {})
    2253           0 : DEF_TRAVERSE_STMT(CXXStdInitializerListExpr, {})
    2254           0 : DEF_TRAVERSE_STMT(CXXPseudoDestructorExpr, {
    2255             :   TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
    2256             :   if (TypeSourceInfo *ScopeInfo = S->getScopeTypeInfo())
    2257             :     TRY_TO(TraverseTypeLoc(ScopeInfo->getTypeLoc()));
    2258             :   if (TypeSourceInfo *DestroyedTypeInfo = S->getDestroyedTypeInfo())
    2259             :     TRY_TO(TraverseTypeLoc(DestroyedTypeInfo->getTypeLoc()));
    2260             : })
    2261           0 : DEF_TRAVERSE_STMT(CXXThisExpr, {})
    2262           0 : DEF_TRAVERSE_STMT(CXXThrowExpr, {})
    2263           0 : DEF_TRAVERSE_STMT(UserDefinedLiteral, {})
    2264           0 : DEF_TRAVERSE_STMT(DesignatedInitExpr, {})
    2265           0 : DEF_TRAVERSE_STMT(DesignatedInitUpdateExpr, {})
    2266           0 : DEF_TRAVERSE_STMT(ExtVectorElementExpr, {})
    2267           0 : DEF_TRAVERSE_STMT(GNUNullExpr, {})
    2268           0 : DEF_TRAVERSE_STMT(ImplicitValueInitExpr, {})
    2269           0 : DEF_TRAVERSE_STMT(NoInitExpr, {})
    2270           0 : DEF_TRAVERSE_STMT(ObjCBoolLiteralExpr, {})
    2271           0 : DEF_TRAVERSE_STMT(ObjCEncodeExpr, {
    2272             :   if (TypeSourceInfo *TInfo = S->getEncodedTypeSourceInfo())
    2273             :     TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
    2274             : })
    2275           0 : DEF_TRAVERSE_STMT(ObjCIsaExpr, {})
    2276           0 : DEF_TRAVERSE_STMT(ObjCIvarRefExpr, {})
    2277           0 : DEF_TRAVERSE_STMT(ObjCMessageExpr, {
    2278             :   if (TypeSourceInfo *TInfo = S->getClassReceiverTypeInfo())
    2279             :     TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
    2280             : })
    2281           0 : DEF_TRAVERSE_STMT(ObjCPropertyRefExpr, {})
    2282           0 : DEF_TRAVERSE_STMT(ObjCSubscriptRefExpr, {})
    2283           0 : DEF_TRAVERSE_STMT(ObjCProtocolExpr, {})
    2284           0 : DEF_TRAVERSE_STMT(ObjCSelectorExpr, {})
    2285           0 : DEF_TRAVERSE_STMT(ObjCIndirectCopyRestoreExpr, {})
    2286           0 : DEF_TRAVERSE_STMT(ObjCBridgedCastExpr, {
    2287             :   TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
    2288             : })
    2289           0 : DEF_TRAVERSE_STMT(ParenExpr, {})
    2290           0 : DEF_TRAVERSE_STMT(ParenListExpr, {})
    2291           0 : DEF_TRAVERSE_STMT(PredefinedExpr, {})
    2292           0 : DEF_TRAVERSE_STMT(ShuffleVectorExpr, {})
    2293           0 : DEF_TRAVERSE_STMT(ConvertVectorExpr, {})
    2294           0 : DEF_TRAVERSE_STMT(StmtExpr, {})
    2295           0 : DEF_TRAVERSE_STMT(UnresolvedLookupExpr, {
    2296             :   TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
    2297             :   if (S->hasExplicitTemplateArgs()) {
    2298             :     TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
    2299             :                                               S->getNumTemplateArgs()));
    2300             :   }
    2301             : })
    2302             : 
    2303           0 : DEF_TRAVERSE_STMT(UnresolvedMemberExpr, {
    2304             :   TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
    2305             :   if (S->hasExplicitTemplateArgs()) {
    2306             :     TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
    2307             :                                               S->getNumTemplateArgs()));
    2308             :   }
    2309             : })
    2310             : 
    2311           0 : DEF_TRAVERSE_STMT(SEHTryStmt, {})
    2312           0 : DEF_TRAVERSE_STMT(SEHExceptStmt, {})
    2313           0 : DEF_TRAVERSE_STMT(SEHFinallyStmt, {})
    2314           0 : DEF_TRAVERSE_STMT(SEHLeaveStmt, {})
    2315           0 : DEF_TRAVERSE_STMT(CapturedStmt, { TRY_TO(TraverseDecl(S->getCapturedDecl())); })
    2316             : 
    2317           0 : DEF_TRAVERSE_STMT(CXXOperatorCallExpr, {})
    2318           0 : DEF_TRAVERSE_STMT(OpaqueValueExpr, {})
    2319           0 : DEF_TRAVERSE_STMT(TypoExpr, {})
    2320           0 : DEF_TRAVERSE_STMT(CUDAKernelCallExpr, {})
    2321             : 
    2322             : // These operators (all of them) do not need any action except
    2323             : // iterating over the children.
    2324           0 : DEF_TRAVERSE_STMT(BinaryConditionalOperator, {})
    2325           0 : DEF_TRAVERSE_STMT(ConditionalOperator, {})
    2326           0 : DEF_TRAVERSE_STMT(UnaryOperator, {})
    2327           0 : DEF_TRAVERSE_STMT(BinaryOperator, {})
    2328           0 : DEF_TRAVERSE_STMT(CompoundAssignOperator, {})
    2329           0 : DEF_TRAVERSE_STMT(CXXNoexceptExpr, {})
    2330           0 : DEF_TRAVERSE_STMT(PackExpansionExpr, {})
    2331           0 : DEF_TRAVERSE_STMT(SizeOfPackExpr, {})
    2332           0 : DEF_TRAVERSE_STMT(SubstNonTypeTemplateParmPackExpr, {})
    2333           0 : DEF_TRAVERSE_STMT(SubstNonTypeTemplateParmExpr, {})
    2334           0 : DEF_TRAVERSE_STMT(FunctionParmPackExpr, {})
    2335           0 : DEF_TRAVERSE_STMT(MaterializeTemporaryExpr, {})
    2336           0 : DEF_TRAVERSE_STMT(CXXFoldExpr, {})
    2337           0 : DEF_TRAVERSE_STMT(AtomicExpr, {})
    2338             : 
    2339             : // These literals (all of them) do not need any action.
    2340          63 : DEF_TRAVERSE_STMT(IntegerLiteral, {})
    2341           0 : DEF_TRAVERSE_STMT(CharacterLiteral, {})
    2342           0 : DEF_TRAVERSE_STMT(FloatingLiteral, {})
    2343           0 : DEF_TRAVERSE_STMT(ImaginaryLiteral, {})
    2344           0 : DEF_TRAVERSE_STMT(StringLiteral, {})
    2345           0 : DEF_TRAVERSE_STMT(ObjCStringLiteral, {})
    2346           0 : DEF_TRAVERSE_STMT(ObjCBoxedExpr, {})
    2347           0 : DEF_TRAVERSE_STMT(ObjCArrayLiteral, {})
    2348           0 : DEF_TRAVERSE_STMT(ObjCDictionaryLiteral, {})
    2349             : 
    2350             : // Traverse OpenCL: AsType, Convert.
    2351           0 : DEF_TRAVERSE_STMT(AsTypeExpr, {})
    2352             : 
    2353             : // OpenMP directives.
    2354             : template <typename Derived>
    2355             : bool RecursiveASTVisitor<Derived>::TraverseOMPExecutableDirective(
    2356             :     OMPExecutableDirective *S) {
    2357           0 :   for (auto *C : S->clauses()) {
    2358           0 :     TRY_TO(TraverseOMPClause(C));
    2359             :   }
    2360           0 :   return true;
    2361           0 : }
    2362             : 
    2363             : template <typename Derived>
    2364             : bool
    2365             : RecursiveASTVisitor<Derived>::TraverseOMPLoopDirective(OMPLoopDirective *S) {
    2366             :   return TraverseOMPExecutableDirective(S);
    2367             : }
    2368             : 
    2369           0 : DEF_TRAVERSE_STMT(OMPParallelDirective,
    2370             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2371             : 
    2372           0 : DEF_TRAVERSE_STMT(OMPSimdDirective,
    2373             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2374             : 
    2375           0 : DEF_TRAVERSE_STMT(OMPForDirective,
    2376             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2377             : 
    2378           0 : DEF_TRAVERSE_STMT(OMPForSimdDirective,
    2379             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2380             : 
    2381           0 : DEF_TRAVERSE_STMT(OMPSectionsDirective,
    2382             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2383             : 
    2384           0 : DEF_TRAVERSE_STMT(OMPSectionDirective,
    2385             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2386             : 
    2387           0 : DEF_TRAVERSE_STMT(OMPSingleDirective,
    2388             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2389             : 
    2390           0 : DEF_TRAVERSE_STMT(OMPMasterDirective,
    2391             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2392             : 
    2393           0 : DEF_TRAVERSE_STMT(OMPCriticalDirective, {
    2394             :   TRY_TO(TraverseDeclarationNameInfo(S->getDirectiveName()));
    2395             :   TRY_TO(TraverseOMPExecutableDirective(S));
    2396             : })
    2397             : 
    2398           0 : DEF_TRAVERSE_STMT(OMPParallelForDirective,
    2399             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2400             : 
    2401           0 : DEF_TRAVERSE_STMT(OMPParallelForSimdDirective,
    2402             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2403             : 
    2404           0 : DEF_TRAVERSE_STMT(OMPParallelSectionsDirective,
    2405             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2406             : 
    2407           0 : DEF_TRAVERSE_STMT(OMPTaskDirective,
    2408             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2409             : 
    2410           0 : DEF_TRAVERSE_STMT(OMPTaskyieldDirective,
    2411             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2412             : 
    2413           0 : DEF_TRAVERSE_STMT(OMPBarrierDirective,
    2414             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2415             : 
    2416           0 : DEF_TRAVERSE_STMT(OMPTaskwaitDirective,
    2417             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2418             : 
    2419           0 : DEF_TRAVERSE_STMT(OMPTaskgroupDirective,
    2420             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2421             : 
    2422           0 : DEF_TRAVERSE_STMT(OMPCancellationPointDirective,
    2423             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2424             : 
    2425           0 : DEF_TRAVERSE_STMT(OMPCancelDirective,
    2426             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2427             : 
    2428           0 : DEF_TRAVERSE_STMT(OMPFlushDirective,
    2429             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2430             : 
    2431           0 : DEF_TRAVERSE_STMT(OMPOrderedDirective,
    2432             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2433             : 
    2434           0 : DEF_TRAVERSE_STMT(OMPAtomicDirective,
    2435             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2436             : 
    2437           0 : DEF_TRAVERSE_STMT(OMPTargetDirective,
    2438             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2439             : 
    2440           0 : DEF_TRAVERSE_STMT(OMPTeamsDirective,
    2441             :                   { TRY_TO(TraverseOMPExecutableDirective(S)); })
    2442             : 
    2443             : // OpenMP clauses.
    2444             : template <typename Derived>
    2445             : bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {
    2446           0 :   if (!C)
    2447           0 :     return true;
    2448           0 :   switch (C->getClauseKind()) {
    2449             : #define OPENMP_CLAUSE(Name, Class)                                             \
    2450             :   case OMPC_##Name:                                                            \
    2451             :     TRY_TO(Visit##Class(static_cast<Class *>(C)));                             \
    2452             :     break;
    2453             : #include "clang/Basic/OpenMPKinds.def"
    2454             :   case OMPC_threadprivate:
    2455             :   case OMPC_unknown:
    2456           0 :     break;
    2457             :   }
    2458           0 :   return true;
    2459           0 : }
    2460             : 
    2461             : template <typename Derived>
    2462             : bool RecursiveASTVisitor<Derived>::VisitOMPIfClause(OMPIfClause *C) {
    2463           0 :   TRY_TO(TraverseStmt(C->getCondition()));
    2464           0 :   return true;
    2465           0 : }
    2466             : 
    2467             : template <typename Derived>
    2468             : bool RecursiveASTVisitor<Derived>::VisitOMPFinalClause(OMPFinalClause *C) {
    2469           0 :   TRY_TO(TraverseStmt(C->getCondition()));
    2470           0 :   return true;
    2471           0 : }
    2472             : 
    2473             : template <typename Derived>
    2474             : bool
    2475             : RecursiveASTVisitor<Derived>::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) {
    2476           0 :   TRY_TO(TraverseStmt(C->getNumThreads()));
    2477           0 :   return true;
    2478           0 : }
    2479             : 
    2480             : template <typename Derived>
    2481             : bool RecursiveASTVisitor<Derived>::VisitOMPSafelenClause(OMPSafelenClause *C) {
    2482           0 :   TRY_TO(TraverseStmt(C->getSafelen()));
    2483           0 :   return true;
    2484           0 : }
    2485             : 
    2486             : template <typename Derived>
    2487             : bool
    2488             : RecursiveASTVisitor<Derived>::VisitOMPCollapseClause(OMPCollapseClause *C) {
    2489           0 :   TRY_TO(TraverseStmt(C->getNumForLoops()));
    2490           0 :   return true;
    2491           0 : }
    2492             : 
    2493             : template <typename Derived>
    2494             : bool RecursiveASTVisitor<Derived>::VisitOMPDefaultClause(OMPDefaultClause *) {
    2495           0 :   return true;
    2496             : }
    2497             : 
    2498             : template <typename Derived>
    2499             : bool RecursiveASTVisitor<Derived>::VisitOMPProcBindClause(OMPProcBindClause *) {
    2500           0 :   return true;
    2501             : }
    2502             : 
    2503             : template <typename Derived>
    2504             : bool
    2505             : RecursiveASTVisitor<Derived>::VisitOMPScheduleClause(OMPScheduleClause *C) {
    2506           0 :   TRY_TO(TraverseStmt(C->getChunkSize()));
    2507           0 :   TRY_TO(TraverseStmt(C->getHelperChunkSize()));
    2508           0 :   return true;
    2509           0 : }
    2510             : 
    2511             : template <typename Derived>
    2512             : bool RecursiveASTVisitor<Derived>::VisitOMPOrderedClause(OMPOrderedClause *) {
    2513           0 :   return true;
    2514             : }
    2515             : 
    2516             : template <typename Derived>
    2517             : bool RecursiveASTVisitor<Derived>::VisitOMPNowaitClause(OMPNowaitClause *) {
    2518           0 :   return true;
    2519             : }
    2520             : 
    2521             : template <typename Derived>
    2522             : bool RecursiveASTVisitor<Derived>::VisitOMPUntiedClause(OMPUntiedClause *) {
    2523           0 :   return true;
    2524             : }
    2525             : 
    2526             : template <typename Derived>
    2527             : bool
    2528             : RecursiveASTVisitor<Derived>::VisitOMPMergeableClause(OMPMergeableClause *) {
    2529           0 :   return true;
    2530             : }
    2531             : 
    2532             : template <typename Derived>
    2533             : bool RecursiveASTVisitor<Derived>::VisitOMPReadClause(OMPReadClause *) {
    2534           0 :   return true;
    2535             : }
    2536             : 
    2537             : template <typename Derived>
    2538             : bool RecursiveASTVisitor<Derived>::VisitOMPWriteClause(OMPWriteClause *) {
    2539           0 :   return true;
    2540             : }
    2541             : 
    2542             : template <typename Derived>
    2543             : bool RecursiveASTVisitor<Derived>::VisitOMPUpdateClause(OMPUpdateClause *) {
    2544           0 :   return true;
    2545             : }
    2546             : 
    2547             : template <typename Derived>
    2548             : bool RecursiveASTVisitor<Derived>::VisitOMPCaptureClause(OMPCaptureClause *) {
    2549           0 :   return true;
    2550             : }
    2551             : 
    2552             : template <typename Derived>
    2553             : bool RecursiveASTVisitor<Derived>::VisitOMPSeqCstClause(OMPSeqCstClause *) {
    2554           0 :   return true;
    2555             : }
    2556             : 
    2557             : template <typename Derived>
    2558             : template <typename T>
    2559             : bool RecursiveASTVisitor<Derived>::VisitOMPClauseList(T *Node) {
    2560           0 :   for (auto *E : Node->varlists()) {
    2561           0 :     TRY_TO(TraverseStmt(E));
    2562             :   }
    2563           0 :   return true;
    2564           0 : }
    2565             : 
    2566             : template <typename Derived>
    2567             : bool RecursiveASTVisitor<Derived>::VisitOMPPrivateClause(OMPPrivateClause *C) {
    2568           0 :   TRY_TO(VisitOMPClauseList(C));
    2569           0 :   for (auto *E : C->private_copies()) {
    2570           0 :     TRY_TO(TraverseStmt(E));
    2571             :   }
    2572           0 :   return true;
    2573           0 : }
    2574             : 
    2575             : template <typename Derived>
    2576             : bool RecursiveASTVisitor<Derived>::VisitOMPFirstprivateClause(
    2577             :     OMPFirstprivateClause *C) {
    2578           0 :   TRY_TO(VisitOMPClauseList(C));
    2579           0 :   for (auto *E : C->private_copies()) {
    2580           0 :     TRY_TO(TraverseStmt(E));
    2581             :   }
    2582           0 :   for (auto *E : C->inits()) {
    2583           0 :     TRY_TO(TraverseStmt(E));
    2584             :   }
    2585           0 :   return true;
    2586           0 : }
    2587             : 
    2588             : template <typename Derived>
    2589             : bool RecursiveASTVisitor<Derived>::VisitOMPLastprivateClause(
    2590             :     OMPLastprivateClause *C) {
    2591           0 :   TRY_TO(VisitOMPClauseList(C));
    2592           0 :   for (auto *E : C->private_copies()) {
    2593           0 :     TRY_TO(TraverseStmt(E));
    2594             :   }
    2595           0 :   for (auto *E : C->source_exprs()) {
    2596           0 :     TRY_TO(TraverseStmt(E));
    2597             :   }
    2598           0 :   for (auto *E : C->destination_exprs()) {
    2599           0 :     TRY_TO(TraverseStmt(E));
    2600             :   }
    2601           0 :   for (auto *E : C->assignment_ops()) {
    2602           0 :     TRY_TO(TraverseStmt(E));
    2603             :   }
    2604           0 :   return true;
    2605           0 : }
    2606             : 
    2607             : template <typename Derived>
    2608             : bool RecursiveASTVisitor<Derived>::VisitOMPSharedClause(OMPSharedClause *C) {
    2609           0 :   TRY_TO(VisitOMPClauseList(C));
    2610           0 :   return true;
    2611           0 : }
    2612             : 
    2613             : template <typename Derived>
    2614             : bool RecursiveASTVisitor<Derived>::VisitOMPLinearClause(OMPLinearClause *C) {
    2615           0 :   TRY_TO(TraverseStmt(C->getStep()));
    2616           0 :   TRY_TO(TraverseStmt(C->getCalcStep()));
    2617           0 :   TRY_TO(VisitOMPClauseList(C));
    2618           0 :   for (auto *E : C->inits()) {
    2619           0 :     TRY_TO(TraverseStmt(E));
    2620             :   }
    2621           0 :   for (auto *E : C->updates()) {
    2622           0 :     TRY_TO(TraverseStmt(E));
    2623             :   }
    2624           0 :   for (auto *E : C->finals()) {
    2625           0 :     TRY_TO(TraverseStmt(E));
    2626             :   }
    2627           0 :   return true;
    2628           0 : }
    2629             : 
    2630             : template <typename Derived>
    2631             : bool RecursiveASTVisitor<Derived>::VisitOMPAlignedClause(OMPAlignedClause *C) {
    2632           0 :   TRY_TO(TraverseStmt(C->getAlignment()));
    2633           0 :   TRY_TO(VisitOMPClauseList(C));
    2634           0 :   return true;
    2635           0 : }
    2636             : 
    2637             : template <typename Derived>
    2638             : bool RecursiveASTVisitor<Derived>::VisitOMPCopyinClause(OMPCopyinClause *C) {
    2639           0 :   TRY_TO(VisitOMPClauseList(C));
    2640           0 :   for (auto *E : C->source_exprs()) {
    2641           0 :     TRY_TO(TraverseStmt(E));
    2642             :   }
    2643           0 :   for (auto *E : C->destination_exprs()) {
    2644           0 :     TRY_TO(TraverseStmt(E));
    2645             :   }
    2646           0 :   for (auto *E : C->assignment_ops()) {
    2647           0 :     TRY_TO(TraverseStmt(E));
    2648             :   }
    2649           0 :   return true;
    2650           0 : }
    2651             : 
    2652             : template <typename Derived>
    2653             : bool RecursiveASTVisitor<Derived>::VisitOMPCopyprivateClause(
    2654             :     OMPCopyprivateClause *C) {
    2655           0 :   TRY_TO(VisitOMPClauseList(C));
    2656           0 :   for (auto *E : C->source_exprs()) {
    2657           0 :     TRY_TO(TraverseStmt(E));
    2658             :   }
    2659           0 :   for (auto *E : C->destination_exprs()) {
    2660           0 :     TRY_TO(TraverseStmt(E));
    2661             :   }
    2662           0 :   for (auto *E : C->assignment_ops()) {
    2663           0 :     TRY_TO(TraverseStmt(E));
    2664             :   }
    2665           0 :   return true;
    2666           0 : }
    2667             : 
    2668             : template <typename Derived>
    2669             : bool
    2670             : RecursiveASTVisitor<Derived>::VisitOMPReductionClause(OMPReductionClause *C) {
    2671           0 :   TRY_TO(TraverseNestedNameSpecifierLoc(C->getQualifierLoc()));
    2672           0 :   TRY_TO(TraverseDeclarationNameInfo(C->getNameInfo()));
    2673           0 :   TRY_TO(VisitOMPClauseList(C));
    2674           0 :   for (auto *E : C->lhs_exprs()) {
    2675           0 :     TRY_TO(TraverseStmt(E));
    2676             :   }
    2677           0 :   for (auto *E : C->rhs_exprs()) {
    2678           0 :     TRY_TO(TraverseStmt(E));
    2679             :   }
    2680           0 :   for (auto *E : C->reduction_ops()) {
    2681           0 :     TRY_TO(TraverseStmt(E));
    2682             :   }
    2683           0 :   return true;
    2684           0 : }
    2685             : 
    2686             : template <typename Derived>
    2687             : bool RecursiveASTVisitor<Derived>::VisitOMPFlushClause(OMPFlushClause *C) {
    2688           0 :   TRY_TO(VisitOMPClauseList(C));
    2689           0 :   return true;
    2690           0 : }
    2691             : 
    2692             : template <typename Derived>
    2693             : bool RecursiveASTVisitor<Derived>::VisitOMPDependClause(OMPDependClause *C) {
    2694           0 :   TRY_TO(VisitOMPClauseList(C));
    2695           0 :   return true;
    2696           0 : }
    2697             : 
    2698             : // FIXME: look at the following tricky-seeming exprs to see if we
    2699             : // need to recurse on anything.  These are ones that have methods
    2700             : // returning decls or qualtypes or nestednamespecifier -- though I'm
    2701             : // not sure if they own them -- or just seemed very complicated, or
    2702             : // had lots of sub-types to explore.
    2703             : //
    2704             : // VisitOverloadExpr and its children: recurse on template args? etc?
    2705             : 
    2706             : // FIXME: go through all the stmts and exprs again, and see which of them
    2707             : // create new types, and recurse on the types (TypeLocs?) of those.
    2708             : // Candidates:
    2709             : //
    2710             : //    http://clang.llvm.org/doxygen/classclang_1_1CXXTypeidExpr.html
    2711             : //    http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html
    2712             : //    http://clang.llvm.org/doxygen/classclang_1_1TypesCompatibleExpr.html
    2713             : //    Every class that has getQualifier.
    2714             : 
    2715             : #undef DEF_TRAVERSE_STMT
    2716             : 
    2717             : #undef TRY_TO
    2718             : 
    2719             : } // end namespace clang
    2720             : 
    2721             : #endif // LLVM_CLANG_AST_RECURSIVEASTVISITOR_H

Generated by: LCOV version 1.11