@@ -82,7 +82,13 @@ namespace llvm {
82
82
// / add a node to the executable's registry. Therefore it's not defined here
83
83
// / to avoid it being instantiated in the plugin and is instead defined in
84
84
// / the executable (see LLVM_INSTANTIATE_REGISTRY below).
85
- static void add_node (node *N);
85
+ static void add_node (node *N) {
86
+ if (Tail)
87
+ Tail->Next = N;
88
+ else
89
+ Head = N;
90
+ Tail = N;
91
+ }
86
92
87
93
// / Iterators for registry entries.
88
94
// /
@@ -101,7 +107,7 @@ namespace llvm {
101
107
102
108
// begin is not defined here in order to avoid usage of an undefined static
103
109
// data member, instead it's instantiated by LLVM_INSTANTIATE_REGISTRY.
104
- static iterator begin ();
110
+ static iterator begin () { return iterator (Head); }
105
111
static iterator end () { return iterator (nullptr ); }
106
112
107
113
static iterator_range<iterator> entries () {
@@ -130,39 +136,22 @@ namespace llvm {
130
136
}
131
137
};
132
138
};
139
+
140
+ template <typename T> typename Registry<T>::node *Registry<T>::Head = nullptr ;
141
+ template <typename T> typename Registry<T>::node *Registry<T>::Tail = nullptr ;
133
142
} // end namespace llvm
134
143
144
+ #ifdef _WIN32
135
145
// / Instantiate a registry class.
136
- // /
137
- // / This provides template definitions of add_node, begin, and the Head and Tail
138
- // / pointers, then explicitly instantiates them. We could explicitly specialize
139
- // / them, instead of the two-step process of define then instantiate, but
140
- // / strictly speaking that's not allowed by the C++ standard (we would need to
141
- // / have explicit specialization declarations in all translation units where the
142
- // / specialization is used) so we don't.
143
- #define LLVM_INSTANTIATE_REGISTRY (REGISTRY_CLASS ) \
144
- namespace llvm { \
145
- template <typename T> \
146
- typename Registry<T>::node *Registry<T>::Head = nullptr ; \
147
- template <typename T> \
148
- typename Registry<T>::node *Registry<T>::Tail = nullptr ; \
149
- template <typename T> \
150
- void Registry<T>::add_node(typename Registry<T>::node *N) { \
151
- if (Tail) \
152
- Tail->Next = N; \
153
- else \
154
- Head = N; \
155
- Tail = N; \
156
- } \
157
- template <typename T> typename Registry<T>::iterator Registry<T>::begin() { \
158
- return iterator (Head); \
159
- } \
160
- template REGISTRY_CLASS::node *Registry<REGISTRY_CLASS::type>::Head; \
161
- template REGISTRY_CLASS::node *Registry<REGISTRY_CLASS::type>::Tail; \
162
- template LLVM_ABI_EXPORT void \
163
- Registry<REGISTRY_CLASS::type>::add_node(REGISTRY_CLASS::node *); \
164
- template LLVM_ABI_EXPORT REGISTRY_CLASS::iterator \
165
- Registry<REGISTRY_CLASS::type>::begin(); \
146
+ #define LLVM_INSTANTIATE_REGISTRY (REGISTRY_CLASS ) \
147
+ namespace llvm { \
148
+ template class LLVM_ABI_EXPORT Registry<REGISTRY_CLASS::type>;\
149
+ }
150
+ #else
151
+ #define LLVM_INSTANTIATE_REGISTRY (REGISTRY_CLASS ) \
152
+ namespace llvm { \
153
+ template class Registry <REGISTRY_CLASS>;\
166
154
}
155
+ #endif
167
156
168
157
#endif // LLVM_SUPPORT_REGISTRY_H
0 commit comments