clang: include/clang/AST/RecursiveASTVisitor.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
14#define LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
15
48#include "llvm/ADT/PointerIntPair.h"
49#include "llvm/ADT/SmallVector.h"
50#include "llvm/Support/Casting.h"
51#include
52#include
53#include <type_traits>
54
56
57
58
59
60
61#define TRY_TO(CALL_EXPR) \
62 do { \
63 if (!getDerived().CALL_EXPR) \
64 return false; \
65 } while (false)
66
67namespace detail {
68
69template <typename T, typename U>
71template <typename T, typename U, typename R, typename... P>
73 : std::true_type {};
74
75
76
77template <typename FirstMethodPtrTy, typename SecondMethodPtrTy>
78LLVM_ATTRIBUTE_ALWAYS_INLINE LLVM_ATTRIBUTE_NODEBUG auto
79isSameMethod([[maybe_unused]] FirstMethodPtrTy FirstMethodPtr,
80 [[maybe_unused]] SecondMethodPtrTy SecondMethodPtr)
81 -> bool {
83 SecondMethodPtrTy>::value)
84 return FirstMethodPtr == SecondMethodPtr;
85 return false;
86}
87
88}
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
156public:
157
158
159
160
161
164
165
166 Derived &getDerived() { return *static_cast<Derived *>(this); }
167
168
169
171
172
173
175
176
177
179
180
182
183
185
186
187
189
190
192 }
193
194
195
196
197
198
200
201
202
203
205
206
207
208
209
210
212
213
214
215
216
217
219
220
221
222
223
224
226
227
228
229
230
231
233
234
235
236
237
238
240
241
242
243
245
246
247
248
249
251
252
253
254
256
257
258
259
260
262
263
264
265
266
267
269
270
271
272
273
275
276
277
278
279
280
281
283
284
285
286
287
289
290
291
292
293
294
295
297
298
299
300
301
304
305
306
307
308
311
312
313
314
315
317
318
319
320
322
323
325
326
327
329
330
331#define ATTR_VISITOR_DECLS_ONLY
332#include "clang/AST/AttrVisitor.inc"
333#undef ATTR_VISITOR_DECLS_ONLY
334
335
336
338
339private:
340
341
342
343
344
345#define TRAVERSE_STMT_BASE(NAME, CLASS, VAR, QUEUE) \
346 (::clang::detail::has_same_member_pointer_type< \
347 decltype(&RecursiveASTVisitor::Traverse##NAME), \
348 decltype(&Derived::Traverse##NAME)>::value \
349 ? static_cast<std::conditional_t< \
350 ::clang::detail::has_same_member_pointer_type< \
351 decltype(&RecursiveASTVisitor::Traverse##NAME), \
352 decltype(&Derived::Traverse##NAME)>::value, \
353 Derived &, RecursiveASTVisitor &>>(*this) \
354 .Traverse##NAME(static_cast<CLASS *>(VAR), QUEUE) \
355 : getDerived().Traverse##NAME(static_cast<CLASS *>(VAR)))
356
357
358
359
360#define TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S) \
361 do { \
362 if (!TRAVERSE_STMT_BASE(Stmt, Stmt, S, Queue)) \
363 return false; \
364 } while (false)
365
366public:
367
368#define ABSTRACT_STMT(STMT)
369#define STMT(CLASS, PARENT) \
370 bool Traverse##CLASS(CLASS *S, DataRecursionQueue *Queue = nullptr);
371#include "clang/AST/StmtNodes.inc"
372
373
374
377#define STMT(CLASS, PARENT) \
378 bool WalkUpFrom##CLASS(CLASS *S) { \
379 TRY_TO(WalkUpFrom##PARENT(S)); \
380 TRY_TO(Visit##CLASS(S)); \
381 return true; \
382 } \
383 bool Visit##CLASS(CLASS *S) { return true; }
384#include "clang/AST/StmtNodes.inc"
385
386
387
388
389
390#define ABSTRACT_TYPE(CLASS, BASE)
391#define TYPE(CLASS, BASE) bool Traverse##CLASS##Type(CLASS##Type *T);
392#include "clang/AST/TypeNodes.inc"
393
394
395
398#define TYPE(CLASS, BASE) \
399 bool WalkUpFrom##CLASS##Type(CLASS##Type *T) { \
400 TRY_TO(WalkUpFrom##BASE(T)); \
401 TRY_TO(Visit##CLASS##Type(T)); \
402 return true; \
403 } \
404 bool Visit##CLASS##Type(CLASS##Type *T) { return true; }
405#include "clang/AST/TypeNodes.inc"
406
407
408
409
410
411#define ABSTRACT_TYPELOC(CLASS, BASE)
412#define TYPELOC(CLASS, BASE) bool Traverse##CLASS##TypeLoc(CLASS##TypeLoc TL);
413#include "clang/AST/TypeLocNodes.def"
414
415
416
419
420
421
424 }
428 }
430
431
432#define TYPE(CLASS, BASE) \
433 bool WalkUpFrom##CLASS##TypeLoc(CLASS##TypeLoc TL) { \
434 TRY_TO(WalkUpFrom##BASE##Loc(TL)); \
435 TRY_TO(Visit##CLASS##TypeLoc(TL)); \
436 return true; \
437 } \
438 bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TL) { return true; }
439#include "clang/AST/TypeNodes.inc"
440
441
442
443
444#define ABSTRACT_DECL(DECL)
445#define DECL(CLASS, BASE) bool Traverse##CLASS##Decl(CLASS##Decl *D);
446#include "clang/AST/DeclNodes.inc"
447
448
449
452#define DECL(CLASS, BASE) \
453 bool WalkUpFrom##CLASS##Decl(CLASS##Decl *D) { \
454 TRY_TO(WalkUpFrom##BASE(D)); \
455 TRY_TO(Visit##CLASS##Decl(D)); \
456 return true; \
457 } \
458 bool Visit##CLASS##Decl(CLASS##Decl *D) { return true; }
459#include "clang/AST/DeclNodes.inc"
460
462
463#define DEF_TRAVERSE_TMPL_INST(TMPLDECLKIND) \
464 bool TraverseTemplateInstantiations(TMPLDECLKIND##TemplateDecl *D);
468#undef DEF_TRAVERSE_TMPL_INST
469
471
476
478
479private:
480
482
483
484 template
485 bool TraverseDeclTemplateParameterLists(T *D);
486
488
490 unsigned Count);
491 bool TraverseArrayTypeLocHelper(ArrayTypeLoc TL);
492 bool TraverseRecordHelper(RecordDecl *D);
495 bool TraverseDeclContextHelper(DeclContext *DC);
497 bool TraverseVarHelper(VarDecl *D);
500 bool TraverseOMPClause(OMPClause *C);
501#define GEN_CLANG_CLAUSE_CLASS
502#define CLAUSE_CLASS(Enum, Str, Class) bool Visit##Class(Class *C);
503#include "llvm/Frontend/OpenMP/OMP.inc"
504
505 template bool VisitOMPClauseList(T *Node);
506
507 bool VisitOMPClauseWithPreInit(OMPClauseWithPreInit *Node);
508 bool VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *Node);
509
510 bool PostVisitStmt(Stmt *S);
511 bool TraverseOpenACCConstructStmt(OpenACCConstructStmt *S);
512 bool
513 TraverseOpenACCAssociatedStmtConstruct(OpenACCAssociatedStmtConstruct *S);
514 bool VisitOpenACCClauseList(ArrayRef<const OpenACCClause *>);
515 bool VisitOpenACCClause(const OpenACCClause *);
516};
517
518template
521 if (!getDerived().shouldVisitImplicitCode()) {
522 TRY_TO(TraverseConceptReference(C->getConceptReference()));
523 return true;
524 }
525 if (Expr *IDC = C->getImmediatelyDeclaredConstraint()) {
526 TRY_TO(TraverseStmt(IDC));
527 } else {
528
529
530
531
532 TRY_TO(TraverseConceptReference(C->getConceptReference()));
533 }
534 return true;
535}
536
537template
542 return getDerived().TraverseConceptTypeRequirement(
543 castconcepts::TypeRequirement(R));
546 return getDerived().TraverseConceptExprRequirement(
547 castconcepts::ExprRequirement(R));
549 return getDerived().TraverseConceptNestedRequirement(
550 castconcepts::NestedRequirement(R));
551 }
552 llvm_unreachable("unexpected case");
553}
554
555template
558
559 switch (S->getStmtClass()) {
561 break;
562#define ABSTRACT_STMT(STMT)
563#define STMT(CLASS, PARENT) \
564 case Stmt::CLASS##Class: \
565 return TRAVERSE_STMT_BASE(CLASS, CLASS, S, Queue);
566#include "clang/AST/StmtNodes.inc"
567 }
568
569 return true;
570}
571
572#undef DISPATCH_STMT
573
574template
578 return true;
580}
581
582template
588 if (RetReq.isTypeConstraint()) {
589 if (getDerived().shouldVisitImplicitCode()) {
590 TRY_TO(TraverseTemplateParameterListHelper(
591 RetReq.getTypeConstraintTemplateParameterList()));
592 } else {
593
594 TRY_TO(TraverseTypeConstraint(RetReq.getTypeConstraint()));
595 }
596 }
597 return true;
598}
599
600template
605 return true;
606}
607
608template
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626 switch (S->getStmtClass()) {
628 break;
629#define ABSTRACT_STMT(STMT)
630#define STMT(CLASS, PARENT) \
631 case Stmt::CLASS##Class: \
632 if (::clang::detail::isSameMethod(&RecursiveASTVisitor::Traverse##CLASS, \
633 &Derived::Traverse##CLASS)) { \
634 TRY_TO(WalkUpFrom##CLASS(static_cast<CLASS *>(S))); \
635 } \
636 break;
637#define INITLISTEXPR(CLASS, PARENT) \
638 case Stmt::CLASS##Class: \
639 if (::clang::detail::isSameMethod(&RecursiveASTVisitor::Traverse##CLASS, \
640 &Derived::Traverse##CLASS)) { \
641 auto ILE = static_cast<CLASS *>(S); \
642 if (auto Syn = ILE->isSemanticForm() ? ILE->getSyntacticForm() : ILE) \
643 TRY_TO(WalkUpFrom##CLASS(Syn)); \
644 if (auto Sem = ILE->isSemanticForm() ? ILE : ILE->getSemanticForm()) \
645 TRY_TO(WalkUpFrom##CLASS(Sem)); \
646 } \
647 break;
648#include "clang/AST/StmtNodes.inc"
649 }
650
651 return true;
652}
653
654#undef DISPATCH_STMT
655
656
657
658template
659LLVM_ATTRIBUTE_NOINLINE bool
661 if (!S)
662 return true;
663
664 if (Queue) {
665 Queue->push_back({S, false});
666 return true;
667 }
668
670 LocalQueue.push_back({S, false});
671
672 while (!LocalQueue.empty()) {
673 auto &CurrSAndVisited = LocalQueue.back();
674 Stmt *CurrS = CurrSAndVisited.getPointer();
675 bool Visited = CurrSAndVisited.getInt();
677 LocalQueue.pop_back();
678 TRY_TO(dataTraverseStmtPost(CurrS));
679 if (getDerived().shouldTraversePostOrder()) {
680 TRY_TO(PostVisitStmt(CurrS));
681 }
682 continue;
683 }
684
685 if (getDerived().dataTraverseStmtPre(CurrS)) {
686 CurrSAndVisited.setInt(true);
687 size_t N = LocalQueue.size();
688 TRY_TO(dataTraverseNode(CurrS, &LocalQueue));
689
690 std::reverse(LocalQueue.begin() + N, LocalQueue.end());
691 } else {
692 LocalQueue.pop_back();
693 }
694 }
695
696 return true;
697}
698
699template
701 if (T.isNull())
702 return true;
703
705#define ABSTRACT_TYPE(CLASS, BASE)
706#define TYPE(CLASS, BASE) \
707 case Type::CLASS: \
708 return getDerived().Traverse##CLASS##Type( \
709 static_cast<CLASS##Type *>(const_cast<Type *>(T.getTypePtr())));
710#include "clang/AST/TypeNodes.inc"
711 }
712
713 return true;
714}
715
716template
719 return true;
720
722#define ABSTRACT_TYPELOC(CLASS, BASE)
723#define TYPELOC(CLASS, BASE) \
724 case TypeLoc::CLASS: \
725 return getDerived().Traverse##CLASS##TypeLoc(TL.castAs<CLASS##TypeLoc>());
726#include "clang/AST/TypeLocNodes.def"
727 }
728
729 return true;
730}
731
732
733#define VISITORCLASS RecursiveASTVisitor
734#include "clang/AST/AttrVisitor.inc"
735#undef VISITORCLASS
736
737template
739 if ()
740 return true;
741
742
743
744 if (!getDerived().shouldVisitImplicitCode()) {
746
747
748
749 if (auto *TTPD = dyn_cast(D))
750 return TraverseTemplateTypeParamDeclConstraints(TTPD);
751 return true;
752 }
753
754
755
756
757
758
759
760
761 if (auto *FTD = dyn_cast(D))
762 if (llvm::isa_and_present(
763 FTD->getDeclName().getCXXDeductionGuideTemplate()))
764 return true;
765 }
766
768#define ABSTRACT_DECL(DECL)
769#define DECL(CLASS, BASE) \
770 case Decl::CLASS: \
771 if (!getDerived().Traverse##CLASS##Decl(static_cast<CLASS##Decl *>(D))) \
772 return false; \
773 break;
774#include "clang/AST/DeclNodes.inc"
775 }
776 return true;
777}
778
779template
782 if (!NNS)
783 return true;
784
787
788 switch (NNS->getKind()) {
794 return true;
795
799 }
800
801 return true;
802}
803
804template
807 if (!NNS)
808 return true;
809
811 TRY_TO(TraverseNestedNameSpecifierLoc(Prefix));
812
819 return true;
820
824 break;
825 }
826
827 return true;
828}
829
830template
838 TRY_TO(TraverseTypeLoc(TSInfo->getTypeLoc()));
839 break;
840
842 TRY_TO(TraverseTemplateName(
844 break;
845
853 break;
854 }
855
856 return true;
857}
858
859template
862 TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier()));
865 if (QTN->getQualifier()) {
866 TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
867 }
868 }
869
870 return true;
871}
872
873template
882 return true;
883
885 return getDerived().TraverseType(Arg.getAsType());
886
889 return getDerived().TraverseTemplateName(
891
893 return getDerived().TraverseStmt(Arg.getAsExpr());
894
896 return getDerived().TraverseTemplateArguments(Arg.pack_elements());
897 }
898
899 return true;
900}
901
902
903
904template
908
915 return true;
916
918
920 return getDerived().TraverseTypeLoc(TSI->getTypeLoc());
921 else
922 return getDerived().TraverseType(Arg.getAsType());
923 }
924
928 TRY_TO(getDerived().TraverseNestedNameSpecifierLoc(
930 return getDerived().TraverseTemplateName(
932
935
937 return getDerived().TraverseTemplateArguments(Arg.pack_elements());
938 }
939
940 return true;
941}
942
943template
947 TRY_TO(TraverseTemplateArgument(Arg));
948
949 return true;
950}
951
952template
956 TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
957
958 if (Init->isWritten() || getDerived().shouldVisitImplicitCode())
959 TRY_TO(TraverseStmt(Init->getInit()));
960
961 return true;
962}
963
964template
965bool
969 if (LE->isInitCapture(C))
970 TRY_TO(TraverseDecl(C->getCapturedVar()));
971 else
973 return true;
974}
975
976
977
978
979#define DEF_TRAVERSE_TYPE(TYPE, CODE) \
980 template \
981 bool RecursiveASTVisitor::Traverse##TYPE(TYPE *T) { \
982 if (!getDerived().shouldTraversePostOrder()) \
983 TRY_TO(WalkUpFrom##TYPE(T)); \
984 { CODE; } \
985 if (getDerived().shouldTraversePostOrder()) \
986 TRY_TO(WalkUpFrom##TYPE(T)); \
987 return true; \
988 }
989
991
993
995
998
1001
1004
1006 TRY_TO(TraverseType(QualType(T->getClass(), 0)));
1008})
1009
1011
1013
1015 TRY_TO(TraverseType(T->getElementType()));
1016 if (T->getSizeExpr())
1017 TRY_TO(TraverseStmt(const_cast<Expr*>(T->getSizeExpr())));
1018})
1019
1021 TRY_TO(TraverseType(T->getElementType()));
1022 if (T->getSizeExpr())
1023 TRY_TO(TraverseStmt(const_cast<Expr *>(T->getSizeExpr())));
1024})
1025
1027 { TRY_TO(TraverseType(T->getElementType())); })
1028
1030 TRY_TO(TraverseType(T->getElementType()));
1032})
1033
1035 TRY_TO(TraverseType(T->getElementType()));
1036 if (T->getSizeExpr())
1037 TRY_TO(TraverseStmt(T->getSizeExpr()));
1038})
1039
1041 TRY_TO(TraverseStmt(T->getAddrSpaceExpr()));
1043})
1044
1046 if (T->getSizeExpr())
1047 TRY_TO(TraverseStmt(T->getSizeExpr()));
1048 TRY_TO(TraverseType(T->getElementType()));
1049})
1050
1052 if (T->getSizeExpr())
1053 TRY_TO(TraverseStmt(T->getSizeExpr()));
1054 TRY_TO(TraverseType(T->getElementType()));
1055})
1056
1058
1060
1062 { TRY_TO(TraverseType(T->getElementType())); })
1063
1065 if (T->getRowExpr())
1066 TRY_TO(TraverseStmt(T->getRowExpr()));
1067 if (T->getColumnExpr())
1068 TRY_TO(TraverseStmt(T->getColumnExpr()));
1069 TRY_TO(TraverseType(T->getElementType()));
1070})
1071
1074
1077
1079 TRY_TO(TraverseType(A));
1080 }
1081
1084 }
1085
1087 TRY_TO(TraverseStmt(NE));
1088})
1089
1093
1095 { TRY_TO(TraverseStmt(T->getUnderlyingExpr())); })
1096
1098
1100 { TRY_TO(TraverseStmt(T->getUnderlyingExpr())); })
1101
1103 TRY_TO(TraverseType(T->getPattern()));
1104 TRY_TO(TraverseStmt(T->getIndexExpr()));
1105})
1106
1108 TRY_TO(TraverseType(T->getBaseType()));
1109 TRY_TO(TraverseType(T->getUnderlyingType()));
1110})
1111
1113 TRY_TO(TraverseType(T->getDeducedType()));
1114 if (T->isConstrained()) {
1115 TRY_TO(TraverseTemplateArguments(T->getTypeConstraintArguments()));
1116 }
1117})
1119 TRY_TO(TraverseTemplateName(T->getTemplateName()));
1120 TRY_TO(TraverseType(T->getDeducedType()));
1121})
1122
1127 TRY_TO(TraverseType(T->getReplacementType()));
1128})
1130 TRY_TO(TraverseTemplateArgument(T->getArgumentPack()));
1131})
1132
1134 TRY_TO(TraverseTemplateName(T->getTemplateName()));
1135 TRY_TO(TraverseTemplateArguments(T->template_arguments()));
1136})
1137
1139
1141 { TRY_TO(TraverseType(T->getModifiedType())); })
1142
1144 if (T->getCountExpr())
1145 TRY_TO(TraverseStmt(T->getCountExpr()));
1147})
1148
1150 { TRY_TO(TraverseType(T->getWrappedType())); })
1151
1153 { TRY_TO(TraverseType(T->getWrappedType())); })
1154
1156
1158 { TRY_TO(TraverseType(T->getUnderlyingType())); })
1159
1161 if (T->getQualifier()) {
1162 TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
1163 }
1164 TRY_TO(TraverseType(T->getNamedType()));
1165})
1166
1168 { TRY_TO(TraverseNestedNameSpecifier(T->getQualifier())); })
1169
1171 TRY_TO(TraverseNestedNameSpecifier(T->getQualifier()));
1172 TRY_TO(TraverseTemplateArguments(T->template_arguments()));
1173})
1174
1176
1178
1180
1182
1183
1184 if (T->getBaseType().getTypePtr() != T)
1185 TRY_TO(TraverseType(T->getBaseType()));
1186 for (auto typeArg : T->getTypeArgsAsWritten()) {
1187 TRY_TO(TraverseType(typeArg));
1188 }
1189})
1190
1193
1195
1197
1200 { TRY_TO(TraverseStmt(T->getNumBitsExpr())); })
1201
1203
1204
1205
1206
1207
1208
1209
1210
1212 template \
1213 bool RecursiveASTVisitor::Traverse##TYPE##Loc(TYPE##Loc TL) { \
1214 if (!getDerived().shouldTraversePostOrder()) { \
1215 TRY_TO(WalkUpFrom##TYPE##Loc(TL)); \
1216 if (getDerived().shouldWalkTypesOfTypeLocs()) \
1217 TRY_TO(WalkUpFrom##TYPE(const_cast<TYPE *>(TL.getTypePtr()))); \
1218 } \
1219 { CODE; } \
1220 if (getDerived().shouldTraversePostOrder()) { \
1221 TRY_TO(WalkUpFrom##TYPE##Loc(TL)); \
1222 if (getDerived().shouldWalkTypesOfTypeLocs()) \
1223 TRY_TO(WalkUpFrom##TYPE(const_cast<TYPE *>(TL.getTypePtr()))); \
1224 } \
1225 return true; \
1226 }
1227
1228template
1229bool
1230RecursiveASTVisitor::TraverseQualifiedTypeLoc(QualifiedTypeLoc TL) {
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246 return TraverseTypeLoc(TL.getUnqualifiedLoc());
1247}
1248
1250
1251
1253 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1254})
1255
1257 { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1258
1260 { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1261
1263 { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1264
1266 { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1267
1268
1269
1271 if (auto *TSI = TL.getClassTInfo())
1272 TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
1273 else
1275 TRY_TO(TraverseTypeLoc(TL.getPointeeLoc()));
1276})
1277
1279 { TRY_TO(TraverseTypeLoc(TL.getOriginalLoc())); })
1280
1282 { TRY_TO(TraverseTypeLoc(TL.getOriginalLoc())); })
1283
1284template
1285bool RecursiveASTVisitor::TraverseArrayTypeLocHelper(ArrayTypeLoc TL) {
1286
1287 TRY_TO(TraverseStmt(TL.getSizeExpr()));
1288 return true;
1289}
1290
1292 TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1293 TRY_TO(TraverseArrayTypeLocHelper(TL));
1294})
1295
1297 TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1298 TRY_TO(TraverseArrayTypeLocHelper(TL));
1299})
1300
1302 TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1303 TRY_TO(TraverseArrayTypeLocHelper(TL));
1304})
1305
1307 TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1308 TRY_TO(TraverseArrayTypeLocHelper(TL));
1309})
1310
1312 TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
1313 TRY_TO(TraverseArrayTypeLocHelper(TL));
1314})
1315
1317 TRY_TO(TraverseStmt(TL.getTypePtr()->getAddrSpaceExpr()));
1318 TRY_TO(TraverseType(TL.getTypePtr()->getPointeeType()));
1319})
1320
1321
1322
1324 if (TL.getTypePtr()->getSizeExpr())
1325 TRY_TO(TraverseStmt(TL.getTypePtr()->getSizeExpr()));
1326 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1327})
1328
1329
1331 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1332})
1333
1335 if (TL.getTypePtr()->getSizeExpr())
1336 TRY_TO(TraverseStmt(TL.getTypePtr()->getSizeExpr()));
1337 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1338})
1339
1340
1341
1343 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1344})
1345
1347 TRY_TO(TraverseStmt(TL.getAttrRowOperand()));
1348 TRY_TO(TraverseStmt(TL.getAttrColumnOperand()));
1349 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1350})
1351
1353 TRY_TO(TraverseStmt(TL.getAttrRowOperand()));
1354 TRY_TO(TraverseStmt(TL.getAttrColumnOperand()));
1355 TRY_TO(TraverseType(TL.getTypePtr()->getElementType()));
1356})
1357
1359 { TRY_TO(TraverseTypeLoc(TL.getReturnLoc())); })
1360
1361
1363 TRY_TO(TraverseTypeLoc(TL.getReturnLoc()));
1364
1366
1367 for (unsigned I = 0, E = TL.getNumParams(); I != E; ++I) {
1368 if (TL.getParam(I)) {
1369 TRY_TO(TraverseDecl(TL.getParam(I)));
1370 } else if (I < T->getNumParams()) {
1372 }
1373 }
1374
1377 }
1378
1380 TRY_TO(TraverseStmt(NE));
1381})
1382
1386
1388 { TRY_TO(TraverseStmt(TL.getUnderlyingExpr())); })
1389
1391 TRY_TO(TraverseTypeLoc(TL.getUnmodifiedTInfo()->getTypeLoc()));
1392})
1393
1394
1396 TRY_TO(TraverseStmt(TL.getTypePtr()->getUnderlyingExpr()));
1397})
1398
1400 TRY_TO(TraverseType(TL.getPattern()));
1401 TRY_TO(TraverseStmt(TL.getTypePtr()->getIndexExpr()));
1402})
1403
1405 TRY_TO(TraverseTypeLoc(TL.getUnderlyingTInfo()->getTypeLoc()));
1406})
1407
1409 TRY_TO(TraverseType(TL.getTypePtr()->getDeducedType()));
1410 if (TL.isConstrained()) {
1411 TRY_TO(TraverseConceptReference(TL.getConceptReference()));
1412 }
1413})
1414
1416 TRY_TO(TraverseTemplateName(TL.getTypePtr()->getTemplateName()));
1417 TRY_TO(TraverseType(TL.getTypePtr()->getDeducedType()));
1418})
1419
1424 TRY_TO(TraverseType(TL.getTypePtr()->getReplacementType()));
1425})
1427 TRY_TO(TraverseTemplateArgument(TL.getTypePtr()->getArgumentPack()));
1428})
1429
1430
1432 TRY_TO(TraverseTemplateName(TL.getTypePtr()->getTemplateName()));
1433 for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) {
1434 TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(I)));
1435 }
1436})
1437
1439
1441
1443 { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
1444
1446 { TRY_TO(TraverseTypeLoc(TL.getModifiedLoc())); })
1447
1449 { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
1450
1452 { TRY_TO(TraverseTypeLoc(TL.getWrappedLoc())); })
1453
1455 { TRY_TO(TraverseTypeLoc(TL.getWrappedLoc())); })
1456
1458 if (TL.getQualifierLoc()) {
1459 TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1460 }
1461 TRY_TO(TraverseTypeLoc(TL.getNamedTypeLoc()));
1462})
1463
1465 TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1466})
1467
1469 if (TL.getQualifierLoc()) {
1470 TRY_TO(TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()));
1471 }
1472
1473 for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) {
1474 TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(I)));
1475 }
1476})
1477
1479 { TRY_TO(TraverseTypeLoc(TL.getPatternLoc())); })
1480
1482 for (unsigned I = 0, N = TL.getNumProtocols(); I != N; ++I) {
1483 ObjCProtocolLoc ProtocolLoc(TL.getProtocol(I), TL.getProtocolLoc(I));
1484 TRY_TO(TraverseObjCProtocolLoc(ProtocolLoc));
1485 }
1486})
1487
1489
1491
1492
1493 if (TL.getTypePtr()->getBaseType().getTypePtr() != TL.getTypePtr())
1494 TRY_TO(TraverseTypeLoc(TL.getBaseLoc()));
1495 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
1496 TRY_TO(TraverseTypeLoc(TL.getTypeArgTInfo(i)->getTypeLoc()));
1497 for (unsigned I = 0, N = TL.getNumProtocols(); I != N; ++I) {
1498 ObjCProtocolLoc ProtocolLoc(TL.getProtocol(I), TL.getProtocolLoc(I));
1499 TRY_TO(TraverseObjCProtocolLoc(ProtocolLoc));
1500 }
1501})
1502
1504 { TRY_TO(TraverseTypeLoc(TL.getPointeeLoc())); })
1505
1507
1509
1512 TRY_TO(TraverseStmt(TL.getTypePtr()->getNumBitsExpr()));
1513})
1514
1516
1517
1518
1519
1520
1521
1522
1523
1524template
1526 const Decl *Child) {
1527
1528
1529 if (isa(Child) || isa(Child))
1530 return true;
1531
1532 if (const CXXRecordDecl* Cls = dyn_cast(Child))
1533 return Cls->isLambda();
1534 return false;
1535}
1536
1537template
1539 if (!DC)
1540 return true;
1541
1542 for (auto *Child : DC->decls()) {
1543 if (!canIgnoreChildDeclWhileTraversingDeclContext(Child))
1544 TRY_TO(TraverseDecl(Child));
1545 }
1546
1547 return true;
1548}
1549
1550
1551#define DEF_TRAVERSE_DECL(DECL, CODE) \
1552 template \
1553 bool RecursiveASTVisitor::Traverse##DECL(DECL *D) { \
1554 bool ShouldVisitChildren = true; \
1555 bool ReturnValue = true; \
1556 if (!getDerived().shouldTraversePostOrder()) \
1557 TRY_TO(WalkUpFrom##DECL(D)); \
1558 { CODE; } \
1559 if (ReturnValue && ShouldVisitChildren) \
1560 TRY_TO(TraverseDeclContextHelper(dyn_cast(D))); \
1561 if (ReturnValue) { \
1562 \
1563 for (auto *I : D->attrs()) \
1564 TRY_TO(getDerived().TraverseAttr(I)); \
1565 } \
1566 if (ReturnValue && getDerived().shouldTraversePostOrder()) \
1567 TRY_TO(WalkUpFrom##DECL(D)); \
1568 return ReturnValue; \
1569 }
1570
1572
1575 TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
1577 for (const auto &I : D->captures()) {
1578 if (I.hasCopyExpr()) {
1579 TRY_TO(TraverseStmt(I.getCopyExpr()));
1580 }
1581 }
1583})
1584
1586 TRY_TO(TraverseStmt(D->getBody()));
1588})
1589
1591 TRY_TO(TraverseStmt(D->getBody()));
1593})
1594
1596
1598
1600 TRY_TO(TraverseStmt(D->getTemporaryExpr()));
1601})
1602
1604 { TRY_TO(TraverseStmt(D->getAsmString())); })
1605
1607
1609
1611
1612 if (D->getFriendType()) {
1613 TRY_TO(TraverseTypeLoc(D->getFriendType()->getTypeLoc()));
1614
1615
1616 if (auto *ET = D->getFriendType()->getType()->getAs<ElaboratedType>())
1617 TRY_TO(TraverseDecl(ET->getOwnedTagDecl()));
1618 } else {
1619 TRY_TO(TraverseDecl(D->getFriendDecl()));
1620 }
1621})
1622
1624 if (D->getFriendType())
1625 TRY_TO(TraverseTypeLoc(D->getFriendType()->getTypeLoc()));
1626 else
1627 TRY_TO(TraverseDecl(D->getFriendDecl()));
1628 for (unsigned I = 0, E = D->getNumTemplateParameters(); I < E; ++I) {
1631 ITPL != ETPL; ++ITPL) {
1632 TRY_TO(TraverseDecl(*ITPL));
1633 }
1634 }
1635})
1636
1638
1640
1642 })
1643
1645 TRY_TO(TraverseStmt(D->getAssertExpr()));
1647})
1648
1650
1651
1652
1653
1654
1655
1656 auto Scope = D->getASTContext().getTraversalScope();
1657 bool HasLimitedScope =
1658 Scope.size() != 1 || !isa(Scope.front());
1659 if (HasLimitedScope) {
1661 for (auto *Child : Scope) {
1662 if (!canIgnoreChildDeclWhileTraversingDeclContext(Child))
1663 TRY_TO(TraverseDecl(Child));
1664 }
1665 }
1666})
1667
1669
1671
1673
1675 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1676
1677
1678
1680})
1681
1683 })
1684
1686 NamespaceDecl,
1687 {
1688
1689
1690 })
1691
1693 })
1694
1696 if (ObjCTypeParamList *typeParamList = D->getTypeParamList()) {
1697 for (auto typeParam : *typeParamList) {
1698 TRY_TO(TraverseObjCTypeParamDecl(typeParam));
1699 }
1700 }
1701 for (auto It : llvm::zip(D->protocols(), D->protocol_locs())) {
1702 ObjCProtocolLoc ProtocolLoc(std::get<0>(It), std::get<1>(It));
1703 TRY_TO(TraverseObjCProtocolLoc(ProtocolLoc));
1704 }
1705})
1706
1708 })
1709
1711 })
1712
1714 if (ObjCTypeParamList *typeParamList = D->getTypeParamListAsWritten()) {
1715 for (auto typeParam : *typeParamList) {
1716 TRY_TO(TraverseObjCTypeParamDecl(typeParam));
1717 }
1718 }
1719
1720 if (TypeSourceInfo *superTInfo = D->getSuperClassTInfo()) {
1721 TRY_TO(TraverseTypeLoc(superTInfo->getTypeLoc()));
1722 }
1723 if (D->isThisDeclarationADefinition()) {
1724 for (auto It : llvm::zip(D->protocols(), D->protocol_locs())) {
1725 ObjCProtocolLoc ProtocolLoc(std::get<0>(It), std::get<1>(It));
1726 TRY_TO(TraverseObjCProtocolLoc(ProtocolLoc));
1727 }
1728 }
1729})
1730
1732 if (D->isThisDeclarationADefinition()) {
1733 for (auto It : llvm::zip(D->protocols(), D->protocol_locs())) {
1734 ObjCProtocolLoc ProtocolLoc(std::get<0>(It), std::get<1>(It));
1735 TRY_TO(TraverseObjCProtocolLoc(ProtocolLoc));
1736 }
1737 }
1738})
1739
1741 if (D->getReturnTypeSourceInfo()) {
1742 TRY_TO(TraverseTypeLoc(D->getReturnTypeSourceInfo()->getTypeLoc()));
1743 }
1744 for (ParmVarDecl *Parameter : D->parameters()) {
1745 TRY_TO(TraverseDecl(Parameter));
1746 }
1747 if (D->isThisDeclarationADefinition()) {
1748 TRY_TO(TraverseStmt(D->getBody()));
1749 }
1751})
1752
1754 if (D->hasExplicitBound()) {
1755 TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1756
1757
1758
1759 }
1760})
1761
1763 if (D->getTypeSourceInfo())
1764 TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1765 else
1766 TRY_TO(TraverseType(D->getType()));
1768})
1769
1771 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1772 TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
1773})
1774
1776 { TRY_TO(TraverseTypeLoc(D->getEnumTypeLoc())); })
1777
1779
1781 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
1782})
1783
1785
1787
1789 for (auto *I : D->varlist()) {
1790 TRY_TO(TraverseStmt(I));
1791 }
1792})
1793
1795 for (auto *C : D->clauselists()) {
1796 TRY_TO(TraverseOMPClause(C));
1797 }
1798})
1799
1801 TRY_TO(TraverseStmt(D->getCombiner()));
1802 if (auto *Initializer = D->getInitializer())
1803 TRY_TO(TraverseStmt(Initializer));
1804 TRY_TO(TraverseType(D->getType()));
1805 return true;
1806})
1807
1809 for (auto *C : D->clauselists())
1810 TRY_TO(TraverseOMPClause(C));
1811 TRY_TO(TraverseType(D->getType()));
1812 return true;
1813})
1814
1816
1818 for (auto *I : D->varlist())
1819 TRY_TO(TraverseStmt(I));
1820 for (auto *C : D->clauselists())
1821 TRY_TO(TraverseOMPClause(C));
1822})
1823
1824
1825template
1826bool RecursiveASTVisitor::TraverseTemplateParameterListHelper(
1827 TemplateParameterList *TPL) {
1828 if (TPL) {
1829 for (NamedDecl *D : *TPL) {
1831 }
1832 if (Expr *RequiresClause = TPL->getRequiresClause()) {
1833 TRY_TO(TraverseStmt(RequiresClause));
1834 }
1835 }
1836 return true;
1837}
1838
1839template
1840template
1841bool RecursiveASTVisitor::TraverseDeclTemplateParameterLists(T *D) {
1842 for (unsigned i = 0; i < D->getNumTemplateParameterLists(); i++) {
1843 TemplateParameterList *TPL = D->getTemplateParameterList(i);
1844 TraverseTemplateParameterListHelper(TPL);
1845 }
1846 return true;
1847}
1848
1849template
1850bool RecursiveASTVisitor::TraverseTemplateInstantiations(
1851 ClassTemplateDecl *D) {
1852 for (auto *SD : D->specializations()) {
1853 for (auto *RD : SD->redecls()) {
1854 assert(!cast(RD)->isInjectedClassName());
1855 switch (
1856 cast(RD)->getSpecializationKind()) {
1857
1860 TRY_TO(TraverseDecl(RD));
1861 break;
1862
1863
1864
1865
1869 break;
1870 }
1871 }
1872 }
1873
1874 return true;
1875}
1876
1877template
1878bool RecursiveASTVisitor::TraverseTemplateInstantiations(
1879 VarTemplateDecl *D) {
1880 for (auto *SD : D->specializations()) {
1881 for (auto *RD : SD->redecls()) {
1882 switch (
1883 cast(RD)->getSpecializationKind()) {
1886 TRY_TO(TraverseDecl(RD));
1887 break;
1888
1892 break;
1893 }
1894 }
1895 }
1896
1897 return true;
1898}
1899
1900
1901
1902template
1903bool RecursiveASTVisitor::TraverseTemplateInstantiations(
1904 FunctionTemplateDecl *D) {
1905 for (auto *FD : D->specializations()) {
1906 for (auto *RD : FD->redecls()) {
1907 switch (RD->getTemplateSpecializationKind()) {
1910
1911 TRY_TO(TraverseDecl(RD));
1912 break;
1913
1914
1915
1918 TRY_TO(TraverseDecl(RD));
1919 break;
1920
1922 break;
1923 }
1924 }
1925 }
1926
1927 return true;
1928}
1929
1930
1931
1932#define DEF_TRAVERSE_TMPL_DECL(TMPLDECLKIND) \
1933 DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateDecl, { \
1934 TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \
1935 TRY_TO(TraverseDecl(D->getTemplatedDecl())); \
1936 \
1937
1938
1939
1940
1941
1942 \
1943 if (getDerived().shouldVisitTemplateInstantiations() && \
1944 D == D->getCanonicalDecl()) \
1945 TRY_TO(TraverseTemplateInstantiations(D)); \
1946 \
1947
1948
1949 \
1950 })
1951
1955
1957
1958
1959 TRY_TO(TraverseDecl(D->getTemplatedDecl()));
1960 if (D->hasDefaultArgument() && ->defaultArgumentWasInherited())
1961 TRY_TO(TraverseTemplateArgumentLoc(D->getDefaultArgument()));
1962 TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1963})
1964
1966 TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
1967})
1968
1969template
1970bool RecursiveASTVisitor::TraverseTemplateTypeParamDeclConstraints(
1971 const TemplateTypeParmDecl *D) {
1972 if (const auto *TC = D->getTypeConstraint())
1973 TRY_TO(TraverseTypeConstraint(TC));
1974 return true;
1975}
1976
1978
1979 if (D->getTypeForDecl())
1980 TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
1981 TRY_TO(TraverseTemplateTypeParamDeclConstraints(D));
1982 if (D->hasDefaultArgument() && ->defaultArgumentWasInherited())
1983 TRY_TO(TraverseTemplateArgumentLoc(D->getDefaultArgument()));
1984})
1985
1987 TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1988
1989
1990
1991})
1992
1994 TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
1995
1996
1997
1998})
1999
2001 TRY_TO(TraverseDecl(D->getTemplatedDecl()));
2002 TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
2003})
2004
2006 TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
2007 TRY_TO(TraverseStmt(D->getConstraintExpr()));
2008})
2009
2011
2012
2013 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
2014
2015
2016
2017})
2018
2020
2022 TRY_TO(TraverseDeclTemplateParameterLists(D));
2023
2024 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
2025 if (auto *TSI = D->getIntegerTypeSourceInfo())
2026 TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
2027
2028
2029})
2030
2031
2032template
2033bool RecursiveASTVisitor::TraverseRecordHelper(RecordDecl *D) {
2034
2035
2036
2037 TRY_TO(TraverseDeclTemplateParameterLists(D));
2038 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
2039 return true;
2040}
2041
2042template
2043bool RecursiveASTVisitor::TraverseCXXBaseSpecifier(
2044 const CXXBaseSpecifier &Base) {
2045 TRY_TO(TraverseTypeLoc(Base.getTypeSourceInfo()->getTypeLoc()));
2046 return true;
2047}
2048
2049template
2050bool RecursiveASTVisitor::TraverseCXXRecordHelper(CXXRecordDecl *D) {
2051 if (!TraverseRecordHelper(D))
2052 return false;
2053 if (D->isCompleteDefinition()) {
2054 for (const auto &I : D->bases()) {
2055 TRY_TO(TraverseCXXBaseSpecifier(I));
2056 }
2057
2058
2059 }
2060 return true;
2061}
2062
2064
2066
2067template
2068bool RecursiveASTVisitor::TraverseTemplateArgumentLocsHelper(
2069 const TemplateArgumentLoc *TAL, unsigned Count) {
2070 for (unsigned I = 0; I < Count; ++I) {
2071 TRY_TO(TraverseTemplateArgumentLoc(TAL[I]));
2072 }
2073 return true;
2074}
2075
2076#define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND, DECLKIND) \
2077 DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateSpecializationDecl, { \
2078
2079
2080
2081
2082
2083
2084
2085 \
2086 if (const auto *ArgsWritten = D->getTemplateArgsAsWritten()) { \
2087 \
2088 TRY_TO(TraverseTemplateArgumentLocsHelper( \
2089 ArgsWritten->getTemplateArgs(), ArgsWritten->NumTemplateArgs)); \
2090 } \
2091 \
2092 if (getDerived().shouldVisitTemplateInstantiations() || \
2093 D->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) { \
2094 \
2095 TRY_TO(Traverse##DECLKIND##Helper(D)); \
2096 } else { \
2097 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc())); \
2098 \
2099
2100
2101
2102 \
2103 return true; \
2104 } \
2105 })
2106
2109
2110#define DEF_TRAVERSE_TMPL_PART_SPEC_DECL(TMPLDECLKIND, DECLKIND) \
2111 DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplatePartialSpecializationDecl, { \
2112 \
2113 TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \
2114 \
2115 TRY_TO(TraverseTemplateArgumentLocsHelper( \
2116 D->getTemplateArgsAsWritten()->getTemplateArgs(), \
2117 D->getTemplateArgsAsWritten()->NumTemplateArgs)); \
2118 \
2119
2120
2121 \
2122 TRY_TO(Traverse##DECLKIND##Helper(D)); \
2123 \
2124 \
2125 })
2126
2129
2131
2133
2134
2135 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
2136 TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
2137})
2138
2140
2141template
2142bool RecursiveASTVisitor::TraverseDeclaratorHelper(DeclaratorDecl *D) {
2143 TRY_TO(TraverseDeclTemplateParameterLists(D));
2144 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
2145 if (D->getTypeSourceInfo())
2146 TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc()));
2147 else
2148 TRY_TO(TraverseType(D->getType()));
2149 return true;
2150}
2151
2153 TRY_TO(TraverseVarHelper(D));
2154 for (auto *Binding : D->bindings()) {
2155 TRY_TO(TraverseDecl(Binding));
2156 }
2157})
2158
2160 if (getDerived().shouldVisitImplicitCode()) {
2161 TRY_TO(TraverseStmt(D->getBinding()));
2162 if (const auto HoldingVar = D->getHoldingVar())
2163 TRY_TO(TraverseDecl(HoldingVar));
2164 }
2165})
2166
2168
2171
2173
2175 TRY_TO(TraverseDeclaratorHelper(D));
2176 if (D->isBitField())
2177 TRY_TO(TraverseStmt(D->getBitWidth()));
2178 if (D->hasInClassInitializer())
2179 TRY_TO(TraverseStmt(D->getInClassInitializer()));
2180})
2181
2183 TRY_TO(TraverseDeclaratorHelper(D));
2184 if (D->isBitField())
2185 TRY_TO(TraverseStmt(D->getBitWidth()));
2186
2187})
2188
2190 TRY_TO(TraverseDeclaratorHelper(D));
2191 if (D->isBitField())
2192 TRY_TO(TraverseStmt(D->getBitWidth()));
2193
2194})
2195
2196template
2197bool RecursiveASTVisitor::TraverseFunctionHelper(FunctionDecl *D) {
2198 TRY_TO(TraverseDeclTemplateParameterLists(D));
2199 TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
2200 TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo()));
2201
2202
2203
2204
2205
2206
2207 if (const FunctionTemplateSpecializationInfo *FTSI =
2208 D->getTemplateSpecializationInfo()) {
2209 if (FTSI->getTemplateSpecializationKind() != TSK_Undeclared &&
2210 FTSI->getTemplateSpecializationKind() != TSK_ImplicitInstantiation) {
2211
2212
2213 if (const ASTTemplateArgumentListInfo *TALI =
2214 FTSI->TemplateArgumentsAsWritten) {
2215 TRY_TO(TraverseTemplateArgumentLocsHelper(TALI->getTemplateArgs(),
2216 TALI->NumTemplateArgs));
2217 }
2218 }
2219 } else if (const DependentFunctionTemplateSpecializationInfo *DFSI =
2220 D->getDependentSpecializationInfo()) {
2221 if (const ASTTemplateArgumentListInfo *TALI =
2222 DFSI->TemplateArgumentsAsWritten) {
2223 TRY_TO(TraverseTemplateArgumentLocsHelper(TALI->getTemplateArgs(),
2224 TALI->NumTemplateArgs));
2225 }
2226 }
2227
2228
2229
2230
2231
2232 if (TypeSourceInfo *TSI = D->getTypeSourceInfo()) {
2233 TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
2234 } else if (getDerived().shouldVisitImplicitCode()) {
2235
2236
2237
2238
2239 for (ParmVarDecl *Parameter : D->parameters()) {
2240 TRY_TO(TraverseDecl(Parameter));
2241 }
2242 }
2243
2244
2245 if (Expr *TrailingRequiresClause = D->getTrailingRequiresClause()) {
2246 TRY_TO(TraverseStmt(TrailingRequiresClause));
2247 }
2248
2249 if (CXXConstructorDecl *Ctor = dyn_cast(D)) {
2250
2251 for (auto *I : Ctor->inits()) {
2252 if (I->isWritten() || getDerived().shouldVisitImplicitCode())
2253 TRY_TO(TraverseConstructorInitializer(I));
2254 }
2255 }
2256
2257 bool VisitBody =
2258 D->isThisDeclarationADefinition() &&
2259
2260
2261 (->isDefaulted() || getDerived().shouldVisitImplicitCode());
2262
2263 if (const auto *MD = dyn_cast(D)) {
2264 if (const CXXRecordDecl *RD = MD->getParent()) {
2265 if (RD->isLambda() &&
2267 VisitBody = VisitBody && getDerived().shouldVisitLambdaBody();
2268 }
2269 }
2270 }
2271
2272 if (VisitBody) {
2273 TRY_TO(TraverseStmt(D->getBody()));
2274
2275
2276 for (auto *Child : D->decls()) {
2277 if (isa(Child))
2278 TRY_TO(TraverseDecl(Child));
2279 }
2280 }
2281 return true;
2282}
2283
2285
2286
2289})
2290
2292
2293
2296})
2297
2299
2300
2303})
2304
2306
2307
2310})
2311
2312
2313
2315
2316
2319})
2320
2322
2323
2326})
2327
2328template
2329bool RecursiveASTVisitor::TraverseVarHelper(VarDecl *D) {
2330 TRY_TO(TraverseDeclaratorHelper(D));
2331
2332 if (!isa(D) &&
2333 (->isCXXForRangeDecl() || getDerived().shouldVisitImplicitCode()))
2334 TRY_TO(TraverseStmt(D->getInit()));
2335 return true;
2336}
2337
2339
2341
2343
2344 TRY_TO(TraverseDeclaratorHelper(D));
2345 if (D->hasDefaultArgument() && ->defaultArgumentWasInherited())
2346 TRY_TO(TraverseTemplateArgumentLoc(D->getDefaultArgument()));
2347})
2348
2350 TRY_TO(TraverseVarHelper(D));
2351
2352 if (D->hasDefaultArg() && D->hasUninstantiatedDefaultArg() &&
2353 ->hasUnparsedDefaultArg())
2354 TRY_TO(TraverseStmt(D->getUninstantiatedDefaultArg()));
2355
2356 if (D->hasDefaultArg() && ->hasUninstantiatedDefaultArg() &&
2357 ->hasUnparsedDefaultArg())
2358 TRY_TO(TraverseStmt(D->getDefaultArg()));
2359})
2360
2362
2364 TRY_TO(TraverseTemplateArguments(D->getTemplateArguments()));
2365})
2366
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2380 template \
2381 bool RecursiveASTVisitor::Traverse##STMT( \
2382 STMT *S, DataRecursionQueue *Queue) { \
2385 if (!getDerived().shouldTraversePostOrder()) \
2386 TRY_TO(WalkUpFrom##STMT(S)); \
2387 { CODE; } \
2388 if (ShouldVisitChildren) { \
2389 for (Stmt * SubStmt : getDerived().getStmtChildren(S)) { \
2390 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(SubStmt); \
2391 } \
2392 } \
2393
2394
2395
2396 \
2397 if (!Queue && ReturnValue && getDerived().shouldTraversePostOrder()) { \
2398 TRY_TO(WalkUpFrom##STMT(S)); \
2399 } \
2401 }
2402
2405 for (unsigned I = 0, E = S->getNumInputs(); I < E; ++I) {
2407 }
2408 for (unsigned I = 0, E = S->getNumOutputs(); I < E; ++I) {
2410 }
2411 for (unsigned I = 0, E = S->getNumClobbers(); I < E; ++I) {
2413 }
2414
2415})
2416
2418 MSAsmStmt,
2419 {
2420
2421 })
2422
2424 TRY_TO(TraverseDecl(S->getExceptionDecl()));
2425
2426})
2427
2429 for (auto *I : S->decls()) {
2430 TRY_TO(TraverseDecl(I));
2431 }
2432
2433
2434
2435
2436
2438})
2439
2440
2441
2463
2465 if (!getDerived().shouldVisitImplicitCode()) {
2466 if (S->getInit())
2471
2473 }
2474})
2475
2477 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2478 TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2479})
2480
2484
2486
2488 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2489 TRY_TO(TraverseDeclarationNameInfo(S->getMemberNameInfo()));
2490 if (S->hasExplicitTemplateArgs()) {
2491 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2492 S->getNumTemplateArgs()));
2493 }
2494})
2495
2497 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2498 TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2499 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2500 S->getNumTemplateArgs()));
2501})
2502
2504 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2505 TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
2506 if (S->hasExplicitTemplateArgs()) {
2507 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2508 S->getNumTemplateArgs()));
2509 }
2510})
2511
2513 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2514 TRY_TO(TraverseDeclarationNameInfo(S->getMemberNameInfo()));
2515 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2516 S->getNumTemplateArgs()));
2517})
2518
2520 ImplicitCastExpr,
2521 {
2522
2523 })
2524
2526 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2527})
2528
2530 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2531})
2532
2534 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2535})
2536
2538 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2539})
2540
2542 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2543})
2544
2546 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2547})
2548
2550 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2551})
2552
2554 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2555})
2556
2557template
2558bool RecursiveASTVisitor::TraverseSynOrSemInitListExpr(
2559 InitListExpr *S, DataRecursionQueue *Queue) {
2560 if (S) {
2561
2562
2563 if (!getDerived().shouldTraversePostOrder())
2564 TRY_TO(WalkUpFromInitListExpr(S));
2565
2566
2567 for (Stmt *SubStmt : S->children()) {
2569 }
2570
2571 if (!Queue && getDerived().shouldTraversePostOrder())
2572 TRY_TO(WalkUpFromInitListExpr(S));
2573 }
2574 return true;
2575}
2576
2577template
2578bool RecursiveASTVisitor::TraverseObjCProtocolLoc(
2579 ObjCProtocolLoc ProtocolLoc) {
2580 return true;
2581}
2582
2583template
2584bool RecursiveASTVisitor::TraverseConceptReference(
2585 ConceptReference *CR) {
2586 if (!getDerived().shouldTraversePostOrder())
2587 TRY_TO(VisitConceptReference(CR));
2588 TRY_TO(TraverseNestedNameSpecifierLoc(CR->getNestedNameSpecifierLoc()));
2589 TRY_TO(TraverseDeclarationNameInfo(CR->getConceptNameInfo()));
2590 if (CR->hasExplicitTemplateArgs())
2591 TRY_TO(TraverseTemplateArgumentLocsHelper(
2592 CR->getTemplateArgsAsWritten()->getTemplateArgs(),
2593 CR->getTemplateArgsAsWritten()->NumTemplateArgs));
2594 if (getDerived().shouldTraversePostOrder())
2595 TRY_TO(VisitConceptReference(CR));
2596 return true;
2597}
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607template
2608bool RecursiveASTVisitor::TraverseInitListExpr(
2609 InitListExpr *S, DataRecursionQueue *Queue) {
2610 if (S->isSemanticForm() && S->isSyntacticForm()) {
2611
2612 TRY_TO(TraverseSynOrSemInitListExpr(S, Queue));
2613 return true;
2614 }
2615 TRY_TO(TraverseSynOrSemInitListExpr(
2616 S->isSemanticForm() ? S->getSyntacticForm() : S, Queue));
2617 if (getDerived().shouldVisitImplicitCode()) {
2618
2619
2620 TRY_TO(TraverseSynOrSemInitListExpr(
2621 S->isSemanticForm() ? S : S->getSemanticForm(), Queue));
2622 }
2623 return true;
2624}
2625
2626
2627
2628
2630 if (S->isExprPredicate())
2631 TRY_TO(TraverseStmt(S->getControllingExpr()));
2632 else
2633 TRY_TO(TraverseTypeLoc(S->getControllingType()->getTypeLoc()));
2634
2635 for (const GenericSelectionExpr::Association Assoc : S->associations()) {
2636 if (TypeSourceInfo *TSI = Assoc.getTypeSourceInfo())
2637 TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
2638 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(Assoc.getAssociationExpr());
2639 }
2640 ShouldVisitChildren = false;
2641})
2642
2643
2644
2647 for (PseudoObjectExpr::semantics_iterator i = S->semantics_begin(),
2648 e = S->semantics_end();
2649 i != e; ++i) {
2650 Expr *sub = *i;
2651 if (OpaqueValueExpr *OVE = dyn_cast(sub))
2652 sub = OVE->getSourceExpr();
2654 }
2656})
2657
2659
2660
2661 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2662})
2663
2665
2666 TRY_TO(TraverseTypeLoc(S->getAllocatedTypeSourceInfo()->getTypeLoc()));
2667})
2668
2670
2671
2672
2673
2674 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2675})
2676
2678
2679
2680 if (S->isArgumentType())
2681 TRY_TO(TraverseTypeLoc(S->getArgumentTypeInfo()->getTypeLoc()));
2682})
2683
2685
2686
2687 if (S->isTypeOperand())
2688 TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
2689})
2690
2692 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2693})
2694
2696
2698
2699
2700 if (S->isTypeOperand())
2701 TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
2702})
2703
2705 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
2706 TRY_TO(TraverseTypeLoc(S->getArg(I)->getTypeLoc()));
2707})
2708
2710 TRY_TO(TraverseTypeLoc(S->getQueriedTypeSourceInfo()->getTypeLoc()));
2711})
2712
2715
2717
2718 TRY_TO(TraverseTypeLoc(S->getWrittenTypeInfo()->getTypeLoc()));
2719})
2720
2722
2723 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2724})
2725
2726
2728
2729 for (unsigned I = 0, N = S->capture_size(); I != N; ++I) {
2730 const LambdaCapture *C = S->capture_begin() + I;
2731 if (C->isExplicit() || getDerived().shouldVisitImplicitCode()) {
2732 TRY_TO(TraverseLambdaCapture(S, C, S->capture_init_begin()[I]));
2733 }
2734 }
2735
2736 if (getDerived().shouldVisitImplicitCode()) {
2737
2738 TRY_TO(TraverseDecl(S->getLambdaClass()));
2739 } else {
2740
2741 TypeLoc TL = S->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
2742 FunctionProtoTypeLoc Proto = TL.getAsAdjusted();
2743
2744 TRY_TO(TraverseTemplateParameterListHelper(S->getTemplateParameterList()));
2745 if (S->hasExplicitParameters()) {
2746
2747 for (unsigned I = 0, N = Proto.getNumParams(); I != N; ++I)
2748 TRY_TO(TraverseDecl(Proto.getParam(I)));
2749 }
2750
2751 auto *T = Proto.getTypePtr();
2754
2757
2758 if (S->hasExplicitResultType())
2759 TRY_TO(TraverseTypeLoc(Proto.getReturnLoc()));
2761
2763 }
2765})
2766
2768
2769 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2770})
2771
2772
2773
2777
2778
2779
2786
2788 TRY_TO(TraverseDecl(S->getBlockDecl()));
2789 return true;
2790})
2791
2794 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2795})
2798
2800 if (getDerived().shouldVisitImplicitCode())
2801 TRY_TO(TraverseStmt(S->getExpr()));
2802})
2803
2805 if (getDerived().shouldVisitImplicitCode())
2806 TRY_TO(TraverseStmt(S->getExpr()));
2807})
2808
2814
2816 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2817 if (TypeSourceInfo *ScopeInfo = S->getScopeTypeInfo())
2818 TRY_TO(TraverseTypeLoc(ScopeInfo->getTypeLoc()));
2819 if (TypeSourceInfo *DestroyedTypeInfo = S->getDestroyedTypeInfo())
2820 TRY_TO(TraverseTypeLoc(DestroyedTypeInfo->getTypeLoc()));
2821})
2822
2833
2834
2835 if (OpaqueValueExpr *OVE = S->getCommonExpr())
2837})
2840
2842 if (TypeSourceInfo *TInfo = S->getEncodedTypeSourceInfo())
2843 TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
2844})
2845
2848
2850 if (TypeSourceInfo *TInfo = S->getClassReceiverTypeInfo())
2851 TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
2852})
2853
2855 if (S->isClassReceiver()) {
2856 ObjCInterfaceDecl *IDecl = S->getClassReceiver();
2857 QualType Type = IDecl->getASTContext().getObjCInterfaceType(IDecl);
2858 ObjCInterfaceLocInfo Data;
2859 Data.NameLoc = S->getReceiverLocation();
2860 Data.NameEndLoc = Data.NameLoc;
2862 }
2863})
2868
2870 TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
2871})
2872
2877 TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
2878})
2886 for (IntegerLiteral *IL : S->underlying_data_elements()) {
2888 }
2889})
2890
2892 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2893 if (S->hasExplicitTemplateArgs()) {
2894 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2895 S->getNumTemplateArgs()));
2896 }
2897})
2898
2900 TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
2901 if (S->hasExplicitTemplateArgs()) {
2902 TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
2903 S->getNumTemplateArgs()));
2904 }
2905})
2906
2912
2914 if (getDerived().shouldVisitImplicitCode()) {
2915 TRY_TO(TraverseStmt(S->getOriginalStmt()));
2916 TRY_TO(TraverseDecl(S->getOutlinedFunctionDecl()));
2918 }
2919})
2920
2923 if (!getDerived().shouldVisitImplicitCode()) {
2924 CXXRewrittenBinaryOperator::DecomposedForm Decomposed =
2925 S->getDecomposedForm();
2926 TRY_TO(TraverseStmt(const_cast<Expr*>(Decomposed.LHS)));
2927 TRY_TO(TraverseStmt(const_cast<Expr*>(Decomposed.RHS)));
2929 }
2930})
2935
2936
2937
2953
2955 if (S->getLifetimeExtendedTemporaryDecl()) {
2956 TRY_TO(TraverseLifetimeExtendedTemporaryDecl(
2957 S->getLifetimeExtendedTemporaryDecl()));
2959 }
2960})
2961
2962
2963
2965 if (!getDerived().shouldVisitImplicitCode()) {
2968 }
2969})
2971 if (!getDerived().shouldVisitImplicitCode()) {
2974 }
2975})
2977 if (!getDerived().shouldVisitImplicitCode()) {
2980 }
2981})
2983 if (!getDerived().shouldVisitImplicitCode()) {
2986 }
2987})
2989 if (!getDerived().shouldVisitImplicitCode()) {
2992 }
2993})
2994
2996 TRY_TO(TraverseConceptReference(S->getConceptReference()));
2997})
2998
3000 TRY_TO(TraverseDecl(S->getBody()));
3001 for (ParmVarDecl *Parm : S->getLocalParameters())
3002 TRY_TO(TraverseDecl(Parm));
3003 for (concepts::Requirement *Req : S->getRequirements())
3004 TRY_TO(TraverseConceptRequirement(Req));
3005})
3006
3007
3018
3019
3021
3022
3023template
3024bool RecursiveASTVisitor::TraverseOMPExecutableDirective(
3025 OMPExecutableDirective *S) {
3026 for (auto *C : S->clauses()) {
3027 TRY_TO(TraverseOMPClause(C));
3028 }
3029 return true;
3030}
3031
3033 if (!getDerived().shouldVisitImplicitCode()) {
3034
3035 TRY_TO(TraverseStmt(S->getLoopStmt()));
3037 }
3038})
3039
3040template
3041bool
3042RecursiveASTVisitor::TraverseOMPLoopDirective(OMPLoopDirective *S) {
3043 return TraverseOMPExecutableDirective(S);
3044}
3045
3047 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3048
3050 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3051
3053 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3054
3056 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3057
3059 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3060
3062 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3063
3065 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3066
3068 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3069
3071 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3072
3074 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3075
3077 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3078
3080 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3081
3083 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3084
3086 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3087
3089 TRY_TO(TraverseDeclarationNameInfo(S->getDirectiveName()));
3090 TRY_TO(TraverseOMPExecutableDirective(S));
3091})
3092
3094 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3095
3097 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3098
3100 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3101
3103 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3104
3106 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3107
3109 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3110
3112 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3113
3115 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3116
3118 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3119
3121 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3122
3124 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3125
3127 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3128
3130 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3131
3133 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3134
3136 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3137
3139 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3140
3142 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3143
3145 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3146
3148 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3149
3151 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3152
3154 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3155
3157 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3158
3160 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3161
3163 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3164
3166 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3167
3169 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3170
3172 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3173
3175 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3176
3178 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3179
3181 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3182
3184 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3185
3187 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3188
3190 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3191
3193 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3194
3196 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3197
3199 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3200
3202 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3203
3205 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3206
3208 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3209
3211 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3212
3214 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3215
3217 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3218
3220 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3221
3223 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3224
3226 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3227
3229 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3230
3232 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3233
3235 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3236
3237DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeParallelForSimdDirective,
3238 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3239
3241 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3242
3244 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3245
3247 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3248
3250 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3251
3253 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3254
3256 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3257
3259 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3260
3262 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3263
3265 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3266
3268 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3269
3271 { TRY_TO(TraverseOMPExecutableDirective(S)); })
3272
3273
3274template
3275bool RecursiveASTVisitor::TraverseOMPClause(OMPClause *C) {
3276 if (!C)
3277 return true;
3278 switch (C->getClauseKind()) {
3279#define GEN_CLANG_CLAUSE_CLASS
3280#define CLAUSE_CLASS(Enum, Str, Class) \
3281 case llvm::omp::Clause::Enum: \
3282 TRY_TO(Visit##Class(static_cast<Class *>(C))); \
3283 break;
3284#define CLAUSE_NO_CLASS(Enum, Str) \
3285 case llvm::omp::Clause::Enum: \
3286 break;
3287#include "llvm/Frontend/OpenMP/OMP.inc"
3288 }
3289 return true;
3290}
3291
3292template
3293bool RecursiveASTVisitor::VisitOMPClauseWithPreInit(
3294 OMPClauseWithPreInit *Node) {
3295 TRY_TO(TraverseStmt(Node->getPreInitStmt()));
3296 return true;
3297}
3298
3299template
3300bool RecursiveASTVisitor::VisitOMPClauseWithPostUpdate(
3301 OMPClauseWithPostUpdate *Node) {
3302 TRY_TO(VisitOMPClauseWithPreInit(Node));
3303 TRY_TO(TraverseStmt(Node->getPostUpdateExpr()));
3304 return true;
3305}
3306
3307template
3308bool RecursiveASTVisitor::VisitOMPAllocatorClause(
3309 OMPAllocatorClause *C) {
3310 TRY_TO(TraverseStmt(C->getAllocator()));
3311 return true;
3312}
3313
3314template
3315bool RecursiveASTVisitor::VisitOMPAllocateClause(OMPAllocateClause *C) {
3316 TRY_TO(TraverseStmt(C->getAllocator()));
3317 TRY_TO(VisitOMPClauseList(C));
3318 return true;
3319}
3320
3321template
3322bool RecursiveASTVisitor::VisitOMPIfClause(OMPIfClause *C) {
3323 TRY_TO(VisitOMPClauseWithPreInit(C));
3324 TRY_TO(TraverseStmt(C->getCondition()));
3325 return true;
3326}
3327
3328template
3329bool RecursiveASTVisitor::VisitOMPFinalClause(OMPFinalClause *C) {
3330 TRY_TO(VisitOMPClauseWithPreInit(C));
3331 TRY_TO(TraverseStmt(C->getCondition()));
3332 return true;
3333}
3334
3335template
3336bool
3337RecursiveASTVisitor::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) {
3338 TRY_TO(VisitOMPClauseWithPreInit(C));
3339 TRY_TO(TraverseStmt(C->getNumThreads()));
3340 return true;
3341}
3342
3343template
3344bool RecursiveASTVisitor::VisitOMPAlignClause(OMPAlignClause *C) {
3345 TRY_TO(TraverseStmt(C->getAlignment()));
3346 return true;
3347}
3348
3349template
3350bool RecursiveASTVisitor::VisitOMPSafelenClause(OMPSafelenClause *C) {
3351 TRY_TO(TraverseStmt(C->getSafelen()));
3352 return true;
3353}
3354
3355template
3356bool RecursiveASTVisitor::VisitOMPSimdlenClause(OMPSimdlenClause *C) {
3357 TRY_TO(TraverseStmt(C->getSimdlen()));
3358 return true;
3359}
3360
3361template
3362bool RecursiveASTVisitor::VisitOMPSizesClause(OMPSizesClause *C) {
3363 for (Expr *E : C->getSizesRefs())
3365 return true;
3366}
3367
3368template
3369bool RecursiveASTVisitor::VisitOMPPermutationClause(
3370 OMPPermutationClause *C) {
3371 for (Expr *E : C->getArgsRefs())
3373 return true;
3374}
3375
3376template
3377bool RecursiveASTVisitor::VisitOMPFullClause(OMPFullClause *C) {
3378 return true;
3379}
3380
3381template
3382bool RecursiveASTVisitor::VisitOMPPartialClause(OMPPartialClause *C) {
3383 TRY_TO(TraverseStmt(C->getFactor()));
3384 return true;
3385}
3386
3387template
3388bool
3389RecursiveASTVisitor::VisitOMPCollapseClause(OMPCollapseClause *C) {
3390 TRY_TO(TraverseStmt(C->getNumForLoops()));
3391 return true;
3392}
3393
3394template
3395bool RecursiveASTVisitor::VisitOMPDefaultClause(OMPDefaultClause *) {
3396 return true;
3397}
3398
3399template
3400bool RecursiveASTVisitor::VisitOMPProcBindClause(OMPProcBindClause *) {
3401 return true;
3402}
3403
3404template
3405bool RecursiveASTVisitor::VisitOMPUnifiedAddressClause(
3406 OMPUnifiedAddressClause *) {
3407 return true;
3408}
3409
3410template
3411bool RecursiveASTVisitor::VisitOMPUnifiedSharedMemoryClause(
3412 OMPUnifiedSharedMemoryClause *) {
3413 return true;
3414}
3415
3416template
3417bool RecursiveASTVisitor::VisitOMPReverseOffloadClause(
3418 OMPReverseOffloadClause *) {
3419 return true;
3420}
3421
3422template
3423bool RecursiveASTVisitor::VisitOMPDynamicAllocatorsClause(
3424 OMPDynamicAllocatorsClause *) {
3425 return true;
3426}
3427
3428template
3429bool RecursiveASTVisitor::VisitOMPAtomicDefaultMemOrderClause(
3430 OMPAtomicDefaultMemOrderClause *) {
3431 return true;
3432}
3433
3434template
3435bool RecursiveASTVisitor::VisitOMPAtClause(OMPAtClause *) {
3436 return true;
3437}
3438
3439template
3440bool RecursiveASTVisitor::VisitOMPSeverityClause(OMPSeverityClause *) {
3441 return true;
3442}
3443
3444template
3445bool RecursiveASTVisitor::VisitOMPMessageClause(OMPMessageClause *C) {
3446 TRY_TO(TraverseStmt(C->getMessageString()));
3447 return true;
3448}
3449
3450template
3451bool
3452RecursiveASTVisitor::VisitOMPScheduleClause(OMPScheduleClause *C) {
3453 TRY_TO(VisitOMPClauseWithPreInit(C));
3454 TRY_TO(TraverseStmt(C->getChunkSize()));
3455 return true;
3456}
3457
3458template
3459bool RecursiveASTVisitor::VisitOMPOrderedClause(OMPOrderedClause *C) {
3460 TRY_TO(TraverseStmt(C->getNumForLoops()));
3461 return true;
3462}
3463
3464template
3465bool RecursiveASTVisitor::VisitOMPNowaitClause(OMPNowaitClause *) {
3466 return true;
3467}
3468
3469template
3470bool RecursiveASTVisitor::VisitOMPUntiedClause(OMPUntiedClause *) {
3471 return true;
3472}
3473
3474template
3475bool
3476RecursiveASTVisitor::VisitOMPMergeableClause(OMPMergeableClause *) {
3477 return true;
3478}
3479
3480template
3481bool RecursiveASTVisitor::VisitOMPReadClause(OMPReadClause *) {
3482 return true;
3483}
3484
3485template
3486bool RecursiveASTVisitor::VisitOMPWriteClause(OMPWriteClause *) {
3487 return true;
3488}
3489
3490template
3491bool RecursiveASTVisitor::VisitOMPUpdateClause(OMPUpdateClause *) {
3492 return true;
3493}
3494
3495template
3496bool RecursiveASTVisitor::VisitOMPCaptureClause(OMPCaptureClause *) {
3497 return true;
3498}
3499
3500template
3501bool RecursiveASTVisitor::VisitOMPCompareClause(OMPCompareClause *) {
3502 return true;
3503}
3504
3505template
3506bool RecursiveASTVisitor::VisitOMPFailClause(OMPFailClause *) {
3507 return true;
3508}
3509
3510template
3511bool RecursiveASTVisitor::VisitOMPSeqCstClause(OMPSeqCstClause *) {
3512 return true;
3513}
3514
3515template
3516bool RecursiveASTVisitor::VisitOMPAcqRelClause(OMPAcqRelClause *) {
3517 return true;
3518}
3519
3520template
3521bool RecursiveASTVisitor::VisitOMPAbsentClause(OMPAbsentClause *) {
3522 return true;
3523}
3524
3525template
3526bool RecursiveASTVisitor::VisitOMPHoldsClause(OMPHoldsClause *) {
3527 return true;
3528}
3529
3530template
3531bool RecursiveASTVisitor::VisitOMPContainsClause(OMPContainsClause *) {
3532 return true;
3533}
3534
3535template
3536bool RecursiveASTVisitor::VisitOMPNoOpenMPClause(OMPNoOpenMPClause *) {
3537 return true;
3538}
3539
3540template
3541bool RecursiveASTVisitor::VisitOMPNoOpenMPRoutinesClause(
3542 OMPNoOpenMPRoutinesClause *) {
3543 return true;
3544}
3545
3546template
3547bool RecursiveASTVisitor::VisitOMPNoParallelismClause(
3548 OMPNoParallelismClause *) {
3549 return true;
3550}
3551
3552template
3553bool RecursiveASTVisitor::VisitOMPAcquireClause(OMPAcquireClause *) {
3554 return true;
3555}
3556
3557template
3558bool RecursiveASTVisitor::VisitOMPReleaseClause(OMPReleaseClause *) {
3559 return true;
3560}
3561
3562template
3563bool RecursiveASTVisitor::VisitOMPRelaxedClause(OMPRelaxedClause *) {
3564 return true;
3565}
3566
3567template
3568bool RecursiveASTVisitor::VisitOMPWeakClause(OMPWeakClause *) {
3569 return true;
3570}
3571
3572template
3573bool RecursiveASTVisitor::VisitOMPThreadsClause(OMPThreadsClause *) {
3574 return true;
3575}
3576
3577template
3578bool RecursiveASTVisitor::VisitOMPSIMDClause(OMPSIMDClause *) {
3579 return true;
3580}
3581
3582template
3583bool RecursiveASTVisitor::VisitOMPNogroupClause(OMPNogroupClause *) {
3584 return true;
3585}
3586
3587template
3588bool RecursiveASTVisitor::VisitOMPInitClause(OMPInitClause *C) {
3589 TRY_TO(VisitOMPClauseList(C));
3590 return true;
3591}
3592
3593template
3594bool RecursiveASTVisitor::VisitOMPUseClause(OMPUseClause *C) {
3595 TRY_TO(TraverseStmt(C->getInteropVar()));
3596 return true;
3597}
3598
3599template
3600bool RecursiveASTVisitor::VisitOMPDestroyClause(OMPDestroyClause *C) {
3601 TRY_TO(TraverseStmt(C->getInteropVar()));
3602 return true;
3603}
3604
3605template
3606bool RecursiveASTVisitor::VisitOMPNovariantsClause(
3607 OMPNovariantsClause *C) {
3608 TRY_TO(VisitOMPClauseWithPreInit(C));
3609 TRY_TO(TraverseStmt(C->getCondition()));
3610 return true;
3611}
3612
3613template
3614bool RecursiveASTVisitor::VisitOMPNocontextClause(
3615 OMPNocontextClause *C) {
3616 TRY_TO(VisitOMPClauseWithPreInit(C));
3617 TRY_TO(TraverseStmt(C->getCondition()));
3618 return true;
3619}
3620
3621template
3622template
3623bool RecursiveASTVisitor::VisitOMPClauseList(T *Node) {
3624 for (auto *E : Node->varlist()) {
3626 }
3627 return true;
3628}
3629
3630template
3631bool RecursiveASTVisitor::VisitOMPInclusiveClause(
3632 OMPInclusiveClause *C) {
3633 TRY_TO(VisitOMPClauseList(C));
3634 return true;
3635}
3636
3637template
3638bool RecursiveASTVisitor::VisitOMPExclusiveClause(
3639 OMPExclusiveClause *C) {
3640 TRY_TO(VisitOMPClauseList(C));
3641 return true;
3642}
3643
3644template
3645bool RecursiveASTVisitor::VisitOMPPrivateClause(OMPPrivateClause *C) {
3646 TRY_TO(VisitOMPClauseList(C));
3647 for (auto *E : C->private_copies()) {
3649 }
3650 return true;
3651}
3652
3653template
3654bool RecursiveASTVisitor::VisitOMPFirstprivateClause(
3655 OMPFirstprivateClause *C) {
3656 TRY_TO(VisitOMPClauseList(C));
3657 TRY_TO(VisitOMPClauseWithPreInit(C));
3658 for (auto *E : C->private_copies()) {
3660 }
3661 for (auto *E : C->inits()) {
3663 }
3664 return true;
3665}
3666
3667template
3668bool RecursiveASTVisitor::VisitOMPLastprivateClause(
3669 OMPLastprivateClause *C) {
3670 TRY_TO(VisitOMPClauseList(C));
3671 TRY_TO(VisitOMPClauseWithPostUpdate(C));
3672 for (auto *E : C->private_copies()) {
3674 }
3675 for (auto *E : C->source_exprs()) {
3677 }
3678 for (auto *E : C->destination_exprs()) {
3680 }
3681 for (auto *E : C->assignment_ops()) {
3683 }
3684 return true;
3685}
3686
3687template
3688bool RecursiveASTVisitor::VisitOMPSharedClause(OMPSharedClause *C) {
3689 TRY_TO(VisitOMPClauseList(C));
3690 return true;
3691}
3692
3693template
3694bool RecursiveASTVisitor::VisitOMPLinearClause(OMPLinearClause *C) {
3695 TRY_TO(TraverseStmt(C->getStep()));
3696 TRY_TO(TraverseStmt(C->getCalcStep()));
3697 TRY_TO(VisitOMPClauseList(C));
3698 TRY_TO(VisitOMPClauseWithPostUpdate(C));
3699 for (auto *E : C->privates()) {
3701 }
3702 for (auto *E : C->inits()) {
3704 }
3705 for (auto *E : C->updates()) {
3707 }
3708 for (auto *E : C->finals()) {
3710 }
3711 return true;
3712}
3713
3714template
3715bool RecursiveASTVisitor::VisitOMPAlignedClause(OMPAlignedClause *C) {
3716 TRY_TO(TraverseStmt(C->getAlignment()));
3717 TRY_TO(VisitOMPClauseList(C));
3718 return true;
3719}
3720
3721template
3722bool RecursiveASTVisitor::VisitOMPCopyinClause(OMPCopyinClause *C) {
3723 TRY_TO(VisitOMPClauseList(C));
3724 for (auto *E : C->source_exprs()) {
3726 }
3727 for (auto *E : C->destination_exprs()) {
3729 }
3730 for (auto *E : C->assignment_ops()) {
3732 }
3733 return true;
3734}
3735
3736template
3737bool RecursiveASTVisitor::VisitOMPCopyprivateClause(
3738 OMPCopyprivateClause *C) {
3739 TRY_TO(VisitOMPClauseList(C));
3740 for (auto *E : C->source_exprs()) {
3742 }
3743 for (auto *E : C->destination_exprs()) {
3745 }
3746 for (auto *E : C->assignment_ops()) {
3748 }
3749 return true;
3750}
3751
3752template
3753bool
3754RecursiveASTVisitor::VisitOMPReductionClause(OMPReductionClause *C) {
3755 TRY_TO(TraverseNestedNameSpecifierLoc(C->getQualifierLoc()));
3756 TRY_TO(TraverseDeclarationNameInfo(C->getNameInfo()));
3757 TRY_TO(VisitOMPClauseList(C));
3758 TRY_TO(VisitOMPClauseWithPostUpdate(C));
3759 for (auto *E : C->privates()) {
3761 }
3762 for (auto *E : C->lhs_exprs()) {
3764 }
3765 for (auto *E : C->rhs_exprs()) {
3767 }
3768 for (auto *E : C->reduction_ops()) {
3770 }
3771 if (C->getModifier() == OMPC_REDUCTION_inscan) {
3772 for (auto *E : C->copy_ops()) {
3774 }
3775 for (auto *E : C->copy_array_temps()) {
3777 }
3778 for (auto *E : C->copy_array_elems()) {
3780 }
3781 }
3782 return true;
3783}
3784
3785template
3786bool RecursiveASTVisitor::VisitOMPTaskReductionClause(
3787 OMPTaskReductionClause *C) {
3788 TRY_TO(TraverseNestedNameSpecifierLoc(C->getQualifierLoc()));
3789 TRY_TO(TraverseDeclarationNameInfo(C->getNameInfo()));
3790 TRY_TO(VisitOMPClauseList(C));
3791 TRY_TO(VisitOMPClauseWithPostUpdate(C));
3792 for (auto *E : C->privates()) {
3794 }
3795 for (auto *E : C->lhs_exprs()) {
3797 }
3798 for (auto *E : C->rhs_exprs()) {
3800 }
3801 for (auto *E : C->reduction_ops()) {
3803 }
3804 return true;
3805}
3806
3807template
3808bool RecursiveASTVisitor::VisitOMPInReductionClause(
3809 OMPInReductionClause *C) {
3810 TRY_TO(TraverseNestedNameSpecifierLoc(C->getQualifierLoc()));
3811 TRY_TO(TraverseDeclarationNameInfo(C->getNameInfo()));
3812 TRY_TO(VisitOMPClauseList(C));
3813 TRY_TO(VisitOMPClauseWithPostUpdate(C));
3814 for (auto *E : C->privates()) {
3816 }
3817 for (auto *E : C->lhs_exprs()) {
3819 }
3820 for (auto *E : C->rhs_exprs()) {
3822 }
3823 for (auto *E : C->reduction_ops()) {
3825 }
3826 for (auto *E : C->taskgroup_descriptors())
3828 return true;
3829}
3830
3831template
3832bool RecursiveASTVisitor::VisitOMPFlushClause(OMPFlushClause *C) {
3833 TRY_TO(VisitOMPClauseList(C));
3834 return true;
3835}
3836
3837template
3838bool RecursiveASTVisitor::VisitOMPDepobjClause(OMPDepobjClause *C) {
3839 TRY_TO(TraverseStmt(C->getDepobj()));
3840 return true;
3841}
3842
3843template
3844bool RecursiveASTVisitor::VisitOMPDependClause(OMPDependClause *C) {
3845 TRY_TO(VisitOMPClauseList(C));
3846 return true;
3847}
3848
3849template
3850bool RecursiveASTVisitor::VisitOMPDeviceClause(OMPDeviceClause *C) {
3851 TRY_TO(VisitOMPClauseWithPreInit(C));
3852 TRY_TO(TraverseStmt(C->getDevice()));
3853 return true;
3854}
3855
3856template
3857bool RecursiveASTVisitor::VisitOMPMapClause(OMPMapClause *C) {
3858 TRY_TO(VisitOMPClauseList(C));
3859 return true;
3860}
3861
3862template
3863bool RecursiveASTVisitor::VisitOMPNumTeamsClause(
3864 OMPNumTeamsClause *C) {
3865 TRY_TO(VisitOMPClauseList(C));
3866 TRY_TO(VisitOMPClauseWithPreInit(C));
3867 return true;
3868}
3869
3870template
3871bool RecursiveASTVisitor::VisitOMPThreadLimitClause(
3872 OMPThreadLimitClause *C) {
3873 TRY_TO(VisitOMPClauseList(C));
3874 TRY_TO(VisitOMPClauseWithPreInit(C));
3875 return true;
3876}
3877
3878template
3879bool RecursiveASTVisitor::VisitOMPPriorityClause(
3880 OMPPriorityClause *C) {
3881 TRY_TO(VisitOMPClauseWithPreInit(C));
3882 TRY_TO(TraverseStmt(C->getPriority()));
3883 return true;
3884}
3885
3886template
3887bool RecursiveASTVisitor::VisitOMPGrainsizeClause(
3888 OMPGrainsizeClause *C) {
3889 TRY_TO(VisitOMPClauseWithPreInit(C));
3890 TRY_TO(TraverseStmt(C->getGrainsize()));
3891 return true;
3892}
3893
3894template
3895bool RecursiveASTVisitor::VisitOMPNumTasksClause(
3896 OMPNumTasksClause *C) {
3897 TRY_TO(VisitOMPClauseWithPreInit(C));
3898 TRY_TO(TraverseStmt(C->getNumTasks()));
3899 return true;
3900}
3901
3902template
3903bool RecursiveASTVisitor::VisitOMPHintClause(OMPHintClause *C) {
3904 TRY_TO(TraverseStmt(C->getHint()));
3905 return true;
3906}
3907
3908template
3909bool RecursiveASTVisitor::VisitOMPDistScheduleClause(
3910 OMPDistScheduleClause *C) {
3911 TRY_TO(VisitOMPClauseWithPreInit(C));
3912 TRY_TO(TraverseStmt(C->getChunkSize()));
3913 return true;
3914}
3915
3916template
3917bool
3918RecursiveASTVisitor::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) {
3919 return true;
3920}
3921
3922template
3923bool RecursiveASTVisitor::VisitOMPToClause(OMPToClause *C) {
3924 TRY_TO(VisitOMPClauseList(C));
3925 return true;
3926}
3927
3928template
3929bool RecursiveASTVisitor::VisitOMPFromClause(OMPFromClause *C) {
3930 TRY_TO(VisitOMPClauseList(C));
3931 return true;
3932}
3933
3934template
3935bool RecursiveASTVisitor::VisitOMPUseDevicePtrClause(
3936 OMPUseDevicePtrClause *C) {
3937 TRY_TO(VisitOMPClauseList(C));
3938 return true;
3939}
3940
3941template
3942bool RecursiveASTVisitor::VisitOMPUseDeviceAddrClause(
3943 OMPUseDeviceAddrClause *C) {
3944 TRY_TO(VisitOMPClauseList(C));
3945 return true;
3946}
3947
3948template
3949bool RecursiveASTVisitor::VisitOMPIsDevicePtrClause(
3950 OMPIsDevicePtrClause *C) {
3951 TRY_TO(VisitOMPClauseList(C));
3952 return true;
3953}
3954
3955template
3956bool RecursiveASTVisitor::VisitOMPHasDeviceAddrClause(
3957 OMPHasDeviceAddrClause *C) {
3958 TRY_TO(VisitOMPClauseList(C));
3959 return true;
3960}
3961
3962template
3963bool RecursiveASTVisitor::VisitOMPNontemporalClause(
3964 OMPNontemporalClause *C) {
3965 TRY_TO(VisitOMPClauseList(C));
3966 for (auto *E : C->private_refs()) {
3968 }
3969 return true;
3970}
3971
3972template
3973bool RecursiveASTVisitor::VisitOMPOrderClause(OMPOrderClause *) {
3974 return true;
3975}
3976
3977template
3978bool RecursiveASTVisitor::VisitOMPDetachClause(OMPDetachClause *C) {
3979 TRY_TO(TraverseStmt(C->getEventHandler()));
3980 return true;
3981}
3982
3983template
3984bool RecursiveASTVisitor::VisitOMPUsesAllocatorsClause(
3985 OMPUsesAllocatorsClause *C) {
3986 for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) {
3987 const OMPUsesAllocatorsClause::Data Data = C->getAllocatorData(I);
3988 TRY_TO(TraverseStmt(Data.Allocator));
3989 TRY_TO(TraverseStmt(Data.AllocatorTraits));
3990 }
3991 return true;
3992}
3993
3994template
3995bool RecursiveASTVisitor::VisitOMPAffinityClause(
3996 OMPAffinityClause *C) {
3997 TRY_TO(TraverseStmt(C->getModifier()));
3998 for (Expr *E : C->varlist())
4000 return true;
4001}
4002
4003template
4004bool RecursiveASTVisitor::VisitOMPFilterClause(OMPFilterClause *C) {
4005 TRY_TO(VisitOMPClauseWithPreInit(C));
4006 TRY_TO(TraverseStmt(C->getThreadID()));
4007 return true;
4008}
4009
4010template
4011bool RecursiveASTVisitor::VisitOMPBindClause(OMPBindClause *C) {
4012 return true;
4013}
4014
4015template
4016bool RecursiveASTVisitor::VisitOMPXDynCGroupMemClause(
4017 OMPXDynCGroupMemClause *C) {
4018 TRY_TO(VisitOMPClauseWithPreInit(C));
4019 TRY_TO(TraverseStmt(C->getSize()));
4020 return true;
4021}
4022
4023template
4024bool RecursiveASTVisitor::VisitOMPDoacrossClause(
4025 OMPDoacrossClause *C) {
4026 TRY_TO(VisitOMPClauseList(C));
4027 return true;
4028}
4029
4030template
4031bool RecursiveASTVisitor::VisitOMPXAttributeClause(
4032 OMPXAttributeClause *C) {
4033 return true;
4034}
4035
4036template
4037bool RecursiveASTVisitor::VisitOMPXBareClause(OMPXBareClause *C) {
4038 return true;
4039}
4040
4041template
4042bool RecursiveASTVisitor::TraverseOpenACCConstructStmt(
4043 OpenACCConstructStmt *C) {
4044 TRY_TO(VisitOpenACCClauseList(C->clauses()));
4045 return true;
4046}
4047
4048template
4049bool RecursiveASTVisitor::TraverseOpenACCAssociatedStmtConstruct(
4050 OpenACCAssociatedStmtConstruct *S) {
4051 TRY_TO(TraverseOpenACCConstructStmt(S));
4052 TRY_TO(TraverseStmt(S->getAssociatedStmt()));
4053 return true;
4054}
4055
4056template
4057bool RecursiveASTVisitor::VisitOpenACCClause(const OpenACCClause *C) {
4058 for (const Stmt *Child : C->children())
4059 TRY_TO(TraverseStmt(const_cast<Stmt *>(Child)));
4060 return true;
4061}
4062
4063template
4064bool RecursiveASTVisitor::VisitOpenACCClauseList(
4065 ArrayRef<const OpenACCClause *> Clauses) {
4066
4067 for (const auto *C : Clauses)
4068 TRY_TO(VisitOpenACCClause(C));
4069 return true;
4070}
4071
4073 { TRY_TO(TraverseOpenACCAssociatedStmtConstruct(S)); })
4075 { TRY_TO(TraverseOpenACCAssociatedStmtConstruct(S)); })
4077 { TRY_TO(TraverseOpenACCAssociatedStmtConstruct(S)); })
4079 { TRY_TO(TraverseOpenACCAssociatedStmtConstruct(S)); })
4081 { TRY_TO(VisitOpenACCClauseList(S->clauses())); })
4083 { TRY_TO(VisitOpenACCClauseList(S->clauses())); })
4085 { TRY_TO(TraverseOpenACCAssociatedStmtConstruct(S)); })
4087 if (S->hasDevNumExpr())
4088 TRY_TO(TraverseStmt(S->getDevNumExpr()));
4089 for (auto *E : S->getQueueIdExprs())
4091 TRY_TO(VisitOpenACCClauseList(S->clauses()));
4092})
4094 { TRY_TO(VisitOpenACCClauseList(S->clauses())); })
4096 { TRY_TO(VisitOpenACCClauseList(S->clauses())); })
4098 { TRY_TO(VisitOpenACCClauseList(S->clauses())); })
4100 { TRY_TO(VisitOpenACCClauseList(S->clauses())); })
4101
4102
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4123#undef TRAVERSE_STMT
4125
4127
4128}
4129
4130#endif
This file provides AST data structures related to concepts.
#define TYPE(DERIVED, BASE)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines OpenMP nodes for declarative directives.
Defines the C++ template declaration subclasses.
#define DEF_TRAVERSE_TMPL_INST(kind)
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
llvm::DenseSet< const void * > Visited
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the LambdaCapture class.
This file defines OpenMP AST classes for clauses.
Defines some OpenMP-specific enums and functions.
#define DEF_TRAVERSE_TMPL_PART_SPEC_DECL(TMPLDECLKIND, DECLKIND)
#define TRAVERSE_STMT_BASE(NAME, CLASS, VAR, QUEUE)
#define DEF_TRAVERSE_TYPE(TYPE, CODE)
#define DEF_TRAVERSE_TYPELOC(TYPE, CODE)
#define TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S)
#define STMT(CLASS, PARENT)
#define DEF_TRAVERSE_TMPL_SPEC_DECL(TMPLDECLKIND, DECLKIND)
#define DEF_TRAVERSE_DECL(DECL, CODE)
#define DEF_TRAVERSE_STMT(STMT, CODE)
#define DEF_TRAVERSE_TMPL_DECL(TMPLDECLKIND)
#define TRY_TO(CALL_EXPR)
Defines various enumerations that describe declaration and type specifiers.
Defines the Objective-C statement AST node classes.
This file defines OpenACC AST classes for statement-level contructs.
This file defines OpenMP AST classes for executable directives and clauses.
This file defines SYCL AST classes used to represent calls to SYCL kernels.
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
TranslationUnitDecl * getTranslationUnitDecl() const
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
Wrapper for source info for arrays.
Attr - This represents one attribute.
An attributed type is a type to which a type attribute has been applied.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Represents a base class of a C++ class.
Represents a C++ base or member initializer.
Represents a C++ struct/union/class.
Represents the body of a CapturedStmt, and serves as its DeclContext.
Complex values, per C99 6.2.5p11.
A reference to a concept and its template args, as it appears in the code.
Represents the canonical version of C arrays with a specified constant size.
Represents a concrete matrix type with constant number of rows and columns.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
Decl - This represents one declaration (or definition), e.g.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
virtual Stmt * getBody() const
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
@ CXXConversionFunctionName
NameKind getNameKind() const
Determine what kind of name this is.
Represents a ValueDecl that came out of a declarator.
Represents the type decltype(expr) (C++11).
Represents a C++17 deduced template specialization type.
Represents an array type in C++ whose size is a value-dependent expression.
Represents an extended vector type where either the type or size is dependent.
Represents a dependent template name that cannot be resolved prior to template instantiation.
Represents a template specialization type whose template cannot be resolved, e.g.
Represents a vector type where either the type or size is dependent.
Represents a type that was referred to using an elaborated type keyword, e.g., struct S,...
This represents one expression.
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
Represents a function declaration or definition.
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Represents a prototype with parameter type info, e.g.
QualType getParamType(unsigned i) const
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
ArrayRef< QualType > exceptions() const
ArrayRef< QualType > param_types() const
QualType getReturnType() const
Represents a C array with an unspecified size.
Describes an C or C++ initializer list.
Represents the declaration of a label.
Describes the capture of a variable or of this, or of a C++1y init-capture.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
This represents a decl that may have a name.
A C++ nested-name-specifier augmented with source location information.
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
Represents a C++ nested name specifier, such as "\::std::vector::".
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
@ NamespaceAlias
A namespace alias, stored as a NamespaceAliasDecl*.
@ TypeSpec
A type, stored as a Type*.
@ TypeSpecWithTemplate
A type that was preceded by the 'template' keyword, stored as a Type*.
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Identifier
An identifier, stored as an IdentifierInfo*.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace, stored as a NamespaceDecl*.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
This is a basic class for representing single OpenMP clause.
This is a basic class for representing single OpenMP executable directive.
This is a common base class for loop directives ('omp simd', 'omp for', 'omp for simd' etc....
Represents a pointer to an Objective C object.
Represents a class type in Objective C.
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Represents a type parameter type in Objective C.
Sugar for parentheses used when specifying types.
A (possibly-)qualified type.
Represents a template name as written in source code.
Wrapper of type source information for a type with non-trivial direct qualifiers.
UnqualTypeLoc getUnqualifiedLoc() const
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
bool TraverseStmt(Stmt *S, DataRecursionQueue *Queue=nullptr)
Recursively visit a statement or expression, by dispatching to Traverse*() based on the argument's dy...
bool TraverseTemplateArgument(const TemplateArgument &Arg)
Recursively visit a template argument and dispatch to the appropriate method for the argument type.
bool WalkUpFromDecl(Decl *D)
bool TraverseConceptRequirement(concepts::Requirement *R)
bool TraverseType(QualType T)
Recursively visit a type, by dispatching to Traverse*Type() based on the argument's getTypeClass() pr...
bool dataTraverseStmtPre(Stmt *S)
Invoked before visiting a statement or expression via data recursion.
bool TraverseObjCProtocolLoc(ObjCProtocolLoc ProtocolLoc)
Recursively visit an Objective-C protocol reference with location information.
bool VisitUnqualTypeLoc(UnqualTypeLoc TL)
bool TraverseConceptExprRequirement(concepts::ExprRequirement *R)
bool TraverseAST(ASTContext &AST)
Recursively visits an entire AST, starting from the TranslationUnitDecl.
bool shouldVisitTemplateInstantiations() const
Return whether this visitor should recurse into template instantiations.
bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc)
Recursively visit a template argument location and dispatch to the appropriate method for the argumen...
bool canIgnoreChildDeclWhileTraversingDeclContext(const Decl *Child)
bool WalkUpFromType(Type *T)
bool dataTraverseStmtPost(Stmt *S)
Invoked after visiting a statement or expression via data recursion.
bool WalkUpFromTypeLoc(TypeLoc TL)
bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Recursively visit a C++ nested-name-specifier with location information.
bool TraverseTemplateName(TemplateName Template)
Recursively visit a template name and dispatch to the appropriate method.
Stmt::child_range getStmtChildren(Stmt *S)
bool TraverseNestedNameSpecifier(NestedNameSpecifier *NNS)
Recursively visit a C++ nested-name-specifier.
bool shouldVisitImplicitCode() const
Return whether this visitor should recurse into implicit code, e.g., implicit constructors and destru...
bool TraverseConceptReference(ConceptReference *CR)
Recursively visit concept reference with location information.
bool TraverseTemplateArguments(ArrayRef< TemplateArgument > Args)
Recursively visit a set of template arguments.
bool WalkUpFromUnqualTypeLoc(UnqualTypeLoc TL)
bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue)
bool TraverseDecl(Decl *D)
Recursively visit a declaration, by dispatching to Traverse*Decl() based on the argument's dynamic ty...
bool WalkUpFromStmt(Stmt *S)
bool TraverseTypeLoc(TypeLoc TL)
Recursively visit a type with location, by dispatching to Traverse*TypeLoc() based on the argument ty...
bool TraverseTypeConstraint(const TypeConstraint *C)
bool WalkUpFromQualifiedTypeLoc(QualifiedTypeLoc TL)
bool VisitTypeLoc(TypeLoc TL)
bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C, Expr *Init)
Recursively visit a lambda capture.
bool VisitConceptReference(ConceptReference *CR)
bool shouldTraversePostOrder() const
Return whether this visitor should traverse post-order.
SmallVectorImpl< llvm::PointerIntPair< Stmt *, 1, bool > > DataRecursionQueue
A queue used for performing data recursion over statements.
bool shouldVisitLambdaBody() const
Return whether this visitor should recurse into lambda body.
bool TraverseSynOrSemInitListExpr(InitListExpr *S, DataRecursionQueue *Queue=nullptr)
Recursively visit the syntactic or semantic form of an initialization list.
bool TraverseAttr(Attr *At)
Recursively visit an attribute, by dispatching to Traverse*Attr() based on the argument's dynamic typ...
bool TraverseConceptNestedRequirement(concepts::NestedRequirement *R)
bool VisitQualifiedTypeLoc(QualifiedTypeLoc TL)
bool shouldWalkTypesOfTypeLocs() const
Return whether this visitor should recurse into the types of TypeLocs.
bool TraverseDeclarationNameInfo(DeclarationNameInfo NameInfo)
Recursively visit a name with its location information.
bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier &Base)
Recursively visit a base specifier.
Derived & getDerived()
Return a reference to the derived class.
bool TraverseConceptTypeRequirement(concepts::TypeRequirement *R)
bool TraverseConstructorInitializer(CXXCtorInitializer *Init)
Recursively visit a constructor initializer.
Scope - A scope is a transient data structure that is used while parsing the program.
Stmt - This represents one statement.
llvm::iterator_range< child_iterator > child_range
Represents the result of substituting a set of types for a template type parameter pack.
Location wrapper for a TemplateArgument.
const TemplateArgument & getArgument() const
TypeSourceInfo * getTypeSourceInfo() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Expr * getSourceExpression() const
Represents a template argument.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
QualType getAsType() const
Retrieve the type for a type template argument.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
Represents a C++ template name within the type system.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
Stores a list of template parameters for a TemplateDecl and its derived classes.
Declaration of a template type parameter.
The top declaration context.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Base wrapper for a particular "section" of type source info.
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
TypeLocClass getTypeLocClass() const
Represents a typeof (or typeof) expression (a C23 feature and GCC extension) or a typeof_unqual expre...
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
The base class of the type hierarchy.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
TypeClass getTypeClass() const
A unary type transform, which is a type constructed from another.
Wrapper of type source information for a type with no direct qualifiers.
Represents a variable declaration or definition.
Represents a GCC generic vector type.
A requires-expression requirement which queries the validity and properties of an expression ('simple...
bool isExprSubstitutionFailure() const
const ReturnTypeRequirement & getReturnTypeRequirement() const
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
bool hasInvalidConstraint() const
Expr * getConstraintExpr() const
A static requirement that can be used in a requires-expression to check properties of types and expre...
RequirementKind getKind() const
A requires-expression requirement which queries the existence of a type name or type template special...
bool isSubstitutionFailure() const
TypeSourceInfo * getType() const
LLVM_ATTRIBUTE_ALWAYS_INLINE LLVM_ATTRIBUTE_NODEBUG auto isSameMethod(FirstMethodPtrTy FirstMethodPtr, SecondMethodPtrTy SecondMethodPtr) -> bool
Returns true if and only if FirstMethodPtr and SecondMethodPtr are pointers to the same non-static me...
The JSON file list parser is used to communicate input to InstallAPI.
for(const auto &A :T->param_types())
const FunctionProtoType * T
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
@ Class
The "class" keyword introduces the elaborated-type-specifier.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
DeclarationName getName() const
getName - Returns the embedded declaration name.
TypeSourceInfo * getNamedTypeInfo() const
getNamedTypeInfo - Returns the source type info associated to the name.