14 #ifndef LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
15 #define LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
44 #include "llvm/ADT/PointerIntPair.h"
45 #include "llvm/ADT/SmallVector.h"
46 #include "llvm/Support/Casting.h"
49 #include <type_traits>
55 #define UNARYOP_LIST() \
56 OPERATOR(PostInc) OPERATOR(PostDec) OPERATOR(PreInc) OPERATOR(PreDec) \
57 OPERATOR(AddrOf) OPERATOR(Deref) OPERATOR(Plus) OPERATOR(Minus) \
58 OPERATOR(Not) OPERATOR(LNot) OPERATOR(Real) OPERATOR(Imag) \
59 OPERATOR(Extension) OPERATOR(Coawait)
62 #define BINOP_LIST() \
63 OPERATOR(PtrMemD) OPERATOR(PtrMemI) OPERATOR(Mul) OPERATOR(Div) \
64 OPERATOR(Rem) OPERATOR(Add) OPERATOR(Sub) OPERATOR(Shl) OPERATOR(Shr) \
65 OPERATOR(LT) OPERATOR(GT) OPERATOR(LE) OPERATOR(GE) OPERATOR(EQ) \
66 OPERATOR(NE) OPERATOR(And) OPERATOR(Xor) OPERATOR(Or) OPERATOR(LAnd) \
67 OPERATOR(LOr) OPERATOR(Assign) OPERATOR(Comma)
71 OPERATOR(Mul) OPERATOR(Div) OPERATOR(Rem) OPERATOR(Add) OPERATOR(Sub) \
72 OPERATOR(Shl) OPERATOR(Shr) OPERATOR(And) OPERATOR(Or) OPERATOR(Xor)
80 #define TRY_TO(CALL_EXPR) \
82 if (!getDerived().CALL_EXPR) \
162 Derived &
getDerived() {
return *
static_cast<Derived *
>(
this); }
306 #define ATTR_VISITOR_DECLS_ONLY
307 #include "clang/AST/AttrVisitor.inc"
308 #undef ATTR_VISITOR_DECLS_ONLY
313 template<
typename T,
typename U>
314 struct has_same_member_pointer_type : std::false_type {};
315 template<
typename T,
typename U,
typename R,
typename...
P>
316 struct has_same_member_pointer_type<R (T::*)(P...), R (U::*)(P...)>
324 #define TRAVERSE_STMT_BASE(NAME, CLASS, VAR, QUEUE) \
325 (has_same_member_pointer_type<decltype( \
326 &RecursiveASTVisitor::Traverse##NAME), \
327 decltype(&Derived::Traverse##NAME)>::value \
328 ? static_cast<typename std::conditional< \
329 has_same_member_pointer_type< \
330 decltype(&RecursiveASTVisitor::Traverse##NAME), \
331 decltype(&Derived::Traverse##NAME)>::value, \
332 Derived &, RecursiveASTVisitor &>::type>(*this) \
333 .Traverse##NAME(static_cast<CLASS *>(VAR), QUEUE) \
334 : getDerived().Traverse##NAME(static_cast<CLASS *>(VAR)))
339 #define TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S) \
341 if (!TRAVERSE_STMT_BASE(Stmt, Stmt, S, Queue)) \
347 #define ABSTRACT_STMT(STMT)
348 #define STMT(CLASS, PARENT) \
349 bool Traverse##CLASS(CLASS *S, DataRecursionQueue *Queue = nullptr);
350 #include "clang/AST/StmtNodes.inc"
356 #define STMT(CLASS, PARENT) \
357 bool WalkUpFrom##CLASS(CLASS *S) { \
358 TRY_TO(WalkUpFrom##PARENT(S)); \
359 TRY_TO(Visit##CLASS(S)); \
362 bool Visit##CLASS(CLASS *S) { return true; }
363 #include "clang/AST/StmtNodes.inc"
368 #define OPERATOR(NAME) \
369 bool TraverseUnary##NAME(UnaryOperator *S, \
370 DataRecursionQueue *Queue = nullptr) { \
371 if (!getDerived().shouldTraversePostOrder()) \
372 TRY_TO(WalkUpFromUnary##NAME(S)); \
373 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr()); \
376 bool WalkUpFromUnary##NAME(UnaryOperator *S) { \
377 TRY_TO(WalkUpFromUnaryOperator(S)); \
378 TRY_TO(VisitUnary##NAME(S)); \
381 bool VisitUnary##NAME(UnaryOperator *S) { return true; }
389 #define GENERAL_BINOP_FALLBACK(NAME, BINOP_TYPE) \
390 bool TraverseBin##NAME(BINOP_TYPE *S, DataRecursionQueue *Queue = nullptr) { \
391 if (!getDerived().shouldTraversePostOrder()) \
392 TRY_TO(WalkUpFromBin##NAME(S)); \
393 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLHS()); \
394 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRHS()); \
397 bool WalkUpFromBin##NAME(BINOP_TYPE *S) { \
398 TRY_TO(WalkUpFrom##BINOP_TYPE(S)); \
399 TRY_TO(VisitBin##NAME(S)); \
402 bool VisitBin##NAME(BINOP_TYPE *S) { return true; }
404 #define OPERATOR(NAME) GENERAL_BINOP_FALLBACK(NAME, BinaryOperator)
412 #define OPERATOR(NAME) \
413 GENERAL_BINOP_FALLBACK(NAME##Assign, CompoundAssignOperator)
417 #undef GENERAL_BINOP_FALLBACK
423 #define ABSTRACT_TYPE(CLASS, BASE)
424 #define TYPE(CLASS, BASE) bool Traverse##CLASS##Type(CLASS##Type *T);
425 #include "clang/AST/TypeNodes.def"
431 #define TYPE(CLASS, BASE) \
432 bool WalkUpFrom##CLASS##Type(CLASS##Type *T) { \
433 TRY_TO(WalkUpFrom##BASE(T)); \
434 TRY_TO(Visit##CLASS##Type(T)); \
437 bool Visit##CLASS##Type(CLASS##Type *T) { return true; }
438 #include "clang/AST/TypeNodes.def"
444 #define ABSTRACT_TYPELOC(CLASS, BASE)
445 #define TYPELOC(CLASS, BASE) bool Traverse##CLASS##TypeLoc(CLASS##TypeLoc TL);
446 #include "clang/AST/TypeLocNodes.def"
465 #define TYPE(CLASS, BASE) \
466 bool WalkUpFrom##CLASS##TypeLoc(CLASS##TypeLoc TL) { \
467 TRY_TO(WalkUpFrom##BASE##Loc(TL)); \
468 TRY_TO(Visit##CLASS##TypeLoc(TL)); \
471 bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TL) { return true; }
472 #include "clang/AST/TypeNodes.def"
477 #define ABSTRACT_DECL(DECL)
478 #define DECL(CLASS, BASE) bool Traverse##CLASS##Decl(CLASS##Decl *D);
479 #include "clang/AST/DeclNodes.inc"
485 #define DECL(CLASS, BASE) \
486 bool WalkUpFrom##CLASS##Decl(CLASS##Decl *D) { \
487 TRY_TO(WalkUpFrom##BASE(D)); \
488 TRY_TO(Visit##CLASS##Decl(D)); \
491 bool Visit##CLASS##Decl(CLASS##Decl *D) { return true; }
492 #include "clang/AST/DeclNodes.inc"
496 bool TraverseTemplateParameterListHelper(TemplateParameterList *TPL);
499 template <
typename T>
500 bool TraverseDeclTemplateParameterLists(T *D);
502 #define DEF_TRAVERSE_TMPL_INST(TMPLDECLKIND) \
503 bool TraverseTemplateInstantiations(TMPLDECLKIND##TemplateDecl *D);
507 #undef DEF_TRAVERSE_TMPL_INST
508 bool TraverseTemplateArgumentLocsHelper(
const TemplateArgumentLoc *TAL,
510 bool TraverseArrayTypeLocHelper(ArrayTypeLoc TL);
511 bool TraverseRecordHelper(RecordDecl *D);
512 bool TraverseCXXRecordHelper(CXXRecordDecl *D);
513 bool TraverseDeclaratorHelper(DeclaratorDecl *D);
514 bool TraverseDeclContextHelper(DeclContext *DC);
515 bool TraverseFunctionHelper(FunctionDecl *D);
516 bool TraverseVarHelper(VarDecl *D);
517 bool TraverseOMPExecutableDirective(OMPExecutableDirective *
S);
518 bool TraverseOMPLoopDirective(OMPLoopDirective *
S);
520 #define OPENMP_CLAUSE(Name, Class) bool Visit##Class(Class *C);
521 #include "clang/Basic/OpenMPKinds.def"
523 template <
typename T>
bool VisitOMPClauseList(T *
Node);
526 bool VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *
Node);
529 bool PostVisitStmt(Stmt *
S);
532 template <
typename Derived>
533 bool RecursiveASTVisitor<Derived>::dataTraverseNode(Stmt *
S,
534 DataRecursionQueue *Queue) {
535 #define DISPATCH_STMT(NAME, CLASS, VAR) \
536 return TRAVERSE_STMT_BASE(NAME, CLASS, VAR, Queue);
541 if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(S)) {
542 switch (BinOp->getOpcode()) {
543 #define OPERATOR(NAME) \
545 DISPATCH_STMT(Bin##NAME, BinaryOperator, S);
551 #define OPERATOR(NAME) \
552 case BO_##NAME##Assign: \
553 DISPATCH_STMT(Bin##NAME##Assign, CompoundAssignOperator, S);
559 }
else if (UnaryOperator *UnOp = dyn_cast<UnaryOperator>(S)) {
560 switch (UnOp->getOpcode()) {
561 #define OPERATOR(NAME) \
563 DISPATCH_STMT(Unary##NAME, UnaryOperator, S);
572 switch (S->getStmtClass()) {
575 #define ABSTRACT_STMT(STMT)
576 #define STMT(CLASS, PARENT) \
577 case Stmt::CLASS##Class: \
578 DISPATCH_STMT(CLASS, CLASS, S);
579 #include "clang/AST/StmtNodes.inc"
587 template <
typename Derived>
588 bool RecursiveASTVisitor<Derived>::PostVisitStmt(Stmt *S) {
589 switch (S->getStmtClass()) {
592 #define ABSTRACT_STMT(STMT)
593 #define STMT(CLASS, PARENT) \
594 case Stmt::CLASS##Class: \
595 TRY_TO(WalkUpFrom##CLASS(static_cast<CLASS *>(S))); break;
596 #define INITLISTEXPR(CLASS, PARENT) \
597 case Stmt::CLASS##Class: \
599 auto ILE = static_cast<CLASS *>(S); \
600 if (auto Syn = ILE->isSemanticForm() ? ILE->getSyntacticForm() : ILE) \
601 TRY_TO(WalkUpFrom##CLASS(Syn)); \
602 if (auto Sem = ILE->isSemanticForm() ? ILE : ILE->getSemanticForm()) \
603 TRY_TO(WalkUpFrom##CLASS(Sem)); \
606 #include "clang/AST/StmtNodes.inc"
614 template <
typename Derived>
621 Queue->push_back({
S,
false});
626 LocalQueue.push_back({
S,
false});
628 while (!LocalQueue.empty()) {
629 auto &CurrSAndVisited = LocalQueue.back();
630 Stmt *CurrS = CurrSAndVisited.getPointer();
631 bool Visited = CurrSAndVisited.getInt();
633 LocalQueue.pop_back();
634 TRY_TO(dataTraverseStmtPost(CurrS));
635 if (getDerived().shouldTraversePostOrder()) {
636 TRY_TO(PostVisitStmt(CurrS));
641 if (getDerived().dataTraverseStmtPre(CurrS)) {
642 CurrSAndVisited.setInt(
true);
643 size_t N = LocalQueue.size();
644 TRY_TO(dataTraverseNode(CurrS, &LocalQueue));
646 std::reverse(LocalQueue.begin() + N, LocalQueue.end());
648 LocalQueue.pop_back();
655 #define DISPATCH(NAME, CLASS, VAR) \
656 return getDerived().Traverse##NAME(static_cast<CLASS *>(VAR))
658 template <
typename Derived>
664 #define ABSTRACT_TYPE(CLASS, BASE)
665 #define TYPE(CLASS, BASE) \
667 DISPATCH(CLASS##Type, CLASS##Type, const_cast<Type *>(T.getTypePtr()));
668 #include "clang/AST/TypeNodes.def"
674 template <
typename Derived>
680 #define ABSTRACT_TYPELOC(CLASS, BASE)
681 #define TYPELOC(CLASS, BASE) \
682 case TypeLoc::CLASS: \
683 return getDerived().Traverse##CLASS##TypeLoc(TL.castAs<CLASS##TypeLoc>());
684 #include "clang/AST/TypeLocNodes.def"
691 #define VISITORCLASS RecursiveASTVisitor
692 #include "clang/AST/AttrVisitor.inc"
695 template <
typename Derived>
702 if (!getDerived().shouldVisitImplicitCode() && D->
isImplicit())
706 #define ABSTRACT_DECL(DECL)
707 #define DECL(CLASS, BASE) \
709 if (!getDerived().Traverse##CLASS##Decl(static_cast<CLASS##Decl *>(D))) \
712 #include "clang/AST/DeclNodes.inc"
716 for (
auto *
I : D->
attrs()) {
717 if (!getDerived().TraverseAttr(
I))
725 template <
typename Derived>
750 template <
typename Derived>
757 TRY_TO(TraverseNestedNameSpecifierLoc(Prefix));
776 template <
typename Derived>
784 TRY_TO(TraverseTypeLoc(TSInfo->getTypeLoc()));
788 TRY_TO(TraverseTemplateName(
805 template <
typename Derived>
808 TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier()));
810 TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
815 template <
typename Derived>
826 return getDerived().TraverseType(Arg.
getAsType());
830 return getDerived().TraverseTemplateName(
834 return getDerived().TraverseStmt(Arg.
getAsExpr());
837 return getDerived().TraverseTemplateArguments(Arg.
pack_begin(),
846 template <
typename Derived>
861 return getDerived().TraverseTypeLoc(TSI->getTypeLoc());
863 return getDerived().TraverseType(Arg.
getAsType());
869 TRY_TO(getDerived().TraverseNestedNameSpecifierLoc(
871 return getDerived().TraverseTemplateName(
878 return getDerived().TraverseTemplateArguments(Arg.
pack_begin(),
885 template <
typename Derived>
888 for (
unsigned I = 0;
I != NumArgs; ++
I) {
889 TRY_TO(TraverseTemplateArgument(Args[
I]));
895 template <
typename Derived>
899 TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
901 if (Init->
isWritten() || getDerived().shouldVisitImplicitCode())
907 template <
typename Derived>
915 TRY_TO(TraverseStmt(Init));
919 template <
typename Derived>
929 #define DEF_TRAVERSE_TYPE(TYPE, CODE) \
930 template <typename Derived> \
931 bool RecursiveASTVisitor<Derived>::Traverse##TYPE(TYPE *T) { \
932 if (!getDerived().shouldTraversePostOrder()) \
933 TRY_TO(WalkUpFrom##TYPE(T)); \
935 if (getDerived().shouldTraversePostOrder()) \
936 TRY_TO(WalkUpFrom##TYPE(T)); \
947 {
TRY_TO(TraverseType(T->getPointeeType())); })
950 {
TRY_TO(TraverseType(T->getPointeeType())); })
953 {
TRY_TO(TraverseType(T->getPointeeType())); })
956 TRY_TO(TraverseType(QualType(T->getClass(), 0)));
957 TRY_TO(TraverseType(T->getPointeeType()));
965 {
TRY_TO(TraverseType(T->getElementType())); })
968 {
TRY_TO(TraverseType(T->getElementType())); })
971 TRY_TO(TraverseType(T->getElementType()));
972 TRY_TO(TraverseStmt(T->getSizeExpr()));
976 TRY_TO(TraverseType(T->getElementType()));
977 if (T->getSizeExpr())
978 TRY_TO(TraverseStmt(T->getSizeExpr()));
982 if (T->getSizeExpr())
983 TRY_TO(TraverseStmt(T->getSizeExpr()));
984 TRY_TO(TraverseType(T->getElementType()));
992 {
TRY_TO(TraverseType(T->getReturnType())); })
995 TRY_TO(TraverseType(T->getReturnType()));
997 for (
const auto &A : T->param_types()) {
1001 for (
const auto &
E : T->exceptions()) {
1005 if (Expr *NE = T->getNoexceptExpr())
1006 TRY_TO(TraverseStmt(NE));
1013 {
TRY_TO(TraverseStmt(T->getUnderlyingExpr())); })
1018 {
TRY_TO(TraverseStmt(T->getUnderlyingExpr())); })
1021 TRY_TO(TraverseType(T->getBaseType()));
1022 TRY_TO(TraverseType(T->getUnderlyingType()));
1027 TRY_TO(TraverseTemplateName(T->getTemplateName()));
1028 TRY_TO(TraverseType(T->getDeducedType()));
1035 TRY_TO(TraverseType(T->getReplacementType()));
1038 TRY_TO(TraverseTemplateArgument(T->getArgumentPack()));
1042 TRY_TO(TraverseTemplateName(T->getTemplateName()));
1043 TRY_TO(TraverseTemplateArguments(T->getArgs(), T->getNumArgs()));
1049 {
TRY_TO(TraverseType(T->getModifiedType())); })
1054 if (T->getQualifier()) {
1055 TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
1057 TRY_TO(TraverseType(T->getNamedType()));
1061 {
TRY_TO(TraverseNestedNameSpecifier(T->getQualifier())); })
1064 TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
1065 TRY_TO(TraverseTemplateArguments(T->getArgs(), T->getNumArgs()));
1077 if (T->getBaseType().getTypePtr() != T)
1078 TRY_TO(TraverseType(T->getBaseType()));
1079 for (
auto typeArg : T->getTypeArgsAsWritten()) {
1080 TRY_TO(TraverseType(typeArg));
1085 {
TRY_TO(TraverseType(T->getPointeeType())); })
1101 template <typename Derived>
\
1102 bool RecursiveASTVisitor<Derived>::Traverse##
TYPE##Loc(
TYPE##Loc TL) {
\
1103 if (getDerived().shouldWalkTypesOfTypeLocs())
\
1104 TRY_TO(WalkUpFrom##
TYPE(const_cast<TYPE *>(TL.getTypePtr())));
\
1110 template <
typename Derived>
1112 RecursiveASTVisitor<Derived>::TraverseQualifiedTypeLoc(QualifiedTypeLoc TL) {
1128 return TraverseTypeLoc(TL.getUnqualifiedLoc());
1135 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1139 {
TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1142 {
TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1145 {
TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1148 {
TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1154 TRY_TO(TraverseType(QualType(TL.getTypePtr()->getClass(), 0)));
1155 TRY_TO(TraverseTypeLoc(TL.getPointeeLoc()));
1159 {
TRY_TO(TraverseTypeLoc(TL.getOriginalLoc())); })
1162 {
TRY_TO(TraverseTypeLoc(TL.getOriginalLoc())); })
1164 template <typename Derived>
1167 TRY_TO(TraverseStmt(TL.getSizeExpr()));
1172 TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1177 TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1182 TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1187 TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1194 if (TL.getTypePtr()->getSizeExpr())
1195 TRY_TO(TraverseStmt(TL.getTypePtr()->getSizeExpr()));
1196 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1201 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1207 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1211 {
TRY_TO(TraverseTypeLoc(TL.getReturnLoc())); })
1215 TRY_TO(TraverseTypeLoc(TL.getReturnLoc()));
1217 const FunctionProtoType *T = TL.getTypePtr();
1219 for (
unsigned I = 0,
E = TL.getNumParams();
I !=
E; ++
I) {
1220 if (TL.getParam(
I)) {
1221 TRY_TO(TraverseDecl(TL.getParam(
I)));
1222 }
else if (I < T->getNumParams()) {
1223 TRY_TO(TraverseType(T->getParamType(
I)));
1227 for (
const auto &
E : T->exceptions()) {
1231 if (Expr *NE = T->getNoexceptExpr())
1232 TRY_TO(TraverseStmt(NE));
1239 {
TRY_TO(TraverseStmt(TL.getUnderlyingExpr())); })
1242 TRY_TO(TraverseTypeLoc(TL.getUnderlyingTInfo()->getTypeLoc()));
1247 TRY_TO(TraverseStmt(TL.getTypePtr()->getUnderlyingExpr()));
1251 TRY_TO(TraverseTypeLoc(TL.getUnderlyingTInfo()->getTypeLoc()));
1255 TRY_TO(TraverseType(TL.getTypePtr()->getDeducedType()));
1259 TRY_TO(TraverseTemplateName(TL.getTypePtr()->getTemplateName()));
1260 TRY_TO(TraverseType(TL.getTypePtr()->getDeducedType()));
1267 TRY_TO(TraverseType(TL.getTypePtr()->getReplacementType()));
1270 TRY_TO(TraverseTemplateArgument(TL.getTypePtr()->getArgumentPack()));
1275 TRY_TO(TraverseTemplateName(TL.getTypePtr()->getTemplateName()));
1276 for (
unsigned I = 0,
E = TL.getNumArgs();
I !=
E; ++
I) {
1277 TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(
I)));
1286 {
TRY_TO(TraverseTypeLoc(TL.getModifiedLoc())); })
1289 if (TL.getQualifierLoc()) {
1290 TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1292 TRY_TO(TraverseTypeLoc(TL.getNamedTypeLoc()));
1296 TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1300 if (TL.getQualifierLoc()) {
1301 TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1304 for (
unsigned I = 0,
E = TL.getNumArgs();
I !=
E; ++
I) {
1305 TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(
I)));
1310 {
TRY_TO(TraverseTypeLoc(TL.getPatternLoc())); })
1319 if (TL.getTypePtr()->getBaseType().getTypePtr() != TL.getTypePtr())
1320 TRY_TO(TraverseTypeLoc(TL.getBaseLoc()));
1321 for (
unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
1322 TRY_TO(TraverseTypeLoc(TL.getTypeArgTInfo(i)->getTypeLoc()));
1326 {
TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1341 template <typename Derived>
1342 bool RecursiveASTVisitor<Derived>::TraverseDeclContextHelper(DeclContext *DC) {
1346 for (
auto *Child : DC->decls()) {
1349 if (!isa<BlockDecl>(Child) && !isa<CapturedDecl>(Child))
1350 TRY_TO(TraverseDecl(Child));
1357 #define DEF_TRAVERSE_DECL(DECL, CODE) \
1358 template <typename Derived> \
1359 bool RecursiveASTVisitor<Derived>::Traverse##DECL(DECL *D) { \
1360 bool ShouldVisitChildren = true; \
1361 bool ReturnValue = true; \
1362 if (!getDerived().shouldTraversePostOrder()) \
1363 TRY_TO(WalkUpFrom##DECL(D)); \
1365 if (ReturnValue && ShouldVisitChildren) \
1366 TRY_TO(TraverseDeclContextHelper(dyn_cast<DeclContext>(D))); \
1367 if (ReturnValue && getDerived().shouldTraversePostOrder()) \
1368 TRY_TO(WalkUpFrom##DECL(D)); \
1369 return ReturnValue; \
1375 if (TypeSourceInfo *TInfo = D->getSignatureAsWritten())
1376 TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
1377 TRY_TO(TraverseStmt(D->getBody()));
1378 for (
const auto &
I : D->captures()) {
1379 if (
I.hasCopyExpr()) {
1380 TRY_TO(TraverseStmt(
I.getCopyExpr()));
1387 TRY_TO(TraverseStmt(D->getBody()));
1394 {
TRY_TO(TraverseStmt(D->getAsmString())); })
1400 if (D->getFriendType())
1401 TRY_TO(TraverseTypeLoc(D->getFriendType()->getTypeLoc()));
1403 TRY_TO(TraverseDecl(D->getFriendDecl()));
1407 if (D->getFriendType())
1408 TRY_TO(TraverseTypeLoc(D->getFriendType()->getTypeLoc()));
1410 TRY_TO(TraverseDecl(D->getFriendDecl()));
1411 for (
unsigned I = 0,
E = D->getNumTemplateParameters();
I <
E; ++
I) {
1412 TemplateParameterList *TPL = D->getTemplateParameterList(
I);
1414 ITPL != ETPL; ++ITPL) {
1415 TRY_TO(TraverseDecl(*ITPL));
1421 TRY_TO(TraverseDecl(D->getSpecialization()));
1423 if (D->hasExplicitTemplateArgs()) {
1438 TRY_TO(TraverseStmt(D->getAssertExpr()));
1439 TRY_TO(TraverseStmt(D->getMessage()));
1443 TranslationUnitDecl,
1456 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1477 if (ObjCTypeParamList *typeParamList = D->getTypeParamList()) {
1478 for (
auto typeParam : *typeParamList) {
1479 TRY_TO(TraverseObjCTypeParamDecl(typeParam));
1491 if (ObjCTypeParamList *typeParamList = D->getTypeParamListAsWritten()) {
1492 for (
auto typeParam : *typeParamList) {
1493 TRY_TO(TraverseObjCTypeParamDecl(typeParam));
1497 if (TypeSourceInfo *superTInfo = D->getSuperClassTInfo()) {
1498 TRY_TO(TraverseTypeLoc(superTInfo->getTypeLoc()));
1506 if (D->getReturnTypeSourceInfo()) {
1507 TRY_TO(TraverseTypeLoc(D->getReturnTypeSourceInfo()->getTypeLoc()));
1509 for (ParmVarDecl *Parameter : D->parameters()) {
1510 TRY_TO(TraverseDecl(Parameter));
1512 if (D->isThisDeclarationADefinition()) {
1513 TRY_TO(TraverseStmt(D->getBody()));
1519 if (D->hasExplicitBound()) {
1520 TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1528 if (D->getTypeSourceInfo())
1529 TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1531 TRY_TO(TraverseType(D->getType()));
1536 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1537 TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
1543 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1551 for (
auto *
I : D->varlists()) {
1557 TRY_TO(TraverseStmt(D->getCombiner()));
1558 if (
auto *Initializer = D->getInitializer())
1559 TRY_TO(TraverseStmt(Initializer));
1560 TRY_TO(TraverseType(D->getType()));
1567 template <typename Derived>
1568 bool RecursiveASTVisitor<Derived>::TraverseTemplateParameterListHelper(
1569 TemplateParameterList *TPL) {
1579 template <
typename Derived>
1580 template <
typename T>
1581 bool RecursiveASTVisitor<Derived>::TraverseDeclTemplateParameterLists(T *D) {
1582 for (
unsigned i = 0; i < D->getNumTemplateParameterLists(); i++) {
1583 TemplateParameterList *TPL = D->getTemplateParameterList(i);
1584 TraverseTemplateParameterListHelper(TPL);
1589 template <
typename Derived>
1590 bool RecursiveASTVisitor<Derived>::TraverseTemplateInstantiations(
1591 ClassTemplateDecl *D) {
1592 for (
auto *SD : D->specializations()) {
1593 for (
auto *RD : SD->redecls()) {
1595 if (cast<CXXRecordDecl>(RD)->isInjectedClassName())
1599 cast<ClassTemplateSpecializationDecl>(RD)->getSpecializationKind()) {
1603 TRY_TO(TraverseDecl(RD));
1620 template <
typename Derived>
1621 bool RecursiveASTVisitor<Derived>::TraverseTemplateInstantiations(
1622 VarTemplateDecl *D) {
1623 for (
auto *SD : D->specializations()) {
1624 for (
auto *RD : SD->redecls()) {
1626 cast<VarTemplateSpecializationDecl>(RD)->getSpecializationKind()) {
1629 TRY_TO(TraverseDecl(RD));
1645 template <
typename Derived>
1646 bool RecursiveASTVisitor<Derived>::TraverseTemplateInstantiations(
1647 FunctionTemplateDecl *D) {
1648 for (
auto *FD : D->specializations()) {
1649 for (
auto *RD : FD->redecls()) {
1650 switch (RD->getTemplateSpecializationKind()) {
1654 TRY_TO(TraverseDecl(RD));
1661 TRY_TO(TraverseDecl(RD));
1675 #define DEF_TRAVERSE_TMPL_DECL(TMPLDECLKIND) \
1676 DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateDecl, { \
1677 TRY_TO(TraverseDecl(D->getTemplatedDecl())); \
1678 TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \
1686 if (getDerived().shouldVisitTemplateInstantiations() && \
1687 D == D->getCanonicalDecl()) \
1688 TRY_TO(TraverseTemplateInstantiations(D)); \
1702 TRY_TO(TraverseDecl(D->getTemplatedDecl()));
1703 if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) {
1704 TRY_TO(TraverseTemplateArgumentLoc(D->getDefaultArgument()));
1706 TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1710 TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1715 if (D->getTypeForDecl())
1716 TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
1717 if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
1718 TRY_TO(TraverseTypeLoc(D->getDefaultArgumentInfo()->getTypeLoc()));
1722 TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1729 TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1736 TRY_TO(TraverseDecl(D->getTemplatedDecl()));
1737 TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1743 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1750 TRY_TO(TraverseDeclTemplateParameterLists(D));
1752 if (D->getTypeForDecl())
1753 TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
1755 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1761 template <typename Derived>
1762 bool RecursiveASTVisitor<Derived>::TraverseRecordHelper(RecordDecl *D) {
1766 TRY_TO(TraverseDeclTemplateParameterLists(D));
1767 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1771 template <
typename Derived>
1772 bool RecursiveASTVisitor<Derived>::TraverseCXXRecordHelper(CXXRecordDecl *D) {
1773 if (!TraverseRecordHelper(D))
1775 if (D->isCompleteDefinition()) {
1776 for (
const auto &
I : D->bases()) {
1777 TRY_TO(TraverseTypeLoc(
I.getTypeSourceInfo()->getTypeLoc()));
1799 if (TypeSourceInfo *TSI = D->getTypeAsWritten()) \
1800 TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
\
1802 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
\
1803 if (!getDerived().shouldVisitTemplateInstantiations() && \
1815 template <typename Derived>
1816 bool RecursiveASTVisitor<Derived>::TraverseTemplateArgumentLocsHelper(
1817 const TemplateArgumentLoc *TAL,
unsigned Count) {
1818 for (
unsigned I = 0;
I < Count; ++
I) {
1819 TRY_TO(TraverseTemplateArgumentLoc(TAL[
I]));
1824 #define DEF_TRAVERSE_TMPL_PART_SPEC_DECL(TMPLDECLKIND, DECLKIND) \
1825 DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplatePartialSpecializationDecl, { \
1827 if (TemplateParameterList *TPL = D->getTemplateParameters()) { \
1828 for (TemplateParameterList::iterator I = TPL->begin(), E = TPL->end(); \
1830 TRY_TO(TraverseDecl(*I)); \
1834 TRY_TO(TraverseTemplateArgumentLocsHelper( \
1835 D->getTemplateArgsAsWritten()->getTemplateArgs(), \
1836 D->getTemplateArgsAsWritten()->NumTemplateArgs)); \
1841 TRY_TO(Traverse##DECLKIND##Helper(D)); \
1854 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1855 TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
1860 template <typename Derived>
1861 bool RecursiveASTVisitor<Derived>::TraverseDeclaratorHelper(DeclaratorDecl *D) {
1862 TRY_TO(TraverseDeclTemplateParameterLists(D));
1863 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1864 if (D->getTypeSourceInfo())
1865 TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1867 TRY_TO(TraverseType(D->getType()));
1872 TRY_TO(TraverseVarHelper(D));
1873 for (
auto *Binding : D->bindings()) {
1874 TRY_TO(TraverseDecl(Binding));
1879 if (getDerived().shouldVisitImplicitCode())
1880 TRY_TO(TraverseStmt(D->getBinding()));
1886 TRY_TO(TraverseDeclaratorHelper(D));
1887 if (D->isBitField())
1888 TRY_TO(TraverseStmt(D->getBitWidth()));
1889 else if (D->hasInClassInitializer())
1890 TRY_TO(TraverseStmt(D->getInClassInitializer()));
1894 TRY_TO(TraverseDeclaratorHelper(D));
1895 if (D->isBitField())
1896 TRY_TO(TraverseStmt(D->getBitWidth()));
1901 TRY_TO(TraverseDeclaratorHelper(D));
1902 if (D->isBitField())
1903 TRY_TO(TraverseStmt(D->getBitWidth()));
1907 template <typename Derived>
1908 bool RecursiveASTVisitor<Derived>::TraverseFunctionHelper(FunctionDecl *D) {
1909 TRY_TO(TraverseDeclTemplateParameterLists(D));
1910 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1911 TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
1918 if (
const FunctionTemplateSpecializationInfo *FTSI =
1919 D->getTemplateSpecializationInfo()) {
1924 if (
const ASTTemplateArgumentListInfo *TALI =
1925 FTSI->TemplateArgumentsAsWritten) {
1926 TRY_TO(TraverseTemplateArgumentLocsHelper(TALI->getTemplateArgs(),
1927 TALI->NumTemplateArgs));
1936 if (TypeSourceInfo *TSI = D->getTypeSourceInfo()) {
1937 TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
1938 }
else if (getDerived().shouldVisitImplicitCode()) {
1943 for (ParmVarDecl *Parameter : D->parameters()) {
1944 TRY_TO(TraverseDecl(Parameter));
1948 if (CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(D)) {
1950 for (
auto *
I : Ctor->inits()) {
1951 TRY_TO(TraverseConstructorInitializer(
I));
1955 if (D->isThisDeclarationADefinition()) {
1956 TRY_TO(TraverseStmt(D->getBody()));
1965 ReturnValue = TraverseFunctionHelper(D);
1972 ReturnValue = TraverseFunctionHelper(D);
1979 ReturnValue = TraverseFunctionHelper(D);
1986 ReturnValue = TraverseFunctionHelper(D);
1995 ReturnValue = TraverseFunctionHelper(D);
2002 ReturnValue = TraverseFunctionHelper(D);
2005 template <typename Derived>
2006 bool RecursiveASTVisitor<Derived>::TraverseVarHelper(VarDecl *D) {
2007 TRY_TO(TraverseDeclaratorHelper(D));
2009 if (!isa<ParmVarDecl>(D) &&
2010 (!D->isCXXForRangeDecl() || getDerived().shouldVisitImplicitCode()))
2011 TRY_TO(TraverseStmt(D->getInit()));
2021 TRY_TO(TraverseDeclaratorHelper(D));
2022 if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
2023 TRY_TO(TraverseStmt(D->getDefaultArgument()));
2027 TRY_TO(TraverseVarHelper(D));
2029 if (D->hasDefaultArg() && D->hasUninstantiatedDefaultArg() &&
2030 !D->hasUnparsedDefaultArg())
2031 TRY_TO(TraverseStmt(D->getUninstantiatedDefaultArg()));
2033 if (D->hasDefaultArg() && !D->hasUninstantiatedDefaultArg() &&
2034 !D->hasUnparsedDefaultArg())
2035 TRY_TO(TraverseStmt(D->getDefaultArg()));
2051 template <typename Derived>
\
2052 bool RecursiveASTVisitor<Derived>::Traverse##
STMT( \
2053 STMT *S, DataRecursionQueue *Queue) {
\
2055 bool ReturnValue =
true;
\
2056 if (!getDerived().shouldTraversePostOrder())
\
2059 if (ShouldVisitChildren) {
\
2060 for (Stmt *SubStmt : S->children()) {
\
2064 if (!Queue && ReturnValue && getDerived().shouldTraversePostOrder())
\
2071 for (
unsigned I = 0, E = S->getNumInputs();
I <
E; ++
I) {
2074 for (
unsigned I = 0, E = S->getNumOutputs();
I <
E; ++
I) {
2077 for (
unsigned I = 0, E = S->getNumClobbers();
I <
E; ++
I) {
2090 TRY_TO(TraverseDecl(S->getExceptionDecl()));
2095 for (
auto *
I : S->decls()) {
2103 ShouldVisitChildren =
false;
2131 if (!getDerived().shouldVisitImplicitCode()) {
2136 ShouldVisitChildren =
false;
2141 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2142 TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2150 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2151 TRY_TO(TraverseDeclarationNameInfo(S->getMemberNameInfo()));
2152 if (S->hasExplicitTemplateArgs()) {
2153 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2154 S->getNumTemplateArgs()));
2159 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2160 TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2161 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2162 S->getNumTemplateArgs()));
2166 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2167 TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2168 if (S->hasExplicitTemplateArgs()) {
2169 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2170 S->getNumTemplateArgs()));
2175 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2176 TRY_TO(TraverseDeclarationNameInfo(S->getMemberNameInfo()));
2177 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2178 S->getNumTemplateArgs()));
2188 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2192 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2196 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2200 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2204 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2208 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2211 template <typename Derived>
2212 bool RecursiveASTVisitor<Derived>::TraverseSynOrSemInitListExpr(
2213 InitListExpr *S, DataRecursionQueue *Queue) {
2217 if (!getDerived().shouldTraversePostOrder())
2218 TRY_TO(WalkUpFromInitListExpr(S));
2221 for (Stmt *SubStmt : S->children()) {
2234 template <
typename Derived>
2235 bool RecursiveASTVisitor<Derived>::TraverseInitListExpr(
2236 InitListExpr *S, DataRecursionQueue *Queue) {
2237 TRY_TO(TraverseSynOrSemInitListExpr(
2238 S->isSemanticForm() ? S->getSyntacticForm() :
S, Queue));
2239 TRY_TO(TraverseSynOrSemInitListExpr(
2240 S->isSemanticForm() ? S : S->getSemanticForm(), Queue));
2248 TRY_TO(TraverseStmt(S->getControllingExpr()));
2249 for (
unsigned i = 0; i != S->getNumAssocs(); ++i) {
2250 if (TypeSourceInfo *TS = S->getAssocTypeSourceInfo(i))
2251 TRY_TO(TraverseTypeLoc(TS->getTypeLoc()));
2254 ShouldVisitChildren =
false;
2262 e = S->semantics_end();
2265 if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(sub))
2266 sub = OVE->getSourceExpr();
2269 ShouldVisitChildren =
false;
2275 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2280 TRY_TO(TraverseTypeLoc(S->getAllocatedTypeSourceInfo()->getTypeLoc()));
2288 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2294 if (S->isArgumentType())
2295 TRY_TO(TraverseTypeLoc(S->getArgumentTypeInfo()->getTypeLoc()));
2301 if (S->isTypeOperand())
2302 TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
2306 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2314 if (S->isTypeOperand())
2315 TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
2319 for (
unsigned I = 0, N = S->getNumArgs();
I != N; ++
I)
2320 TRY_TO(TraverseTypeLoc(S->getArg(
I)->getTypeLoc()));
2324 TRY_TO(TraverseTypeLoc(S->getQueriedTypeSourceInfo()->getTypeLoc()));
2332 TRY_TO(TraverseTypeLoc(S->getWrittenTypeInfo()->getTypeLoc()));
2337 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2342 for (
unsigned I = 0, N = S->capture_size();
I != N; ++
I) {
2343 const LambdaCapture *
C = S->capture_begin() +
I;
2344 if (C->isExplicit() || getDerived().shouldVisitImplicitCode()) {
2345 TRY_TO(TraverseLambdaCapture(S, C, S->capture_init_begin()[
I]));
2349 TypeLoc TL = S->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
2350 FunctionProtoTypeLoc Proto = TL.getAsAdjusted<FunctionProtoTypeLoc>();
2352 if (S->hasExplicitParameters() && S->hasExplicitResultType()) {
2354 TRY_TO(TraverseTypeLoc(TL));
2356 if (S->hasExplicitParameters()) {
2358 for (
unsigned I = 0, N = Proto.getNumParams();
I != N; ++
I) {
2359 TRY_TO(TraverseDecl(Proto.getParam(
I)));
2361 }
else if (S->hasExplicitResultType()) {
2362 TRY_TO(TraverseTypeLoc(Proto.getReturnLoc()));
2365 auto *T = Proto.getTypePtr();
2366 for (
const auto &E : T->exceptions()) {
2370 if (Expr *NE = T->getNoexceptExpr())
2375 ShouldVisitChildren =
false;
2380 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2396 TRY_TO(TraverseDecl(S->getBlockDecl()));
2402 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2408 if (getDerived().shouldVisitImplicitCode())
2409 TRY_TO(TraverseStmt(S->getExpr()));
2420 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2421 if (TypeSourceInfo *ScopeInfo = S->getScopeTypeInfo())
2422 TRY_TO(TraverseTypeLoc(ScopeInfo->getTypeLoc()));
2423 if (TypeSourceInfo *DestroyedTypeInfo = S->getDestroyedTypeInfo())
2424 TRY_TO(TraverseTypeLoc(DestroyedTypeInfo->getTypeLoc()));
2439 if (OpaqueValueExpr *OVE = S->getCommonExpr())
2446 if (TypeSourceInfo *TInfo = S->getEncodedTypeSourceInfo())
2447 TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
2454 if (TypeSourceInfo *TInfo = S->getClassReceiverTypeInfo())
2455 TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
2465 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2476 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2477 if (S->hasExplicitTemplateArgs()) {
2478 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2479 S->getNumTemplateArgs()));
2484 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2485 if (S->hasExplicitTemplateArgs()) {
2486 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2487 S->getNumTemplateArgs()));
2523 if (!getDerived().shouldVisitImplicitCode()) {
2525 ShouldVisitChildren =
false;
2529 if (!getDerived().shouldVisitImplicitCode()) {
2531 ShouldVisitChildren =
false;
2535 if (!getDerived().shouldVisitImplicitCode()) {
2537 ShouldVisitChildren =
false;
2541 if (!getDerived().shouldVisitImplicitCode()) {
2543 ShouldVisitChildren =
false;
2547 if (!getDerived().shouldVisitImplicitCode()) {
2549 ShouldVisitChildren =
false;
2568 template <typename Derived>
2569 bool RecursiveASTVisitor<Derived>::TraverseOMPExecutableDirective(
2570 OMPExecutableDirective *S) {
2571 for (
auto *C : S->clauses()) {
2572 TRY_TO(TraverseOMPClause(C));
2577 template <
typename Derived>
2579 RecursiveASTVisitor<Derived>::TraverseOMPLoopDirective(OMPLoopDirective *S) {
2580 return TraverseOMPExecutableDirective(S);
2584 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2587 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2590 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2593 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2596 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2599 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2602 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2605 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2608 TRY_TO(TraverseDeclarationNameInfo(S->getDirectiveName()));
2609 TRY_TO(TraverseOMPExecutableDirective(S));
2613 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2616 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2619 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2622 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2625 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2628 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2631 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2634 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2637 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2640 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2643 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2646 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2649 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2652 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2655 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2658 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2661 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2664 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2667 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2670 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2673 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2676 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2679 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2682 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2685 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2688 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2691 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2694 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2697 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2700 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2703 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2706 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2709 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2712 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2715 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2718 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2721 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2724 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2727 template <typename Derived>
2728 bool RecursiveASTVisitor<Derived>::TraverseOMPClause(
OMPClause *C) {
2731 switch (C->getClauseKind()) {
2732 #define OPENMP_CLAUSE(Name, Class) \
2734 TRY_TO(Visit##Class(static_cast<Class *>(C))); \
2736 #include "clang/Basic/OpenMPKinds.def"
2745 template <
typename Derived>
2746 bool RecursiveASTVisitor<Derived>::VisitOMPClauseWithPreInit(
2748 TRY_TO(TraverseStmt(Node->getPreInitStmt()));
2752 template <
typename Derived>
2753 bool RecursiveASTVisitor<Derived>::VisitOMPClauseWithPostUpdate(
2754 OMPClauseWithPostUpdate *Node) {
2755 TRY_TO(VisitOMPClauseWithPreInit(Node));
2756 TRY_TO(TraverseStmt(Node->getPostUpdateExpr()));
2760 template <
typename Derived>
2761 bool RecursiveASTVisitor<Derived>::VisitOMPIfClause(OMPIfClause *C) {
2762 TRY_TO(VisitOMPClauseWithPreInit(C));
2763 TRY_TO(TraverseStmt(C->getCondition()));
2767 template <
typename Derived>
2768 bool RecursiveASTVisitor<Derived>::VisitOMPFinalClause(OMPFinalClause *C) {
2769 TRY_TO(TraverseStmt(C->getCondition()));
2773 template <
typename Derived>
2775 RecursiveASTVisitor<Derived>::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) {
2776 TRY_TO(VisitOMPClauseWithPreInit(C));
2777 TRY_TO(TraverseStmt(C->getNumThreads()));
2781 template <
typename Derived>
2782 bool RecursiveASTVisitor<Derived>::VisitOMPSafelenClause(OMPSafelenClause *C) {
2783 TRY_TO(TraverseStmt(C->getSafelen()));
2787 template <
typename Derived>
2788 bool RecursiveASTVisitor<Derived>::VisitOMPSimdlenClause(OMPSimdlenClause *C) {
2789 TRY_TO(TraverseStmt(C->getSimdlen()));
2793 template <
typename Derived>
2795 RecursiveASTVisitor<Derived>::VisitOMPCollapseClause(OMPCollapseClause *C) {
2796 TRY_TO(TraverseStmt(C->getNumForLoops()));
2800 template <
typename Derived>
2801 bool RecursiveASTVisitor<Derived>::VisitOMPDefaultClause(OMPDefaultClause *) {
2805 template <
typename Derived>
2806 bool RecursiveASTVisitor<Derived>::VisitOMPProcBindClause(OMPProcBindClause *) {
2810 template <
typename Derived>
2812 RecursiveASTVisitor<Derived>::VisitOMPScheduleClause(OMPScheduleClause *C) {
2813 TRY_TO(VisitOMPClauseWithPreInit(C));
2814 TRY_TO(TraverseStmt(C->getChunkSize()));
2818 template <
typename Derived>
2819 bool RecursiveASTVisitor<Derived>::VisitOMPOrderedClause(OMPOrderedClause *C) {
2820 TRY_TO(TraverseStmt(C->getNumForLoops()));
2824 template <
typename Derived>
2825 bool RecursiveASTVisitor<Derived>::VisitOMPNowaitClause(OMPNowaitClause *) {
2829 template <
typename Derived>
2830 bool RecursiveASTVisitor<Derived>::VisitOMPUntiedClause(OMPUntiedClause *) {
2834 template <
typename Derived>
2836 RecursiveASTVisitor<Derived>::VisitOMPMergeableClause(OMPMergeableClause *) {
2840 template <
typename Derived>
2841 bool RecursiveASTVisitor<Derived>::VisitOMPReadClause(OMPReadClause *) {
2845 template <
typename Derived>
2846 bool RecursiveASTVisitor<Derived>::VisitOMPWriteClause(OMPWriteClause *) {
2850 template <
typename Derived>
2851 bool RecursiveASTVisitor<Derived>::VisitOMPUpdateClause(OMPUpdateClause *) {
2855 template <
typename Derived>
2856 bool RecursiveASTVisitor<Derived>::VisitOMPCaptureClause(OMPCaptureClause *) {
2860 template <
typename Derived>
2861 bool RecursiveASTVisitor<Derived>::VisitOMPSeqCstClause(OMPSeqCstClause *) {
2865 template <
typename Derived>
2866 bool RecursiveASTVisitor<Derived>::VisitOMPThreadsClause(
OMPThreadsClause *) {
2870 template <
typename Derived>
2871 bool RecursiveASTVisitor<Derived>::VisitOMPSIMDClause(
OMPSIMDClause *) {
2875 template <
typename Derived>
2876 bool RecursiveASTVisitor<Derived>::VisitOMPNogroupClause(
OMPNogroupClause *) {
2880 template <
typename Derived>
2881 template <
typename T>
2882 bool RecursiveASTVisitor<Derived>::VisitOMPClauseList(T *Node) {
2883 for (
auto *E : Node->varlists()) {
2889 template <
typename Derived>
2890 bool RecursiveASTVisitor<Derived>::VisitOMPPrivateClause(OMPPrivateClause *C) {
2891 TRY_TO(VisitOMPClauseList(C));
2892 for (
auto *E : C->private_copies()) {
2898 template <
typename Derived>
2899 bool RecursiveASTVisitor<Derived>::VisitOMPFirstprivateClause(
2900 OMPFirstprivateClause *C) {
2901 TRY_TO(VisitOMPClauseList(C));
2902 TRY_TO(VisitOMPClauseWithPreInit(C));
2903 for (
auto *E : C->private_copies()) {
2906 for (
auto *E : C->inits()) {
2912 template <
typename Derived>
2913 bool RecursiveASTVisitor<Derived>::VisitOMPLastprivateClause(
2914 OMPLastprivateClause *C) {
2915 TRY_TO(VisitOMPClauseList(C));
2916 TRY_TO(VisitOMPClauseWithPostUpdate(C));
2917 for (
auto *E : C->private_copies()) {
2920 for (
auto *E : C->source_exprs()) {
2923 for (
auto *E : C->destination_exprs()) {
2926 for (
auto *E : C->assignment_ops()) {
2932 template <
typename Derived>
2933 bool RecursiveASTVisitor<Derived>::VisitOMPSharedClause(OMPSharedClause *C) {
2934 TRY_TO(VisitOMPClauseList(C));
2938 template <
typename Derived>
2939 bool RecursiveASTVisitor<Derived>::VisitOMPLinearClause(
OMPLinearClause *C) {
2940 TRY_TO(TraverseStmt(C->getStep()));
2941 TRY_TO(TraverseStmt(C->getCalcStep()));
2942 TRY_TO(VisitOMPClauseList(C));
2943 TRY_TO(VisitOMPClauseWithPostUpdate(C));
2944 for (
auto *E : C->privates()) {
2947 for (
auto *E : C->inits()) {
2950 for (
auto *E : C->updates()) {
2953 for (
auto *E : C->finals()) {
2959 template <
typename Derived>
2960 bool RecursiveASTVisitor<Derived>::VisitOMPAlignedClause(
OMPAlignedClause *C) {
2962 TRY_TO(VisitOMPClauseList(C));
2966 template <
typename Derived>
2967 bool RecursiveASTVisitor<Derived>::VisitOMPCopyinClause(
OMPCopyinClause *C) {
2968 TRY_TO(VisitOMPClauseList(C));
2981 template <
typename Derived>
2982 bool RecursiveASTVisitor<Derived>::VisitOMPCopyprivateClause(
2984 TRY_TO(VisitOMPClauseList(C));
2997 template <
typename Derived>
2999 RecursiveASTVisitor<Derived>::VisitOMPReductionClause(OMPReductionClause *C) {
3000 TRY_TO(TraverseNestedNameSpecifierLoc(C->getQualifierLoc()));
3001 TRY_TO(TraverseDeclarationNameInfo(C->getNameInfo()));
3002 TRY_TO(VisitOMPClauseList(C));
3003 TRY_TO(VisitOMPClauseWithPostUpdate(C));
3004 for (
auto *E : C->privates()) {
3007 for (
auto *E : C->lhs_exprs()) {
3010 for (
auto *E : C->rhs_exprs()) {
3013 for (
auto *E : C->reduction_ops()) {
3019 template <
typename Derived>
3020 bool RecursiveASTVisitor<Derived>::VisitOMPTaskReductionClause(
3021 OMPTaskReductionClause *C) {
3022 TRY_TO(TraverseNestedNameSpecifierLoc(C->getQualifierLoc()));
3023 TRY_TO(TraverseDeclarationNameInfo(C->getNameInfo()));
3024 TRY_TO(VisitOMPClauseList(C));
3025 TRY_TO(VisitOMPClauseWithPostUpdate(C));
3026 for (
auto *E : C->privates()) {
3029 for (
auto *E : C->lhs_exprs()) {
3032 for (
auto *E : C->rhs_exprs()) {
3035 for (
auto *E : C->reduction_ops()) {
3041 template <
typename Derived>
3042 bool RecursiveASTVisitor<Derived>::VisitOMPFlushClause(
OMPFlushClause *C) {
3043 TRY_TO(VisitOMPClauseList(C));
3047 template <
typename Derived>
3048 bool RecursiveASTVisitor<Derived>::VisitOMPDependClause(
OMPDependClause *C) {
3049 TRY_TO(VisitOMPClauseList(C));
3053 template <
typename Derived>
3054 bool RecursiveASTVisitor<Derived>::VisitOMPDeviceClause(
OMPDeviceClause *C) {
3059 template <
typename Derived>
3060 bool RecursiveASTVisitor<Derived>::VisitOMPMapClause(
OMPMapClause *C) {
3061 TRY_TO(VisitOMPClauseList(C));
3065 template <
typename Derived>
3066 bool RecursiveASTVisitor<Derived>::VisitOMPNumTeamsClause(
3068 TRY_TO(VisitOMPClauseWithPreInit(C));
3073 template <
typename Derived>
3074 bool RecursiveASTVisitor<Derived>::VisitOMPThreadLimitClause(
3076 TRY_TO(VisitOMPClauseWithPreInit(C));
3081 template <
typename Derived>
3082 bool RecursiveASTVisitor<Derived>::VisitOMPPriorityClause(
3088 template <
typename Derived>
3089 bool RecursiveASTVisitor<Derived>::VisitOMPGrainsizeClause(
3095 template <
typename Derived>
3096 bool RecursiveASTVisitor<Derived>::VisitOMPNumTasksClause(
3102 template <
typename Derived>
3103 bool RecursiveASTVisitor<Derived>::VisitOMPHintClause(
OMPHintClause *C) {
3108 template <
typename Derived>
3109 bool RecursiveASTVisitor<Derived>::VisitOMPDistScheduleClause(
3111 TRY_TO(VisitOMPClauseWithPreInit(C));
3116 template <
typename Derived>
3122 template <
typename Derived>
3123 bool RecursiveASTVisitor<Derived>::VisitOMPToClause(
OMPToClause *C) {
3124 TRY_TO(VisitOMPClauseList(C));
3128 template <
typename Derived>
3129 bool RecursiveASTVisitor<Derived>::VisitOMPFromClause(
OMPFromClause *C) {
3130 TRY_TO(VisitOMPClauseList(C));
3134 template <
typename Derived>
3135 bool RecursiveASTVisitor<Derived>::VisitOMPUseDevicePtrClause(
3137 TRY_TO(VisitOMPClauseList(C));
3141 template <
typename Derived>
3142 bool RecursiveASTVisitor<Derived>::VisitOMPIsDevicePtrClause(
3144 TRY_TO(VisitOMPClauseList(C));
3165 #undef DEF_TRAVERSE_STMT
3166 #undef TRAVERSE_STMT
3167 #undef TRAVERSE_STMT_BASE
3173 #endif // LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
This represents 'thread_limit' clause in the '#pragma omp ...' directive.
bool TraverseLambdaBody(LambdaExpr *LE, DataRecursionQueue *Queue=nullptr)
Recursively visit the body of a lambda expression.
Expr * getSourceExpression() const
This represents clause 'copyin' in the '#pragma omp ...' directives.
A (possibly-)qualified type.
helper_expr_const_range source_exprs() const
#define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND)
Expr *const * semantics_iterator
Stmt - This represents one statement.
C Language Family Type Representation.
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
The template argument is an expression, and we've not resolved it to one of the other forms yet...
#define TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S)
for(unsigned I=0, E=TL.getNumArgs();I!=E;++I)
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
Decl - This represents one declaration (or definition), e.g.
This represents 'grainsize' clause in the '#pragma omp ...' directive.
Defines the C++ template declaration subclasses.
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
This represents 'priority' clause in the '#pragma omp ...' directive.
bool VisitTypeLoc(TypeLoc TL)
The base class of the type hierarchy.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
A container of type source information.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
bool TraverseTemplateName(TemplateName Template)
Recursively visit a template name and dispatch to the appropriate method.
Describes the capture of a variable or of this, or of a C++1y init-capture.
Expr * getAlignment()
Returns alignment.
const TemplateArgumentLoc * getArgumentArray() const
An identifier, stored as an IdentifierInfo*.
TRY_TO(TraverseType(T->getPointeeType()))
Expr * getInit() const
Get the initializer.
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
Derived & getDerived()
Return a reference to the derived class.
Represents an empty template argument, e.g., one that has not been deduced.
This represents 'defaultmap' clause in the '#pragma omp ...' directive.
bool dataTraverseStmtPre(Stmt *S)
Invoked before visiting a statement or expression via data recursion.
A namespace, stored as a NamespaceDecl*.
This represents implicit clause 'flush' for the '#pragma omp flush' directive.
Defines the Objective-C statement AST node classes.
Defines the clang::Expr interface and subclasses for C++ expressions.
SmallVectorImpl< llvm::PointerIntPair< Stmt *, 1, bool > > DataRecursionQueue
A queue used for performing data recursion over statements.
This represents 'nogroup' clause in the '#pragma omp ...' directive.
bool TraverseDecl(Decl *D)
Recursively visit a declaration, by dispatching to Traverse*Decl() based on the argument's dynamic ty...
Base wrapper for a particular "section" of type source info.
DeclarationName getName() const
getName - Returns the embedded declaration name.
return(__x >> __y)|(__x<< (32-__y))
A C++ nested-name-specifier augmented with source location information.
Represents a dependent template name that cannot be resolved prior to template instantiation.
This represents 'simd' clause in the '#pragma omp ...' directive.
bool shouldTraversePostOrder() const
Return whether this visitor should traverse post-order.
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
#define TYPE(CLASS, BASE)
bool shouldVisitTemplateInstantiations() const
Return whether this visitor should recurse into template instantiations.
Expr * getChunkSize()
Get chunk size.
This represents clause 'map' in the '#pragma omp ...' directives.
This represents clause 'to' in the '#pragma omp ...' directives.
Defines some OpenMP-specific enums and functions.
bool TraverseSynOrSemInitListExpr(InitListExpr *S, DataRecursionQueue *Queue=nullptr)
Recursively visit the syntactic or semantic form of an initialization list.
Wrapper of type source information for a type with no direct qualifiers.
TypeSourceInfo * getTypeSourceInfo() const
Expr * getNumTeams()
Return NumTeams number.
TypeSourceInfo * getNamedTypeInfo() const
getNamedTypeInfo - Returns the source type info associated to the name.
#define TRY_TO(CALL_EXPR)
#define DEF_TRAVERSE_TMPL_DECL(TMPLDECLKIND)
This represents clause 'copyprivate' in the '#pragma omp ...' directives.
Describes an C or C++ initializer list.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
A convenient class for passing around template argument information.
NamedDecl ** iterator
Iterates through the template parameters in this list.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
bool TraverseDeclarationNameInfo(DeclarationNameInfo NameInfo)
Recursively visit a name with its location information.
NestedNameSpecifierLoc getTemplateQualifierLoc() const
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
bool WalkUpFromType(Type *T)
TypeClass getTypeClass() const
VarDecl * getCapturedVar() const
Retrieve the declaration of the local variable being captured.
CompoundStmt * getBody() const
Retrieve the body of the lambda.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
bool WalkUpFromStmt(Stmt *S)
This represents clause 'is_device_ptr' in the '#pragma omp ...' directives.
A class that does preordor or postorder depth-first traversal on the entire Clang AST and visits each...
#define DEF_TRAVERSE_TMPL_PART_SPEC_DECL(TMPLDECLKIND, DECLKIND)
Expr * getHint() const
Returns number of threads.
bool isWritten() const
Determine whether this initializer is explicitly written in the source code.
detail::InMemoryDirectory::const_iterator I
This represents clause 'from' in the '#pragma omp ...' directives.
bool WalkUpFromTypeLoc(TypeLoc TL)
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
OMPLinearClause(SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, unsigned NumVars)
Build 'linear' clause with given number of variables NumVars.
This represents 'threads' clause in the '#pragma omp ...' directive.
This represents clause 'aligned' in the '#pragma omp ...' directives.
DEF_TRAVERSE_DECL(BlockDecl,{if(TypeSourceInfo *TInfo=D->getSignatureAsWritten()) TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));TRY_TO(TraverseStmt(D->getBody()));for(const auto &I:D->captures()){if(I.hasCopyExpr()){TRY_TO(TraverseStmt(I.getCopyExpr()));}}ShouldVisitChildren=false;}) DEF_TRAVERSE_DECL(CapturedDecl
DEF_TRAVERSE_TYPE(ComplexType,{TRY_TO(TraverseType(T->getElementType()));}) DEF_TRAVERSE_TYPE(PointerType
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
This represents implicit clause 'depend' for the '#pragma omp task' directive.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
Expr - This represents one expression.
bool TraverseConstructorInitializer(CXXCtorInitializer *Init)
Recursively visit a constructor initializer.
helper_expr_const_range assignment_ops() const
bool WalkUpFromDecl(Decl *D)
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
bool WalkUpFromQualifiedTypeLoc(QualifiedTypeLoc TL)
bool shouldVisitImplicitCode() const
Return whether this visitor should recurse into implicit code, e.g., implicit constructors and destru...
ArgKind getKind() const
Return the kind of stored template argument.
bool VisitQualifiedTypeLoc(QualifiedTypeLoc TL)
Represents a C++ template name within the type system.
Defines the clang::TypeLoc interface and its subclasses.
A namespace alias, stored as a NamespaceAliasDecl*.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
Expr * getDevice()
Return device number.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
This template specialization was implicitly instantiated from a template.
A type, stored as a Type*.
DEF_TRAVERSE_TYPELOC(ComplexType,{TRY_TO(TraverseType(TL.getTypePtr() ->getElementType()));}) DEF_TRAVERSE_TYPELOC(PointerType
return TraverseArrayTypeLocHelper(TL)
This file defines OpenMP AST classes for clauses.
helper_expr_const_range destination_exprs() const
bool WalkUpFromUnqualTypeLoc(UnqualTypeLoc TL)
This represents 'num_teams' clause in the '#pragma omp ...' directive.
This represents 'hint' clause in the '#pragma omp ...' directive.
bool TraverseTypeLoc(TypeLoc TL)
Recursively visit a type with location, by dispatching to Traverse*TypeLoc() based on the argument ty...
#define TRAVERSE_STMT_BASE(NAME, CLASS, VAR, QUEUE)
bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Recursively visit a C++ nested-name-specifier with location information.
Expr * getPriority()
Return Priority number.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
This file defines OpenMP nodes for declarative directives.
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
bool TraverseStmt(Stmt *S, DataRecursionQueue *Queue=nullptr)
Recursively visit a statement or expression, by dispatching to Traverse*() based on the argument's dy...
TypeLocClass getTypeLocClass() const
This template specialization was instantiated from a template due to an explicit instantiation defini...
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
Expr * getGrainsize() const
Return safe iteration space distance.
bool TraverseType(QualType T)
Recursively visit a type, by dispatching to Traverse*Type() based on the argument's getTypeClass() pr...
bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C, Expr *Init)
Recursively visit a lambda capture.
Defines various enumerations that describe declaration and type specifiers.
ast_type_traits::DynTypedNode Node
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
Represents a template argument.
QualType getAsType() const
Retrieve the type for a type template argument.
Represents a template name that was expressed as a qualified name.
TypeSourceInfo * getTypeSourceInfo() const
Returns the declarator information for a base class or delegating initializer.
This represents 'device' clause in the '#pragma omp ...' directive.
The template argument is a pack expansion of a template name that was provided for a template templat...
#define DEF_TRAVERSE_TMPL_INST(TMPLDECLKIND)
This template specialization was instantiated from a template due to an explicit instantiation declar...
Expr * getNumTasks() const
Return safe iteration space distance.
detail::InMemoryDirectory::const_iterator E
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
A type that was preceded by the 'template' keyword, stored as a Type*.
Location wrapper for a TemplateArgument.
This file defines OpenMP AST classes for executable directives and clauses.
bool TraverseTemplateArgument(const TemplateArgument &Arg)
Recursively visit a template argument and dispatch to the appropriate method for the argument type...
Represents a C++ base or member initializer.
This template specialization was declared or defined by an explicit specialization (C++ [temp...
UnqualTypeLoc getUnqualifiedLoc() const
The template argument is a type.
bool TraverseNestedNameSpecifier(NestedNameSpecifier *NNS)
Recursively visit a C++ nested-name-specifier.
The template argument is actually a parameter pack.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
helper_expr_const_range destination_exprs() const
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
unsigned pack_size() const
The number of template arguments in the given template argument pack.
This represents 'num_tasks' clause in the '#pragma omp ...' directive.
The template argument is a template name that was provided for a template template parameter...
bool dataTraverseStmtPost(Stmt *S)
Invoked after visiting a statement or expression via data recursion.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
Expr * getThreadLimit()
Return ThreadLimit number.
bool TraverseTemplateArguments(const TemplateArgument *Args, unsigned NumArgs)
Recursively visit a set of template arguments.
#define DEF_TRAVERSE_STMT(STMT, CODE)
This represents 'dist_schedule' clause in the '#pragma omp ...' directive.
bool TraverseAttr(Attr *At)
Recursively visit an attribute, by dispatching to Traverse*Attr() based on the argument's dynamic typ...
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
bool VisitUnqualTypeLoc(UnqualTypeLoc TL)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
The global specifier '::'. There is no stored value.
bool shouldWalkTypesOfTypeLocs() const
Return whether this visitor should recurse into the types of TypeLocs.
const TemplateArgument & getArgument() const
bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc)
Recursively visit a template argument location and dispatch to the appropriate method for the argumen...
Attr - This represents one attribute.
This represents clause 'use_device_ptr' in the '#pragma omp ...' directives.
helper_expr_const_range assignment_ops() const
Defines the LambdaCapture class.
#define STMT(CLASS, PARENT)
helper_expr_const_range source_exprs() const