File indexing completed on 2026-05-10 08:36:33
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef LLVM_CLANG_AST_DECLVISITOR_H
0014 #define LLVM_CLANG_AST_DECLVISITOR_H
0015
0016 #include "clang/AST/Decl.h"
0017 #include "clang/AST/DeclBase.h"
0018 #include "clang/AST/DeclCXX.h"
0019 #include "clang/AST/DeclFriend.h"
0020 #include "clang/AST/DeclObjC.h"
0021 #include "clang/AST/DeclOpenMP.h"
0022 #include "clang/AST/DeclTemplate.h"
0023 #include "llvm/ADT/STLExtras.h"
0024 #include "llvm/Support/ErrorHandling.h"
0025
0026 namespace clang {
0027
0028 namespace declvisitor {
0029
0030 template<template <typename> class Ptr, typename ImplClass, typename RetTy=void>
0031 class Base {
0032 public:
0033 #define PTR(CLASS) typename Ptr<CLASS>::type
0034 #define DISPATCH(NAME, CLASS) \
0035 return static_cast<ImplClass*>(this)->Visit##NAME(static_cast<PTR(CLASS)>(D))
0036
0037 RetTy Visit(PTR(Decl) D) {
0038 switch (D->getKind()) {
0039 #define DECL(DERIVED, BASE) \
0040 case Decl::DERIVED: DISPATCH(DERIVED##Decl, DERIVED##Decl);
0041 #define ABSTRACT_DECL(DECL)
0042 #include "clang/AST/DeclNodes.inc"
0043 }
0044 llvm_unreachable("Decl that isn't part of DeclNodes.inc!");
0045 }
0046
0047
0048
0049 #define DECL(DERIVED, BASE) \
0050 RetTy Visit##DERIVED##Decl(PTR(DERIVED##Decl) D) { DISPATCH(BASE, BASE); }
0051 #include "clang/AST/DeclNodes.inc"
0052
0053 RetTy VisitDecl(PTR(Decl) D) { return RetTy(); }
0054
0055 #undef PTR
0056 #undef DISPATCH
0057 };
0058
0059 }
0060
0061
0062
0063
0064
0065 template <typename ImplClass, typename RetTy = void>
0066 class DeclVisitor
0067 : public declvisitor::Base<std::add_pointer, ImplClass, RetTy> {};
0068
0069
0070
0071
0072 template <typename ImplClass, typename RetTy = void>
0073 class ConstDeclVisitor
0074 : public declvisitor::Base<llvm::make_const_ptr, ImplClass, RetTy> {};
0075
0076 }
0077
0078 #endif