File indexing completed on 2026-05-10 08:36:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef LLVM_CLANG_AST_TEMPLATEARGUMENTVISITOR_H
0014 #define LLVM_CLANG_AST_TEMPLATEARGUMENTVISITOR_H
0015
0016 #include "clang/AST/TemplateBase.h"
0017
0018 namespace clang {
0019
0020 namespace templateargumentvisitor {
0021
0022
0023 template <template <typename> class Ref, typename ImplClass,
0024 typename RetTy = void, typename... ParamTys>
0025 class Base {
0026 public:
0027 #define REF(CLASS) typename Ref<CLASS>::type
0028 #define DISPATCH(NAME) \
0029 case TemplateArgument::NAME: \
0030 return static_cast<ImplClass *>(this)->Visit##NAME##TemplateArgument( \
0031 TA, std::forward<ParamTys>(P)...)
0032
0033 RetTy Visit(REF(TemplateArgument) TA, ParamTys... P) {
0034 switch (TA.getKind()) {
0035 DISPATCH(Null);
0036 DISPATCH(Type);
0037 DISPATCH(Declaration);
0038 DISPATCH(NullPtr);
0039 DISPATCH(Integral);
0040 DISPATCH(StructuralValue);
0041 DISPATCH(Template);
0042 DISPATCH(TemplateExpansion);
0043 DISPATCH(Expression);
0044 DISPATCH(Pack);
0045 }
0046 llvm_unreachable("TemplateArgument is not covered in switch!");
0047 }
0048
0049
0050
0051
0052 #define VISIT_METHOD(CATEGORY) \
0053 RetTy Visit##CATEGORY##TemplateArgument(REF(TemplateArgument) TA, \
0054 ParamTys... P) { \
0055 return static_cast<ImplClass *>(this)->VisitTemplateArgument( \
0056 TA, std::forward<ParamTys>(P)...); \
0057 }
0058
0059 VISIT_METHOD(Null);
0060 VISIT_METHOD(Type);
0061 VISIT_METHOD(Declaration);
0062 VISIT_METHOD(NullPtr);
0063 VISIT_METHOD(Integral);
0064 VISIT_METHOD(StructuralValue);
0065 VISIT_METHOD(Template);
0066 VISIT_METHOD(TemplateExpansion);
0067 VISIT_METHOD(Expression);
0068 VISIT_METHOD(Pack);
0069
0070 RetTy VisitTemplateArgument(REF(TemplateArgument), ParamTys...) {
0071 return RetTy();
0072 }
0073
0074 #undef REF
0075 #undef DISPATCH
0076 #undef VISIT_METHOD
0077 };
0078
0079 }
0080
0081
0082
0083
0084
0085 template <typename ImplClass, typename RetTy = void, typename... ParamTys>
0086 class TemplateArgumentVisitor
0087 : public templateargumentvisitor::Base<std::add_lvalue_reference, ImplClass,
0088 RetTy, ParamTys...> {};
0089
0090
0091
0092
0093
0094 template <typename ImplClass, typename RetTy = void, typename... ParamTys>
0095 class ConstTemplateArgumentVisitor
0096 : public templateargumentvisitor::Base<llvm::make_const_ref, ImplClass,
0097 RetTy, ParamTys...> {};
0098
0099 }
0100
0101 #endif