clang  7.0.0svn
TemplateInstCallback.h
Go to the documentation of this file.
1 //===- TemplateInstCallback.h - Template Instantiation Callback - C++ --===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===---------------------------------------------------------------------===//
9 //
10 // This file defines the TemplateInstantiationCallback class, which is the
11 // base class for callbacks that will be notified at template instantiations.
12 //
13 //===---------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_TEMPLATE_INST_CALLBACK_H
16 #define LLVM_CLANG_TEMPLATE_INST_CALLBACK_H
17 
18 #include "clang/Sema/Sema.h"
19 
20 namespace clang {
21 
22 /// This is a base class for callbacks that will be notified at every
23 /// template instantiation.
25 public:
26  virtual ~TemplateInstantiationCallback() = default;
27 
28  /// Called before doing AST-parsing.
29  virtual void initialize(const Sema &TheSema) = 0;
30 
31  /// Called after AST-parsing is completed.
32  virtual void finalize(const Sema &TheSema) = 0;
33 
34  /// Called when instantiation of a template just began.
35  virtual void atTemplateBegin(const Sema &TheSema,
36  const Sema::CodeSynthesisContext &Inst) = 0;
37 
38  /// Called when instantiation of a template is just about to end.
39  virtual void atTemplateEnd(const Sema &TheSema,
40  const Sema::CodeSynthesisContext &Inst) = 0;
41 };
42 
43 template <class TemplateInstantiationCallbackPtrs>
44 void initialize(TemplateInstantiationCallbackPtrs &Callbacks,
45  const Sema &TheSema) {
46  for (auto &C : Callbacks) {
47  if (C)
48  C->initialize(TheSema);
49  }
50 }
51 
52 template <class TemplateInstantiationCallbackPtrs>
53 void finalize(TemplateInstantiationCallbackPtrs &Callbacks,
54  const Sema &TheSema) {
55  for (auto &C : Callbacks) {
56  if (C)
57  C->finalize(TheSema);
58  }
59 }
60 
61 template <class TemplateInstantiationCallbackPtrs>
62 void atTemplateBegin(TemplateInstantiationCallbackPtrs &Callbacks,
63  const Sema &TheSema,
64  const Sema::CodeSynthesisContext &Inst) {
65  for (auto &C : Callbacks) {
66  if (C)
67  C->atTemplateBegin(TheSema, Inst);
68  }
69 }
70 
71 template <class TemplateInstantiationCallbackPtrs>
72 void atTemplateEnd(TemplateInstantiationCallbackPtrs &Callbacks,
73  const Sema &TheSema,
74  const Sema::CodeSynthesisContext &Inst) {
75  for (auto &C : Callbacks) {
76  if (C)
77  C->atTemplateEnd(TheSema, Inst);
78  }
79 }
80 
81 } // namespace clang
82 
83 #endif
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
Definition: Sema.h:7124
This is a base class for callbacks that will be notified at every template instantiation.
virtual void initialize(const Sema &TheSema)=0
Called before doing AST-parsing.
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:276
virtual void finalize(const Sema &TheSema)=0
Called after AST-parsing is completed.
Dataflow Directional Tag Classes.
virtual ~TemplateInstantiationCallback()=default
virtual void atTemplateBegin(const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)=0
Called when instantiation of a template just began.
virtual void atTemplateEnd(const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)=0
Called when instantiation of a template is just about to end.