14 #ifndef LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
15 #define LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
17 #include <type_traits>
44 #define UNARYOP_LIST() \
45 OPERATOR(PostInc) OPERATOR(PostDec) OPERATOR(PreInc) OPERATOR(PreDec) \
46 OPERATOR(AddrOf) OPERATOR(Deref) OPERATOR(Plus) OPERATOR(Minus) \
47 OPERATOR(Not) OPERATOR(LNot) OPERATOR(Real) OPERATOR(Imag) \
48 OPERATOR(Extension) OPERATOR(Coawait)
51 #define BINOP_LIST() \
52 OPERATOR(PtrMemD) OPERATOR(PtrMemI) OPERATOR(Mul) OPERATOR(Div) \
53 OPERATOR(Rem) OPERATOR(Add) OPERATOR(Sub) OPERATOR(Shl) OPERATOR(Shr) \
54 OPERATOR(LT) OPERATOR(GT) OPERATOR(LE) OPERATOR(GE) OPERATOR(EQ) \
55 OPERATOR(NE) OPERATOR(And) OPERATOR(Xor) OPERATOR(Or) OPERATOR(LAnd) \
56 OPERATOR(LOr) OPERATOR(Assign) OPERATOR(Comma)
60 OPERATOR(Mul) OPERATOR(Div) OPERATOR(Rem) OPERATOR(Add) OPERATOR(Sub) \
61 OPERATOR(Shl) OPERATOR(Shr) OPERATOR(And) OPERATOR(Or) OPERATOR(Xor)
69 #define TRY_TO(CALL_EXPR) \
71 if (!getDerived().CALL_EXPR) \
145 Derived &
getDerived() {
return *
static_cast<Derived *
>(
this); }
272 #define ATTR_VISITOR_DECLS_ONLY
273 #include "clang/AST/AttrVisitor.inc"
274 #undef ATTR_VISITOR_DECLS_ONLY
279 template<
typename T,
typename U>
280 struct has_same_member_pointer_type : std::false_type {};
281 template<
typename T,
typename U,
typename R,
typename...
P>
282 struct has_same_member_pointer_type<R (T::*)(P...), R (U::*)(P...)>
290 #define TRAVERSE_STMT_BASE(NAME, CLASS, VAR, QUEUE) \
291 (has_same_member_pointer_type<decltype( \
292 &RecursiveASTVisitor::Traverse##NAME), \
293 decltype(&Derived::Traverse##NAME)>::value \
294 ? static_cast<typename std::conditional< \
295 has_same_member_pointer_type< \
296 decltype(&RecursiveASTVisitor::Traverse##NAME), \
297 decltype(&Derived::Traverse##NAME)>::value, \
298 Derived &, RecursiveASTVisitor &>::type>(*this) \
299 .Traverse##NAME(static_cast<CLASS *>(VAR), QUEUE) \
300 : getDerived().Traverse##NAME(static_cast<CLASS *>(VAR)))
305 #define TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S) \
307 if (!TRAVERSE_STMT_BASE(Stmt, Stmt, S, Queue)) \
313 #define ABSTRACT_STMT(STMT)
314 #define STMT(CLASS, PARENT) \
315 bool Traverse##CLASS(CLASS *S, DataRecursionQueue *Queue = nullptr);
316 #include "clang/AST/StmtNodes.inc"
322 #define STMT(CLASS, PARENT) \
323 bool WalkUpFrom##CLASS(CLASS *S) { \
324 TRY_TO(WalkUpFrom##PARENT(S)); \
325 TRY_TO(Visit##CLASS(S)); \
328 bool Visit##CLASS(CLASS *S) { return true; }
329 #include "clang/AST/StmtNodes.inc"
334 #define OPERATOR(NAME) \
335 bool TraverseUnary##NAME(UnaryOperator *S, \
336 DataRecursionQueue *Queue = nullptr) { \
337 TRY_TO(WalkUpFromUnary##NAME(S)); \
338 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr()); \
341 bool WalkUpFromUnary##NAME(UnaryOperator *S) { \
342 TRY_TO(WalkUpFromUnaryOperator(S)); \
343 TRY_TO(VisitUnary##NAME(S)); \
346 bool VisitUnary##NAME(UnaryOperator *S) { return true; }
354 #define GENERAL_BINOP_FALLBACK(NAME, BINOP_TYPE) \
355 bool TraverseBin##NAME(BINOP_TYPE *S, DataRecursionQueue *Queue = nullptr) { \
356 TRY_TO(WalkUpFromBin##NAME(S)); \
357 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLHS()); \
358 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRHS()); \
361 bool WalkUpFromBin##NAME(BINOP_TYPE *S) { \
362 TRY_TO(WalkUpFrom##BINOP_TYPE(S)); \
363 TRY_TO(VisitBin##NAME(S)); \
366 bool VisitBin##NAME(BINOP_TYPE *S) { return true; }
368 #define OPERATOR(NAME) GENERAL_BINOP_FALLBACK(NAME, BinaryOperator)
376 #define OPERATOR(NAME) \
377 GENERAL_BINOP_FALLBACK(NAME##Assign, CompoundAssignOperator)
381 #undef GENERAL_BINOP_FALLBACK
387 #define ABSTRACT_TYPE(CLASS, BASE)
388 #define TYPE(CLASS, BASE) bool Traverse##CLASS##Type(CLASS##Type *T);
389 #include "clang/AST/TypeNodes.def"
395 #define TYPE(CLASS, BASE) \
396 bool WalkUpFrom##CLASS##Type(CLASS##Type *T) { \
397 TRY_TO(WalkUpFrom##BASE(T)); \
398 TRY_TO(Visit##CLASS##Type(T)); \
401 bool Visit##CLASS##Type(CLASS##Type *T) { return true; }
402 #include "clang/AST/TypeNodes.def"
408 #define ABSTRACT_TYPELOC(CLASS, BASE)
409 #define TYPELOC(CLASS, BASE) bool Traverse##CLASS##TypeLoc(CLASS##TypeLoc TL);
410 #include "clang/AST/TypeLocNodes.def"
429 #define TYPE(CLASS, BASE) \
430 bool WalkUpFrom##CLASS##TypeLoc(CLASS##TypeLoc TL) { \
431 TRY_TO(WalkUpFrom##BASE##Loc(TL)); \
432 TRY_TO(Visit##CLASS##TypeLoc(TL)); \
435 bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TL) { return true; }
436 #include "clang/AST/TypeNodes.def"
441 #define ABSTRACT_DECL(DECL)
442 #define DECL(CLASS, BASE) bool Traverse##CLASS##Decl(CLASS##Decl *D);
443 #include "clang/AST/DeclNodes.inc"
449 #define DECL(CLASS, BASE) \
450 bool WalkUpFrom##CLASS##Decl(CLASS##Decl *D) { \
451 TRY_TO(WalkUpFrom##BASE(D)); \
452 TRY_TO(Visit##CLASS##Decl(D)); \
455 bool Visit##CLASS##Decl(CLASS##Decl *D) { return true; }
456 #include "clang/AST/DeclNodes.inc"
460 bool TraverseTemplateParameterListHelper(TemplateParameterList *TPL);
461 #define DEF_TRAVERSE_TMPL_INST(TMPLDECLKIND) \
462 bool TraverseTemplateInstantiations(TMPLDECLKIND##TemplateDecl *D);
466 #undef DEF_TRAVERSE_TMPL_INST
467 bool TraverseTemplateArgumentLocsHelper(
const TemplateArgumentLoc *TAL,
469 bool TraverseArrayTypeLocHelper(ArrayTypeLoc TL);
470 bool TraverseRecordHelper(RecordDecl *D);
471 bool TraverseCXXRecordHelper(CXXRecordDecl *D);
472 bool TraverseDeclaratorHelper(DeclaratorDecl *D);
473 bool TraverseDeclContextHelper(DeclContext *DC);
474 bool TraverseFunctionHelper(FunctionDecl *D);
475 bool TraverseVarHelper(VarDecl *D);
476 bool TraverseOMPExecutableDirective(OMPExecutableDirective *
S);
477 bool TraverseOMPLoopDirective(OMPLoopDirective *
S);
479 #define OPENMP_CLAUSE(Name, Class) bool Visit##Class(Class *C);
480 #include "clang/Basic/OpenMPKinds.def"
482 template <
typename T>
bool VisitOMPClauseList(T *
Node);
487 template <
typename Derived>
488 bool RecursiveASTVisitor<Derived>::dataTraverseNode(
Stmt *
S,
489 DataRecursionQueue *Queue) {
490 #define DISPATCH_STMT(NAME, CLASS, VAR) \
491 return TRAVERSE_STMT_BASE(NAME, CLASS, VAR, Queue);
496 if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(S)) {
497 switch (BinOp->getOpcode()) {
498 #define OPERATOR(NAME) \
500 DISPATCH_STMT(Bin##NAME, BinaryOperator, S);
506 #define OPERATOR(NAME) \
507 case BO_##NAME##Assign: \
508 DISPATCH_STMT(Bin##NAME##Assign, CompoundAssignOperator, S);
514 }
else if (UnaryOperator *UnOp = dyn_cast<UnaryOperator>(S)) {
515 switch (UnOp->getOpcode()) {
516 #define OPERATOR(NAME) \
518 DISPATCH_STMT(Unary##NAME, UnaryOperator, S);
527 switch (S->getStmtClass()) {
528 case Stmt::NoStmtClass:
530 #define ABSTRACT_STMT(STMT)
531 #define STMT(CLASS, PARENT) \
532 case Stmt::CLASS##Class: \
533 DISPATCH_STMT(CLASS, CLASS, S);
534 #include "clang/AST/StmtNodes.inc"
542 template <
typename Derived>
554 LocalQueue.push_back(S);
556 while (!LocalQueue.empty()) {
557 Stmt *CurrS = LocalQueue.pop_back_val();
559 size_t N = LocalQueue.size();
560 TRY_TO(dataTraverseNode(CurrS, &LocalQueue));
562 std::reverse(LocalQueue.begin() + N, LocalQueue.end());
568 #define DISPATCH(NAME, CLASS, VAR) \
569 return getDerived().Traverse##NAME(static_cast<CLASS *>(VAR))
571 template <
typename Derived>
577 #define ABSTRACT_TYPE(CLASS, BASE)
578 #define TYPE(CLASS, BASE) \
580 DISPATCH(CLASS##Type, CLASS##Type, const_cast<Type *>(T.getTypePtr()));
581 #include "clang/AST/TypeNodes.def"
587 template <
typename Derived>
593 #define ABSTRACT_TYPELOC(CLASS, BASE)
594 #define TYPELOC(CLASS, BASE) \
595 case TypeLoc::CLASS: \
596 return getDerived().Traverse##CLASS##TypeLoc(TL.castAs<CLASS##TypeLoc>());
597 #include "clang/AST/TypeLocNodes.def"
604 #define VISITORCLASS RecursiveASTVisitor
605 #include "clang/AST/AttrVisitor.inc"
608 template <
typename Derived>
615 if (!getDerived().shouldVisitImplicitCode() && D->
isImplicit())
619 #define ABSTRACT_DECL(DECL)
620 #define DECL(CLASS, BASE) \
622 if (!getDerived().Traverse##CLASS##Decl(static_cast<CLASS##Decl *>(D))) \
625 #include "clang/AST/DeclNodes.inc"
629 for (
auto *
I : D->
attrs()) {
630 if (!getDerived().TraverseAttr(
I))
638 template <
typename Derived>
663 template <
typename Derived>
670 TRY_TO(TraverseNestedNameSpecifierLoc(Prefix));
689 template <
typename Derived>
697 TRY_TO(TraverseTypeLoc(TSInfo->getTypeLoc()));
714 template <
typename Derived>
717 TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier()));
719 TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
724 template <
typename Derived>
735 return getDerived().TraverseType(Arg.
getAsType());
739 return getDerived().TraverseTemplateName(
743 return getDerived().TraverseStmt(Arg.
getAsExpr());
746 return getDerived().TraverseTemplateArguments(Arg.
pack_begin(),
755 template <
typename Derived>
770 return getDerived().TraverseTypeLoc(TSI->getTypeLoc());
772 return getDerived().TraverseType(Arg.
getAsType());
778 TRY_TO(getDerived().TraverseNestedNameSpecifierLoc(
780 return getDerived().TraverseTemplateName(
787 return getDerived().TraverseTemplateArguments(Arg.
pack_begin(),
794 template <
typename Derived>
798 TRY_TO(TraverseTemplateArgument(Args[
I]));
804 template <
typename Derived>
808 TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
810 if (Init->
isWritten() || getDerived().shouldVisitImplicitCode())
815 template <
typename Derived>
824 template <
typename Derived>
834 #define DEF_TRAVERSE_TYPE(TYPE, CODE) \
835 template <typename Derived> \
836 bool RecursiveASTVisitor<Derived>::Traverse##TYPE(TYPE *T) { \
837 TRY_TO(WalkUpFrom##TYPE(T)); \
849 {
TRY_TO(TraverseType(T->getPointeeType())); })
852 {
TRY_TO(TraverseType(T->getPointeeType())); })
855 {
TRY_TO(TraverseType(T->getPointeeType())); })
858 TRY_TO(TraverseType(QualType(T->getClass(), 0)));
859 TRY_TO(TraverseType(T->getPointeeType()));
867 {
TRY_TO(TraverseType(T->getElementType())); })
870 {
TRY_TO(TraverseType(T->getElementType())); })
873 TRY_TO(TraverseType(T->getElementType()));
874 TRY_TO(TraverseStmt(T->getSizeExpr()));
878 TRY_TO(TraverseType(T->getElementType()));
879 if (T->getSizeExpr())
880 TRY_TO(TraverseStmt(T->getSizeExpr()));
884 if (T->getSizeExpr())
885 TRY_TO(TraverseStmt(T->getSizeExpr()));
886 TRY_TO(TraverseType(T->getElementType()));
894 {
TRY_TO(TraverseType(T->getReturnType())); })
897 TRY_TO(TraverseType(T->getReturnType()));
899 for (
const auto &A : T->param_types()) {
903 for (
const auto &
E : T->exceptions()) {
907 if (Expr *NE = T->getNoexceptExpr())
915 {
TRY_TO(TraverseStmt(T->getUnderlyingExpr())); })
920 {
TRY_TO(TraverseStmt(T->getUnderlyingExpr())); })
923 TRY_TO(TraverseType(T->getBaseType()));
924 TRY_TO(TraverseType(T->getUnderlyingType()));
936 TRY_TO(TraverseTemplateName(T->getTemplateName()));
937 TRY_TO(TraverseTemplateArguments(T->getArgs(), T->getNumArgs()));
943 {
TRY_TO(TraverseType(T->getModifiedType())); })
948 if (T->getQualifier()) {
949 TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
951 TRY_TO(TraverseType(T->getNamedType()));
955 {
TRY_TO(TraverseNestedNameSpecifier(T->getQualifier())); })
958 TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
959 TRY_TO(TraverseTemplateArguments(T->getArgs(), T->getNumArgs()));
969 if (T->getBaseType().getTypePtr() != T)
970 TRY_TO(TraverseType(T->getBaseType()));
971 for (
auto typeArg : T->getTypeArgsAsWritten()) {
972 TRY_TO(TraverseType(typeArg));
977 {
TRY_TO(TraverseType(T->getPointeeType())); })
993 template <typename Derived>
\
994 bool RecursiveASTVisitor<Derived>::Traverse##
TYPE##Loc(
TYPE##Loc TL) {
\
995 if (getDerived().shouldWalkTypesOfTypeLocs())
\
996 TRY_TO(WalkUpFrom##
TYPE(const_cast<TYPE *>(TL.getTypePtr())));
\
1002 template <
typename Derived>
1004 RecursiveASTVisitor<Derived>::TraverseQualifiedTypeLoc(QualifiedTypeLoc TL) {
1020 return TraverseTypeLoc(TL.getUnqualifiedLoc());
1027 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1031 {
TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1034 {
TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1037 {
TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1040 {
TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1046 TRY_TO(TraverseType(QualType(TL.getTypePtr()->getClass(), 0)));
1047 TRY_TO(TraverseTypeLoc(TL.getPointeeLoc()));
1051 {
TRY_TO(TraverseTypeLoc(TL.getOriginalLoc())); })
1054 {
TRY_TO(TraverseTypeLoc(TL.getOriginalLoc())); })
1056 template <typename Derived>
1059 TRY_TO(TraverseStmt(TL.getSizeExpr()));
1064 TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1069 TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1074 TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1079 TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1086 if (TL.getTypePtr()->getSizeExpr())
1087 TRY_TO(TraverseStmt(TL.getTypePtr()->getSizeExpr()));
1088 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1093 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1099 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1103 {
TRY_TO(TraverseTypeLoc(TL.getReturnLoc())); })
1107 TRY_TO(TraverseTypeLoc(TL.getReturnLoc()));
1109 const FunctionProtoType *T = TL.getTypePtr();
1111 for (
unsigned I = 0,
E = TL.getNumParams();
I !=
E; ++
I) {
1112 if (TL.getParam(
I)) {
1113 TRY_TO(TraverseDecl(TL.getParam(
I)));
1114 }
else if (I < T->getNumParams()) {
1115 TRY_TO(TraverseType(T->getParamType(
I)));
1119 for (
const auto &
E : T->exceptions()) {
1123 if (Expr *NE = T->getNoexceptExpr())
1124 TRY_TO(TraverseStmt(NE));
1131 {
TRY_TO(TraverseStmt(TL.getUnderlyingExpr())); })
1134 TRY_TO(TraverseTypeLoc(TL.getUnderlyingTInfo()->getTypeLoc()));
1139 TRY_TO(TraverseStmt(TL.getTypePtr()->getUnderlyingExpr()));
1143 TRY_TO(TraverseTypeLoc(TL.getUnderlyingTInfo()->getTypeLoc()));
1147 TRY_TO(TraverseType(TL.getTypePtr()->getDeducedType()));
1158 TRY_TO(TraverseTemplateName(TL.getTypePtr()->getTemplateName()));
1159 for (
unsigned I = 0,
E = TL.getNumArgs();
I !=
E; ++
I) {
1160 TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(
I)));
1169 {
TRY_TO(TraverseTypeLoc(TL.getModifiedLoc())); })
1172 if (TL.getQualifierLoc()) {
1173 TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1175 TRY_TO(TraverseTypeLoc(TL.getNamedTypeLoc()));
1179 TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1183 if (TL.getQualifierLoc()) {
1184 TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1187 for (
unsigned I = 0,
E = TL.getNumArgs();
I !=
E; ++
I) {
1188 TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(
I)));
1193 {
TRY_TO(TraverseTypeLoc(TL.getPatternLoc())); })
1200 if (TL.getTypePtr()->getBaseType().getTypePtr() != TL.getTypePtr())
1201 TRY_TO(TraverseTypeLoc(TL.getBaseLoc()));
1202 for (
unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
1203 TRY_TO(TraverseTypeLoc(TL.getTypeArgTInfo(i)->getTypeLoc()));
1207 {
TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1222 template <typename Derived>
1223 bool RecursiveASTVisitor<Derived>::TraverseDeclContextHelper(DeclContext *DC) {
1227 for (
auto *Child : DC->decls()) {
1230 if (!isa<BlockDecl>(Child) && !isa<CapturedDecl>(Child))
1231 TRY_TO(TraverseDecl(Child));
1238 #define DEF_TRAVERSE_DECL(DECL, CODE) \
1239 template <typename Derived> \
1240 bool RecursiveASTVisitor<Derived>::Traverse##DECL(DECL *D) { \
1241 TRY_TO(WalkUpFrom##DECL(D)); \
1243 TRY_TO(TraverseDeclContextHelper(dyn_cast<DeclContext>(D))); \
1250 if (TypeSourceInfo *TInfo = D->getSignatureAsWritten())
1251 TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
1252 TRY_TO(TraverseStmt(D->getBody()));
1253 for (
const auto &
I : D->captures()) {
1254 if (
I.hasCopyExpr()) {
1255 TRY_TO(TraverseStmt(
I.getCopyExpr()));
1265 TRY_TO(TraverseStmt(D->getBody()));
1275 {
TRY_TO(TraverseStmt(D->getAsmString())); })
1281 if (D->getFriendType())
1282 TRY_TO(TraverseTypeLoc(D->getFriendType()->getTypeLoc()));
1284 TRY_TO(TraverseDecl(D->getFriendDecl()));
1288 if (D->getFriendType())
1289 TRY_TO(TraverseTypeLoc(D->getFriendType()->getTypeLoc()));
1291 TRY_TO(TraverseDecl(D->getFriendDecl()));
1292 for (
unsigned I = 0,
E = D->getNumTemplateParameters();
I <
E; ++
I) {
1293 TemplateParameterList *TPL = D->getTemplateParameterList(
I);
1295 ITPL != ETPL; ++ITPL) {
1296 TRY_TO(TraverseDecl(*ITPL));
1302 TRY_TO(TraverseDecl(D->getSpecialization()));
1304 if (D->hasExplicitTemplateArgs()) {
1305 const TemplateArgumentListInfo &args = D->templateArgs();
1306 TRY_TO(TraverseTemplateArgumentLocsHelper(args.getArgumentArray(),
1317 TRY_TO(TraverseStmt(D->getAssertExpr()));
1318 TRY_TO(TraverseStmt(D->getMessage()));
1322 TranslationUnitDecl,
1331 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1356 if (ObjCTypeParamList *typeParamList = D->getTypeParamList()) {
1357 for (
auto typeParam : *typeParamList) {
1358 TRY_TO(TraverseObjCTypeParamDecl(typeParam));
1370 if (ObjCTypeParamList *typeParamList = D->getTypeParamListAsWritten()) {
1371 for (
auto typeParam : *typeParamList) {
1372 TRY_TO(TraverseObjCTypeParamDecl(typeParam));
1376 if (TypeSourceInfo *superTInfo = D->getSuperClassTInfo()) {
1377 TRY_TO(TraverseTypeLoc(superTInfo->getTypeLoc()));
1385 if (D->getReturnTypeSourceInfo()) {
1386 TRY_TO(TraverseTypeLoc(D->getReturnTypeSourceInfo()->getTypeLoc()));
1392 if (D->isThisDeclarationADefinition()) {
1393 TRY_TO(TraverseStmt(D->getBody()));
1399 if (D->hasExplicitBound()) {
1400 TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1408 if (D->getTypeSourceInfo())
1409 TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1411 TRY_TO(TraverseType(D->getType()));
1416 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1417 TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
1421 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1427 for (
auto *
I : D->varlists()) {
1433 template <typename Derived>
1434 bool RecursiveASTVisitor<Derived>::TraverseTemplateParameterListHelper(
1435 TemplateParameterList *TPL) {
1445 template <
typename Derived>
1446 bool RecursiveASTVisitor<Derived>::TraverseTemplateInstantiations(
1447 ClassTemplateDecl *D) {
1448 for (
auto *SD : D->specializations()) {
1449 for (
auto *RD : SD->redecls()) {
1451 if (cast<CXXRecordDecl>(RD)->isInjectedClassName())
1455 cast<ClassTemplateSpecializationDecl>(RD)->getSpecializationKind()) {
1459 TRY_TO(TraverseDecl(RD));
1476 template <
typename Derived>
1477 bool RecursiveASTVisitor<Derived>::TraverseTemplateInstantiations(
1478 VarTemplateDecl *D) {
1479 for (
auto *SD : D->specializations()) {
1480 for (
auto *RD : SD->redecls()) {
1482 cast<VarTemplateSpecializationDecl>(RD)->getSpecializationKind()) {
1485 TRY_TO(TraverseDecl(RD));
1501 template <
typename Derived>
1502 bool RecursiveASTVisitor<Derived>::TraverseTemplateInstantiations(
1503 FunctionTemplateDecl *D) {
1504 for (
auto *FD : D->specializations()) {
1505 for (
auto *RD : FD->redecls()) {
1506 switch (RD->getTemplateSpecializationKind()) {
1510 TRY_TO(TraverseDecl(RD));
1517 TRY_TO(TraverseDecl(RD));
1531 #define DEF_TRAVERSE_TMPL_DECL(TMPLDECLKIND) \
1532 DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateDecl, { \
1533 TRY_TO(TraverseDecl(D->getTemplatedDecl())); \
1534 TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \
1542 if (getDerived().shouldVisitTemplateInstantiations() && \
1543 D == D->getCanonicalDecl()) \
1544 TRY_TO(TraverseTemplateInstantiations(D)); \
1558 TRY_TO(TraverseDecl(D->getTemplatedDecl()));
1559 if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) {
1560 TRY_TO(TraverseTemplateArgumentLoc(D->getDefaultArgument()));
1562 TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1566 TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1571 if (D->getTypeForDecl())
1572 TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
1573 if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
1574 TRY_TO(TraverseTypeLoc(D->getDefaultArgumentInfo()->getTypeLoc()));
1578 TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1585 TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1592 TRY_TO(TraverseDecl(D->getTemplatedDecl()));
1593 TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1599 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1606 if (D->getTypeForDecl())
1607 TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
1609 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1615 template <typename Derived>
1616 bool RecursiveASTVisitor<Derived>::TraverseRecordHelper(RecordDecl *D) {
1620 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1624 template <
typename Derived>
1625 bool RecursiveASTVisitor<Derived>::TraverseCXXRecordHelper(CXXRecordDecl *D) {
1626 if (!TraverseRecordHelper(D))
1628 if (D->isCompleteDefinition()) {
1629 for (
const auto &
I : D->bases()) {
1630 TRY_TO(TraverseTypeLoc(
I.getTypeSourceInfo()->getTypeLoc()));
1652 if (TypeSourceInfo *TSI = D->getTypeAsWritten()) \
1653 TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
\
1655 if (!getDerived().shouldVisitTemplateInstantiations() && \
1667 template <typename Derived>
1668 bool RecursiveASTVisitor<Derived>::TraverseTemplateArgumentLocsHelper(
1669 const TemplateArgumentLoc *TAL,
unsigned Count) {
1670 for (
unsigned I = 0;
I <
Count; ++
I) {
1671 TRY_TO(TraverseTemplateArgumentLoc(TAL[
I]));
1676 #define DEF_TRAVERSE_TMPL_PART_SPEC_DECL(TMPLDECLKIND, DECLKIND) \
1677 DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplatePartialSpecializationDecl, { \
1679 if (TemplateParameterList *TPL = D->getTemplateParameters()) { \
1680 for (TemplateParameterList::iterator I = TPL->begin(), E = TPL->end(); \
1682 TRY_TO(TraverseDecl(*I)); \
1686 TRY_TO(TraverseTemplateArgumentLocsHelper( \
1687 D->getTemplateArgsAsWritten()->getTemplateArgs(), \
1688 D->getTemplateArgsAsWritten()->NumTemplateArgs)); \
1693 TRY_TO(Traverse##DECLKIND##Helper(D)); \
1706 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1707 TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
1712 template <typename Derived>
1713 bool RecursiveASTVisitor<Derived>::TraverseDeclaratorHelper(DeclaratorDecl *D) {
1714 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1715 if (D->getTypeSourceInfo())
1716 TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1718 TRY_TO(TraverseType(D->getType()));
1725 TRY_TO(TraverseDeclaratorHelper(D));
1726 if (D->isBitField())
1727 TRY_TO(TraverseStmt(D->getBitWidth()));
1728 else if (D->hasInClassInitializer())
1729 TRY_TO(TraverseStmt(D->getInClassInitializer()));
1733 TRY_TO(TraverseDeclaratorHelper(D));
1734 if (D->isBitField())
1735 TRY_TO(TraverseStmt(D->getBitWidth()));
1740 TRY_TO(TraverseDeclaratorHelper(D));
1741 if (D->isBitField())
1742 TRY_TO(TraverseStmt(D->getBitWidth()));
1746 template <typename Derived>
1747 bool RecursiveASTVisitor<Derived>::TraverseFunctionHelper(FunctionDecl *D) {
1748 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1749 TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
1756 if (
const FunctionTemplateSpecializationInfo *FTSI =
1757 D->getTemplateSpecializationInfo()) {
1762 if (
const ASTTemplateArgumentListInfo *TALI =
1763 FTSI->TemplateArgumentsAsWritten) {
1764 TRY_TO(TraverseTemplateArgumentLocsHelper(TALI->getTemplateArgs(),
1765 TALI->NumTemplateArgs));
1774 if (TypeSourceInfo *TSI = D->getTypeSourceInfo()) {
1775 TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
1776 }
else if (getDerived().shouldVisitImplicitCode()) {
1787 if (CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(D)) {
1789 for (
auto *
I : Ctor->inits()) {
1790 TRY_TO(TraverseConstructorInitializer(
I));
1794 if (D->isThisDeclarationADefinition()) {
1795 TRY_TO(TraverseStmt(D->getBody()));
1803 return TraverseFunctionHelper(D);
1809 return TraverseFunctionHelper(D);
1815 return TraverseFunctionHelper(D);
1823 return TraverseFunctionHelper(D);
1829 return TraverseFunctionHelper(D);
1832 template <typename Derived>
1833 bool RecursiveASTVisitor<Derived>::TraverseVarHelper(VarDecl *D) {
1834 TRY_TO(TraverseDeclaratorHelper(D));
1836 if (!isa<ParmVarDecl>(D) &&
1837 (!D->isCXXForRangeDecl() || getDerived().shouldVisitImplicitCode()))
1838 TRY_TO(TraverseStmt(D->getInit()));
1848 TRY_TO(TraverseDeclaratorHelper(D));
1849 if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
1850 TRY_TO(TraverseStmt(D->getDefaultArgument()));
1854 TRY_TO(TraverseVarHelper(D));
1856 if (D->hasDefaultArg() && D->hasUninstantiatedDefaultArg() &&
1857 !D->hasUnparsedDefaultArg())
1858 TRY_TO(TraverseStmt(D->getUninstantiatedDefaultArg()));
1860 if (D->hasDefaultArg() && !D->hasUninstantiatedDefaultArg() &&
1861 !D->hasUnparsedDefaultArg())
1862 TRY_TO(TraverseStmt(D->getDefaultArg()));
1878 template <typename Derived>
\
1879 bool RecursiveASTVisitor<Derived>::Traverse##
STMT( \
1880 STMT *S, DataRecursionQueue *Queue) {
\
1883 for (
Stmt *SubStmt : S->children()) {
\
1891 for (
unsigned I = 0, E = S->getNumInputs();
I <
E; ++
I) {
1894 for (
unsigned I = 0, E = S->getNumOutputs();
I <
E; ++
I) {
1897 for (
unsigned I = 0, E = S->getNumClobbers();
I <
E; ++
I) {
1910 TRY_TO(TraverseDecl(S->getExceptionDecl()));
1915 for (
auto *
I : S->decls()) {
1950 if (!getDerived().shouldVisitImplicitCode()) {
1959 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
1960 TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
1967 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
1968 TRY_TO(TraverseDeclarationNameInfo(S->getMemberNameInfo()));
1969 if (S->hasExplicitTemplateArgs()) {
1970 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
1971 S->getNumTemplateArgs()));
1976 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
1977 TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
1978 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
1979 S->getNumTemplateArgs()));
1983 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
1984 TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
1985 if (S->hasExplicitTemplateArgs()) {
1986 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
1987 S->getNumTemplateArgs()));
1992 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
1993 TRY_TO(TraverseDeclarationNameInfo(S->getMemberNameInfo()));
1994 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
1995 S->getNumTemplateArgs()));
2005 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2009 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2013 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2017 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2021 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2025 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2028 template <typename Derived>
2029 bool RecursiveASTVisitor<Derived>::TraverseSynOrSemInitListExpr(
2030 InitListExpr *S, DataRecursionQueue *Queue) {
2032 TRY_TO(WalkUpFromInitListExpr(S));
2034 for (
Stmt *SubStmt : S->children()) {
2048 TRY_TO(TraverseSynOrSemInitListExpr(
2049 S->isSemanticForm() ? S->getSyntacticForm() :
S, Queue));
2050 TRY_TO(TraverseSynOrSemInitListExpr(
2051 S->isSemanticForm() ? S : S->getSemanticForm(), Queue));
2059 TRY_TO(TraverseStmt(S->getControllingExpr()));
2060 for (
unsigned i = 0; i != S->getNumAssocs(); ++i) {
2061 if (TypeSourceInfo *TS = S->getAssocTypeSourceInfo(i))
2062 TRY_TO(TraverseTypeLoc(TS->getTypeLoc()));
2073 e = S->semantics_end();
2076 if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(sub))
2077 sub = OVE->getSourceExpr();
2086 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2091 TRY_TO(TraverseTypeLoc(S->getAllocatedTypeSourceInfo()->getTypeLoc()));
2099 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2105 if (S->isArgumentType())
2106 TRY_TO(TraverseTypeLoc(S->getArgumentTypeInfo()->getTypeLoc()));
2112 if (S->isTypeOperand())
2113 TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
2117 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2125 if (S->isTypeOperand())
2126 TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
2130 for (
unsigned I = 0, N = S->getNumArgs();
I != N; ++
I)
2131 TRY_TO(TraverseTypeLoc(S->getArg(
I)->getTypeLoc()));
2135 TRY_TO(TraverseTypeLoc(S->getQueriedTypeSourceInfo()->getTypeLoc()));
2143 TRY_TO(TraverseTypeLoc(S->getWrittenTypeInfo()->getTypeLoc()));
2148 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2154 CEnd = S->explicit_capture_end();
2156 TRY_TO(TraverseLambdaCapture(S,
C));
2159 TypeLoc TL = S->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
2160 FunctionProtoTypeLoc Proto = TL.castAs<FunctionProtoTypeLoc>();
2162 if (S->hasExplicitParameters() && S->hasExplicitResultType()) {
2164 TRY_TO(TraverseTypeLoc(TL));
2166 if (S->hasExplicitParameters()) {
2168 for (
unsigned I = 0, N = Proto.getNumParams();
I != N; ++
I) {
2169 TRY_TO(TraverseDecl(Proto.getParam(
I)));
2171 }
else if (S->hasExplicitResultType()) {
2172 TRY_TO(TraverseTypeLoc(Proto.getReturnLoc()));
2175 auto *T = Proto.getTypePtr();
2176 for (
const auto &E : T->exceptions()) {
2180 if (Expr *NE = T->getNoexceptExpr())
2189 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2204 TRY_TO(TraverseDecl(S->getBlockDecl()));
2209 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2220 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2221 if (TypeSourceInfo *ScopeInfo = S->getScopeTypeInfo())
2222 TRY_TO(TraverseTypeLoc(ScopeInfo->getTypeLoc()));
2223 if (TypeSourceInfo *DestroyedTypeInfo = S->getDestroyedTypeInfo())
2224 TRY_TO(TraverseTypeLoc(DestroyedTypeInfo->getTypeLoc()));
2237 if (TypeSourceInfo *TInfo = S->getEncodedTypeSourceInfo())
2238 TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
2243 if (TypeSourceInfo *TInfo = S->getClassReceiverTypeInfo())
2244 TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
2252 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2261 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2262 if (S->hasExplicitTemplateArgs()) {
2263 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2264 S->getNumTemplateArgs()));
2269 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2270 if (S->hasExplicitTemplateArgs()) {
2271 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2272 S->getNumTemplateArgs()));
2308 if (!getDerived().shouldVisitImplicitCode()) {
2314 if (!getDerived().shouldVisitImplicitCode()) {
2320 if (!getDerived().shouldVisitImplicitCode()) {
2326 if (!getDerived().shouldVisitImplicitCode()) {
2347 template <typename Derived>
2348 bool RecursiveASTVisitor<Derived>::TraverseOMPExecutableDirective(
2349 OMPExecutableDirective *S) {
2350 for (
auto *
C : S->clauses()) {
2356 template <
typename Derived>
2358 RecursiveASTVisitor<Derived>::TraverseOMPLoopDirective(OMPLoopDirective *S) {
2359 return TraverseOMPExecutableDirective(S);
2363 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2366 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2369 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2372 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2375 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2378 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2381 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2384 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2387 TRY_TO(TraverseDeclarationNameInfo(S->getDirectiveName()));
2388 TRY_TO(TraverseOMPExecutableDirective(S));
2392 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2395 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2398 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2401 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2404 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2407 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2410 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2413 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2416 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2419 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2422 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2425 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2428 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2431 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2434 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2437 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2440 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2443 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2446 {
TRY_TO(TraverseOMPExecutableDirective(S)); })
2449 template <typename Derived>
2450 bool RecursiveASTVisitor<Derived>::TraverseOMPClause(
OMPClause *
C) {
2453 switch (C->getClauseKind()) {
2454 #define OPENMP_CLAUSE(Name, Class) \
2456 TRY_TO(Visit##Class(static_cast<Class *>(C))); \
2458 #include "clang/Basic/OpenMPKinds.def"
2466 template <
typename Derived>
2467 bool RecursiveASTVisitor<Derived>::VisitOMPIfClause(OMPIfClause *C) {
2468 TRY_TO(TraverseStmt(C->getCondition()));
2472 template <
typename Derived>
2473 bool RecursiveASTVisitor<Derived>::VisitOMPFinalClause(OMPFinalClause *C) {
2474 TRY_TO(TraverseStmt(C->getCondition()));
2478 template <
typename Derived>
2480 RecursiveASTVisitor<Derived>::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) {
2481 TRY_TO(TraverseStmt(C->getNumThreads()));
2485 template <
typename Derived>
2486 bool RecursiveASTVisitor<Derived>::VisitOMPSafelenClause(OMPSafelenClause *C) {
2487 TRY_TO(TraverseStmt(C->getSafelen()));
2491 template <
typename Derived>
2492 bool RecursiveASTVisitor<Derived>::VisitOMPSimdlenClause(OMPSimdlenClause *C) {
2493 TRY_TO(TraverseStmt(C->getSimdlen()));
2497 template <
typename Derived>
2499 RecursiveASTVisitor<Derived>::VisitOMPCollapseClause(OMPCollapseClause *C) {
2500 TRY_TO(TraverseStmt(C->getNumForLoops()));
2504 template <
typename Derived>
2505 bool RecursiveASTVisitor<Derived>::VisitOMPDefaultClause(OMPDefaultClause *) {
2509 template <
typename Derived>
2510 bool RecursiveASTVisitor<Derived>::VisitOMPProcBindClause(OMPProcBindClause *) {
2514 template <
typename Derived>
2516 RecursiveASTVisitor<Derived>::VisitOMPScheduleClause(OMPScheduleClause *C) {
2517 TRY_TO(TraverseStmt(C->getChunkSize()));
2518 TRY_TO(TraverseStmt(C->getHelperChunkSize()));
2522 template <
typename Derived>
2523 bool RecursiveASTVisitor<Derived>::VisitOMPOrderedClause(OMPOrderedClause *C) {
2524 TRY_TO(TraverseStmt(C->getNumForLoops()));
2528 template <
typename Derived>
2529 bool RecursiveASTVisitor<Derived>::VisitOMPNowaitClause(OMPNowaitClause *) {
2533 template <
typename Derived>
2534 bool RecursiveASTVisitor<Derived>::VisitOMPUntiedClause(OMPUntiedClause *) {
2538 template <
typename Derived>
2540 RecursiveASTVisitor<Derived>::VisitOMPMergeableClause(OMPMergeableClause *) {
2544 template <
typename Derived>
2545 bool RecursiveASTVisitor<Derived>::VisitOMPReadClause(OMPReadClause *) {
2549 template <
typename Derived>
2550 bool RecursiveASTVisitor<Derived>::VisitOMPWriteClause(OMPWriteClause *) {
2554 template <
typename Derived>
2555 bool RecursiveASTVisitor<Derived>::VisitOMPUpdateClause(OMPUpdateClause *) {
2559 template <
typename Derived>
2560 bool RecursiveASTVisitor<Derived>::VisitOMPCaptureClause(OMPCaptureClause *) {
2564 template <
typename Derived>
2565 bool RecursiveASTVisitor<Derived>::VisitOMPSeqCstClause(OMPSeqCstClause *) {
2569 template <
typename Derived>
2570 bool RecursiveASTVisitor<Derived>::VisitOMPThreadsClause(
OMPThreadsClause *) {
2574 template <
typename Derived>
2575 bool RecursiveASTVisitor<Derived>::VisitOMPSIMDClause(
OMPSIMDClause *) {
2579 template <
typename Derived>
2580 bool RecursiveASTVisitor<Derived>::VisitOMPNogroupClause(
OMPNogroupClause *) {
2584 template <
typename Derived>
2585 template <
typename T>
2586 bool RecursiveASTVisitor<Derived>::VisitOMPClauseList(T *
Node) {
2587 for (
auto *E : Node->varlists()) {
2593 template <
typename Derived>
2594 bool RecursiveASTVisitor<Derived>::VisitOMPPrivateClause(OMPPrivateClause *C) {
2595 TRY_TO(VisitOMPClauseList(C));
2596 for (
auto *E : C->private_copies()) {
2602 template <
typename Derived>
2603 bool RecursiveASTVisitor<Derived>::VisitOMPFirstprivateClause(
2604 OMPFirstprivateClause *C) {
2605 TRY_TO(VisitOMPClauseList(C));
2606 for (
auto *E : C->private_copies()) {
2609 for (
auto *E : C->inits()) {
2615 template <
typename Derived>
2616 bool RecursiveASTVisitor<Derived>::VisitOMPLastprivateClause(
2617 OMPLastprivateClause *C) {
2618 TRY_TO(VisitOMPClauseList(C));
2619 for (
auto *E : C->private_copies()) {
2622 for (
auto *E : C->source_exprs()) {
2625 for (
auto *E : C->destination_exprs()) {
2628 for (
auto *E : C->assignment_ops()) {
2634 template <
typename Derived>
2635 bool RecursiveASTVisitor<Derived>::VisitOMPSharedClause(OMPSharedClause *C) {
2636 TRY_TO(VisitOMPClauseList(C));
2640 template <
typename Derived>
2641 bool RecursiveASTVisitor<Derived>::VisitOMPLinearClause(
OMPLinearClause *C) {
2642 TRY_TO(TraverseStmt(C->getStep()));
2643 TRY_TO(TraverseStmt(C->getCalcStep()));
2644 TRY_TO(VisitOMPClauseList(C));
2645 for (
auto *E : C->privates()) {
2648 for (
auto *E : C->inits()) {
2651 for (
auto *E : C->updates()) {
2654 for (
auto *E : C->finals()) {
2660 template <
typename Derived>
2661 bool RecursiveASTVisitor<Derived>::VisitOMPAlignedClause(
OMPAlignedClause *C) {
2663 TRY_TO(VisitOMPClauseList(C));
2667 template <
typename Derived>
2668 bool RecursiveASTVisitor<Derived>::VisitOMPCopyinClause(
OMPCopyinClause *C) {
2669 TRY_TO(VisitOMPClauseList(C));
2682 template <
typename Derived>
2683 bool RecursiveASTVisitor<Derived>::VisitOMPCopyprivateClause(
2685 TRY_TO(VisitOMPClauseList(C));
2698 template <
typename Derived>
2700 RecursiveASTVisitor<Derived>::VisitOMPReductionClause(OMPReductionClause *C) {
2701 TRY_TO(TraverseNestedNameSpecifierLoc(C->getQualifierLoc()));
2702 TRY_TO(TraverseDeclarationNameInfo(C->getNameInfo()));
2703 TRY_TO(VisitOMPClauseList(C));
2704 for (
auto *E : C->privates()) {
2707 for (
auto *E : C->lhs_exprs()) {
2710 for (
auto *E : C->rhs_exprs()) {
2713 for (
auto *E : C->reduction_ops()) {
2719 template <
typename Derived>
2720 bool RecursiveASTVisitor<Derived>::VisitOMPFlushClause(
OMPFlushClause *C) {
2721 TRY_TO(VisitOMPClauseList(C));
2725 template <
typename Derived>
2726 bool RecursiveASTVisitor<Derived>::VisitOMPDependClause(
OMPDependClause *C) {
2727 TRY_TO(VisitOMPClauseList(C));
2731 template <
typename Derived>
2732 bool RecursiveASTVisitor<Derived>::VisitOMPDeviceClause(
OMPDeviceClause *C) {
2737 template <
typename Derived>
2738 bool RecursiveASTVisitor<Derived>::VisitOMPMapClause(
OMPMapClause *C) {
2739 TRY_TO(VisitOMPClauseList(C));
2743 template <
typename Derived>
2744 bool RecursiveASTVisitor<Derived>::VisitOMPNumTeamsClause(
2750 template <
typename Derived>
2751 bool RecursiveASTVisitor<Derived>::VisitOMPThreadLimitClause(
2757 template <
typename Derived>
2758 bool RecursiveASTVisitor<Derived>::VisitOMPPriorityClause(
2764 template <
typename Derived>
2765 bool RecursiveASTVisitor<Derived>::VisitOMPGrainsizeClause(
2771 template <
typename Derived>
2772 bool RecursiveASTVisitor<Derived>::VisitOMPNumTasksClause(
2778 template <
typename Derived>
2779 bool RecursiveASTVisitor<Derived>::VisitOMPHintClause(
OMPHintClause *C) {
2801 #undef DEF_TRAVERSE_STMT
2802 #undef TRAVERSE_STMT
2803 #undef TRAVERSE_STMT_BASE
2809 #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.
ParmVarDecl *const * param_const_iterator
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
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)
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.
TemplateSpecializationType(TemplateName T, const TemplateArgument *Args, unsigned NumArgs, QualType Canon, QualType Aliased)
This represents 'priority' clause in the '#pragma omp ...' directive.
bool VisitTypeLoc(TypeLoc TL)
The base class of the type hierarchy.
DependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, unsigned NumArgs, const TemplateArgument *Args, QualType Canon)
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.
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.
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.
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.
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.
SmallVectorImpl< Stmt * > DataRecursionQueue
A queue used for performing data recursion over statements.
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.
bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C)
Recursively visit a lambda capture.
This represents clause 'map' in the '#pragma omp ...' directives.
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 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.
NamedDecl ** iterator
Iterates through the template parameters in this list.
bool TraverseDeclarationNameInfo(DeclarationNameInfo NameInfo)
Recursively visit a name with its location information.
#define DEF_TRAVERSE_DECL(DECL, CODE)
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)
A class that does preorder depth-first traversal on the entire Clang AST and visits each node...
#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
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_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.
bool TraverseConstructorInitializer(CXXCtorInitializer *Init)
Recursively visit a constructor initializer.
helper_expr_const_range assignment_ops() const
bool WalkUpFromDecl(Decl *D)
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.
ParmVarDecl *const * param_iterator
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.
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
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)
const LambdaCapture * capture_iterator
An iterator that walks over the captures of the lambda, both implicit and explicit.
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...
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.
return(x >> y)|(x<< (32-y))
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
for(auto typeArg:T->getTypeArgsAsWritten())
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...
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)
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.
helper_expr_const_range assignment_ops() const
#define STMT(CLASS, PARENT)
helper_expr_const_range source_exprs() const