1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | #ifndef LLVM_CLANG_AST_COMMENTVISITOR_H |
10 | #define |
11 | |
12 | #include "clang/AST/Comment.h" |
13 | #include "llvm/ADT/STLExtras.h" |
14 | #include "llvm/Support/ErrorHandling.h" |
15 | |
16 | namespace clang { |
17 | namespace comments { |
18 | template <template <typename> class Ptr, typename ImplClass, |
19 | typename RetTy = void, class... ParamTys> |
20 | class { |
21 | public: |
22 | #define PTR(CLASS) typename Ptr<CLASS>::type |
23 | #define DISPATCH(NAME, CLASS) \ |
24 | return static_cast<ImplClass *>(this)->visit##NAME( \ |
25 | static_cast<PTR(CLASS)>(C), std::forward<ParamTys>(P)...) |
26 | |
27 | RetTy (PTR(Comment) C, ParamTys... P) { |
28 | if (!C) |
29 | return RetTy(); |
30 | |
31 | switch (C->getCommentKind()) { |
32 | default: llvm_unreachable("Unknown comment kind!"); |
33 | #define (COMMENT) |
34 | #define (CLASS, PARENT) \ |
35 | case Comment::CLASS##Kind: DISPATCH(CLASS, CLASS); |
36 | #include "clang/AST/CommentNodes.inc" |
37 | #undef ABSTRACT_COMMENT |
38 | #undef COMMENT |
39 | } |
40 | } |
41 | |
42 | |
43 | |
44 | #define (COMMENT) COMMENT |
45 | #define (CLASS, PARENT) \ |
46 | RetTy visit##CLASS(PTR(CLASS) C, ParamTys... P) { DISPATCH(PARENT, PARENT); } |
47 | #include "clang/AST/CommentNodes.inc" |
48 | #undef ABSTRACT_COMMENT |
49 | #undef COMMENT |
50 | |
51 | RetTy (PTR(Comment) C, ParamTys... P) { return RetTy(); } |
52 | |
53 | #undef PTR |
54 | #undef DISPATCH |
55 | }; |
56 | |
57 | template <typename ImplClass, typename RetTy = void, class... ParamTys> |
58 | class : public CommentVisitorBase<std::add_pointer, ImplClass, |
59 | RetTy, ParamTys...> {}; |
60 | |
61 | template <typename ImplClass, typename RetTy = void, class... ParamTys> |
62 | class |
63 | : public CommentVisitorBase<llvm::make_const_ptr, ImplClass, RetTy, |
64 | ParamTys...> {}; |
65 | |
66 | } |
67 | } |
68 | |
69 | #endif |
70 | |