1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | #ifndef LLVM_CLANG_TEMPLATE_INST_CALLBACK_H |
15 | #define LLVM_CLANG_TEMPLATE_INST_CALLBACK_H |
16 | |
17 | #include "clang/Sema/Sema.h" |
18 | |
19 | namespace clang { |
20 | |
21 | |
22 | |
23 | class TemplateInstantiationCallback { |
24 | public: |
25 | virtual ~TemplateInstantiationCallback() = default; |
26 | |
27 | |
28 | virtual void initialize(const Sema &TheSema) = 0; |
29 | |
30 | |
31 | virtual void finalize(const Sema &TheSema) = 0; |
32 | |
33 | |
34 | virtual void atTemplateBegin(const Sema &TheSema, |
35 | const Sema::CodeSynthesisContext &Inst) = 0; |
36 | |
37 | |
38 | virtual void atTemplateEnd(const Sema &TheSema, |
39 | const Sema::CodeSynthesisContext &Inst) = 0; |
40 | }; |
41 | |
42 | template <class TemplateInstantiationCallbackPtrs> |
43 | void initialize(TemplateInstantiationCallbackPtrs &Callbacks, |
44 | const Sema &TheSema) { |
45 | for (auto &C : Callbacks) { |
46 | if (C) |
47 | C->initialize(TheSema); |
48 | } |
49 | } |
50 | |
51 | template <class TemplateInstantiationCallbackPtrs> |
52 | void finalize(TemplateInstantiationCallbackPtrs &Callbacks, |
53 | const Sema &TheSema) { |
54 | for (auto &C : Callbacks) { |
55 | if (C) |
56 | C->finalize(TheSema); |
57 | } |
58 | } |
59 | |
60 | template <class TemplateInstantiationCallbackPtrs> |
61 | void atTemplateBegin(TemplateInstantiationCallbackPtrs &Callbacks, |
62 | const Sema &TheSema, |
63 | const Sema::CodeSynthesisContext &Inst) { |
64 | for (auto &C : Callbacks) { |
65 | if (C) |
66 | C->atTemplateBegin(TheSema, Inst); |
67 | } |
68 | } |
69 | |
70 | template <class TemplateInstantiationCallbackPtrs> |
71 | void atTemplateEnd(TemplateInstantiationCallbackPtrs &Callbacks, |
72 | const Sema &TheSema, |
73 | const Sema::CodeSynthesisContext &Inst) { |
74 | for (auto &C : Callbacks) { |
75 | if (C) |
76 | C->atTemplateEnd(TheSema, Inst); |
77 | } |
78 | } |
79 | |
80 | } |
81 | |
82 | #endif |
83 | |