Coverage Report

Created: 2018-07-22 10:17

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Sema/TemplateInstCallback.h
Line
Count
Source
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.
24
class TemplateInstantiationCallback {
25
public:
26
11
  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
36.3k
                const Sema &TheSema) {
46
36.3k
  for (auto &C : Callbacks) {
47
11
    if (C)
48
11
      C->initialize(TheSema);
49
11
  }
50
36.3k
}
51
52
template <class TemplateInstantiationCallbackPtrs>
53
void finalize(TemplateInstantiationCallbackPtrs &Callbacks,
54
36.3k
              const Sema &TheSema) {
55
36.3k
  for (auto &C : Callbacks) {
56
11
    if (C)
57
11
      C->finalize(TheSema);
58
11
  }
59
36.3k
}
60
61
template <class TemplateInstantiationCallbackPtrs>
62
void atTemplateBegin(TemplateInstantiationCallbackPtrs &Callbacks,
63
                     const Sema &TheSema,
64
4.95M
                     const Sema::CodeSynthesisContext &Inst) {
65
4.95M
  for (auto &C : Callbacks) {
66
67
    if (C)
67
67
      C->atTemplateBegin(TheSema, Inst);
68
67
  }
69
4.95M
}
70
71
template <class TemplateInstantiationCallbackPtrs>
72
void atTemplateEnd(TemplateInstantiationCallbackPtrs &Callbacks,
73
                   const Sema &TheSema,
74
4.95M
                   const Sema::CodeSynthesisContext &Inst) {
75
4.95M
  for (auto &C : Callbacks) {
76
67
    if (C)
77
67
      C->atTemplateEnd(TheSema, Inst);
78
67
  }
79
4.95M
}
80
81
} // namespace clang
82
83
#endif