Bug 1498115 - Part 1: Remove the FlexboxContainerProperties component. r=pbro
[gecko.git] / build / build-clang / r277806.patch
blobc3a375af6ecd9226c9fa59d11994065e302e7167
1 commit eca7f4535bffb1c86cb1620b9d9425ff3ce31ab9
2 Author: John Brawn <john.brawn@arm.com>
3 Date: Fri Aug 5 11:01:08 2016 +0000
5 Reapply r276973 "Adjust Registry interface to not require plugins to export a registry"
7 This differs from the previous version by being more careful about template
8 instantiation/specialization in order to prevent errors when building with
9 clang -Werror. Specifically:
10 * begin is not defined in the template and is instead instantiated when Head
11 is. I think the warning when we don't do that is wrong (PR28815) but for now
12 at least do it this way to avoid the warning.
13 * Instead of performing template specializations in LLVM_INSTANTIATE_REGISTRY
14 instead provide a template definition then do explicit instantiation. No
15 compiler I've tried has problems with doing it the other way, but strictly
16 speaking it's not permitted by the C++ standard so better safe than sorry.
18 Original commit message:
20 Currently the Registry class contains the vestiges of a previous attempt to
21 allow plugins to be used on Windows without using BUILD_SHARED_LIBS, where a
22 plugin would have its own copy of a registry and export it to be imported by
23 the tool that's loading the plugin. This only works if the plugin is entirely
24 self-contained with the only interface between the plugin and tool being the
25 registry, and in particular this conflicts with how IR pass plugins work.
27 This patch changes things so that instead the add_node function of the registry
28 is exported by the tool and then imported by the plugin, which solves this
29 problem and also means that instead of every plugin having to export every
30 registry they use instead LLVM only has to export the add_node functions. This
31 allows plugins that use a registry to work on Windows if
32 LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is used.
35 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277806 91177308-0d34-0410-b5e6-96231b3b80d8
37 diff --git a/llvm/include/llvm/Support/Registry.h b/llvm/include/llvm/Support/Registry.h
38 index 27f025fcd08..9557f56093b 100644
39 --- a/llvm/include/llvm/Support/Registry.h
40 +++ b/llvm/include/llvm/Support/Registry.h
41 @@ -44,6 +44,7 @@ namespace llvm {
42 template <typename T>
43 class Registry {
44 public:
45 + typedef T type;
46 typedef SimpleRegistryEntry<T> entry;
48 class node;
49 @@ -69,13 +70,14 @@ namespace llvm {
50 node(const entry &V) : Next(nullptr), Val(V) {}
53 - static void add_node(node *N) {
54 - if (Tail)
55 - Tail->Next = N;
56 - else
57 - Head = N;
58 - Tail = N;
59 - }
60 + /// Add a node to the Registry: this is the interface between the plugin and
61 + /// the executable.
62 + ///
63 + /// This function is exported by the executable and called by the plugin to
64 + /// add a node to the executable's registry. Therefore it's not defined here
65 + /// to avoid it being instantiated in the plugin and is instead defined in
66 + /// the executable (see LLVM_INSTANTIATE_REGISTRY below).
67 + static void add_node(node *N);
69 /// Iterators for registry entries.
70 ///
71 @@ -92,7 +94,9 @@ namespace llvm {
72 const entry *operator->() const { return &Cur->Val; }
75 - static iterator begin() { return iterator(Head); }
76 + // begin is not defined here in order to avoid usage of an undefined static
77 + // data member, instead it's instantiated by LLVM_INSTANTIATE_REGISTRY.
78 + static iterator begin();
79 static iterator end() { return iterator(nullptr); }
81 static iterator_range<iterator> entries() {
82 @@ -120,61 +124,37 @@ namespace llvm {
83 add_node(&Node);
87 - /// A dynamic import facility. This is used on Windows to
88 - /// import the entries added in the plugin.
89 - static void import(sys::DynamicLibrary &DL, const char *RegistryName) {
90 - typedef void *(*GetRegistry)();
91 - std::string Name("LLVMGetRegistry_");
92 - Name.append(RegistryName);
93 - GetRegistry Getter =
94 - (GetRegistry)(intptr_t)DL.getAddressOfSymbol(Name.c_str());
95 - if (Getter) {
96 - // Call the getter function in order to get the full copy of the
97 - // registry defined in the plugin DLL, and copy them over to the
98 - // current Registry.
99 - typedef std::pair<const node *, const node *> Info;
100 - Info *I = static_cast<Info *>(Getter());
101 - iterator begin(I->first);
102 - iterator end(I->second);
103 - for (++end; begin != end; ++begin) {
104 - // This Node object needs to remain alive for the
105 - // duration of the program.
106 - add_node(new node(*begin));
111 - /// Retrieve the data to be passed across DLL boundaries when
112 - /// importing registries from another DLL on Windows.
113 - static void *exportRegistry() {
114 - static std::pair<const node *, const node *> Info(Head, Tail);
115 - return &Info;
120 - // Since these are defined in a header file, plugins must be sure to export
121 - // these symbols.
122 - template <typename T>
123 - typename Registry<T>::node *Registry<T>::Head;
125 - template <typename T>
126 - typename Registry<T>::node *Registry<T>::Tail;
127 } // end namespace llvm
129 -#ifdef LLVM_ON_WIN32
130 -#define LLVM_EXPORT_REGISTRY(REGISTRY_CLASS) \
131 - extern "C" { \
132 - __declspec(dllexport) void *__cdecl LLVMGetRegistry_##REGISTRY_CLASS() { \
133 - return REGISTRY_CLASS::exportRegistry(); \
134 - } \
135 +/// 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> typename Registry<T>::node *Registry<T>::Head = nullptr;\
146 + template<typename T> typename Registry<T>::node *Registry<T>::Tail = nullptr;\
147 + template<typename T> \
148 + void Registry<T>::add_node(typename Registry<T>::node *N) { \
149 + if (Tail) \
150 + Tail->Next = N; \
151 + else \
152 + Head = N; \
153 + Tail = N; \
154 + } \
155 + template<typename T> typename Registry<T>::iterator Registry<T>::begin() { \
156 + return iterator(Head); \
157 + } \
158 + template REGISTRY_CLASS::node *Registry<REGISTRY_CLASS::type>::Head; \
159 + template REGISTRY_CLASS::node *Registry<REGISTRY_CLASS::type>::Tail; \
160 + template \
161 + void Registry<REGISTRY_CLASS::type>::add_node(REGISTRY_CLASS::node*); \
162 + template REGISTRY_CLASS::iterator Registry<REGISTRY_CLASS::type>::begin(); \
164 -#define LLVM_IMPORT_REGISTRY(REGISTRY_CLASS, DL) \
165 - REGISTRY_CLASS::import(DL, #REGISTRY_CLASS)
166 -#else
167 -#define LLVM_EXPORT_REGISTRY(REGISTRY_CLASS)
168 -#define LLVM_IMPORT_REGISTRY(REGISTRY_CLASS, DL)
169 -#endif
171 #endif // LLVM_SUPPORT_REGISTRY_H
172 diff --git a/llvm/lib/CodeGen/GCMetadataPrinter.cpp b/llvm/lib/CodeGen/GCMetadataPrinter.cpp
173 index bb8cfa1cc80..d183c7f2980 100644
174 --- a/llvm/lib/CodeGen/GCMetadataPrinter.cpp
175 +++ b/llvm/lib/CodeGen/GCMetadataPrinter.cpp
176 @@ -14,6 +14,8 @@
177 #include "llvm/CodeGen/GCMetadataPrinter.h"
178 using namespace llvm;
180 +LLVM_INSTANTIATE_REGISTRY(GCMetadataPrinterRegistry)
182 GCMetadataPrinter::GCMetadataPrinter() {}
184 GCMetadataPrinter::~GCMetadataPrinter() {}
185 diff --git a/llvm/lib/CodeGen/GCStrategy.cpp b/llvm/lib/CodeGen/GCStrategy.cpp
186 index 554d326942e..31ab86fdf27 100644
187 --- a/llvm/lib/CodeGen/GCStrategy.cpp
188 +++ b/llvm/lib/CodeGen/GCStrategy.cpp
189 @@ -16,6 +16,8 @@
191 using namespace llvm;
193 +LLVM_INSTANTIATE_REGISTRY(GCRegistry)
195 GCStrategy::GCStrategy()
196 : UseStatepoints(false), NeededSafePoints(0), CustomReadBarriers(false),
197 CustomWriteBarriers(false), CustomRoots(false), InitRoots(true),
199 commit 0cfb8c87dfc0a8366d6db83f93aa50e9514dbf9d
200 Author: John Brawn <john.brawn@arm.com>
201 Date: Fri Aug 5 11:01:08 2016 +0000
203 Reapply r276973 "Adjust Registry interface to not require plugins to export a registry"
205 This differs from the previous version by being more careful about template
206 instantiation/specialization in order to prevent errors when building with
207 clang -Werror. Specifically:
208 * begin is not defined in the template and is instead instantiated when Head
209 is. I think the warning when we don't do that is wrong (PR28815) but for now
210 at least do it this way to avoid the warning.
211 * Instead of performing template specializations in LLVM_INSTANTIATE_REGISTRY
212 instead provide a template definition then do explicit instantiation. No
213 compiler I've tried has problems with doing it the other way, but strictly
214 speaking it's not permitted by the C++ standard so better safe than sorry.
216 Original commit message:
218 Currently the Registry class contains the vestiges of a previous attempt to
219 allow plugins to be used on Windows without using BUILD_SHARED_LIBS, where a
220 plugin would have its own copy of a registry and export it to be imported by
221 the tool that's loading the plugin. This only works if the plugin is entirely
222 self-contained with the only interface between the plugin and tool being the
223 registry, and in particular this conflicts with how IR pass plugins work.
225 This patch changes things so that instead the add_node function of the registry
226 is exported by the tool and then imported by the plugin, which solves this
227 problem and also means that instead of every plugin having to export every
228 registry they use instead LLVM only has to export the add_node functions. This
229 allows plugins that use a registry to work on Windows if
230 LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is used.
233 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@277806 91177308-0d34-0410-b5e6-96231b3b80d8
235 diff --git a/clang/examples/AnnotateFunctions/CMakeLists.txt b/clang/examples/AnnotateFunctions/CMakeLists.txt
236 index cf564d527d..5684abf238 100644
237 --- a/clang/examples/AnnotateFunctions/CMakeLists.txt
238 +++ b/clang/examples/AnnotateFunctions/CMakeLists.txt
239 @@ -1,4 +1,4 @@
240 -add_llvm_loadable_module(AnnotateFunctions AnnotateFunctions.cpp)
241 +add_llvm_loadable_module(AnnotateFunctions AnnotateFunctions.cpp PLUGIN_TOOL clang)
243 if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
244 target_link_libraries(AnnotateFunctions PRIVATE
245 diff --git a/clang/examples/PrintFunctionNames/CMakeLists.txt b/clang/examples/PrintFunctionNames/CMakeLists.txt
246 index 5a00d5036f..f5f818866c 100644
247 --- a/clang/examples/PrintFunctionNames/CMakeLists.txt
248 +++ b/clang/examples/PrintFunctionNames/CMakeLists.txt
249 @@ -9,7 +9,7 @@ if( NOT MSVC ) # MSVC mangles symbols differently, and
250 endif()
251 endif()
253 -add_llvm_loadable_module(PrintFunctionNames PrintFunctionNames.cpp)
254 +add_llvm_loadable_module(PrintFunctionNames PrintFunctionNames.cpp PLUGIN_TOOL clang)
256 if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
257 target_link_libraries(PrintFunctionNames PRIVATE
258 diff --git a/clang/include/clang/Frontend/FrontendPluginRegistry.h b/clang/include/clang/Frontend/FrontendPluginRegistry.h
259 index ecab630c12..9d7ee08d95 100644
260 --- a/clang/include/clang/Frontend/FrontendPluginRegistry.h
261 +++ b/clang/include/clang/Frontend/FrontendPluginRegistry.h
262 @@ -13,9 +13,6 @@
263 #include "clang/Frontend/FrontendAction.h"
264 #include "llvm/Support/Registry.h"
266 -// Instantiated in FrontendAction.cpp.
267 -extern template class llvm::Registry<clang::PluginASTAction>;
269 namespace clang {
271 /// The frontend plugin registry.
272 diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h
273 index c9b712504e..000df6647f 100644
274 --- a/clang/include/clang/Lex/Preprocessor.h
275 +++ b/clang/include/clang/Lex/Preprocessor.h
276 @@ -1972,6 +1972,4 @@ typedef llvm::Registry<PragmaHandler> PragmaHandlerRegistry;
278 } // end namespace clang
280 -extern template class llvm::Registry<clang::PragmaHandler>;
282 #endif
283 diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp
284 index d2c2a80394..2945b8925f 100644
285 --- a/clang/lib/Frontend/FrontendAction.cpp
286 +++ b/clang/lib/Frontend/FrontendAction.cpp
287 @@ -33,7 +33,7 @@
288 #include <system_error>
289 using namespace clang;
291 -template class llvm::Registry<clang::PluginASTAction>;
292 +LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry)
294 namespace {
296 diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
297 index 8832c7f80c..f0d6872546 100644
298 --- a/clang/lib/Lex/Preprocessor.cpp
299 +++ b/clang/lib/Lex/Preprocessor.cpp
300 @@ -54,7 +54,7 @@
301 #include <utility>
302 using namespace clang;
304 -template class llvm::Registry<clang::PragmaHandler>;
305 +LLVM_INSTANTIATE_REGISTRY(PragmaHandlerRegistry)
307 //===----------------------------------------------------------------------===//
308 ExternalPreprocessorSource::~ExternalPreprocessorSource() { }
309 diff --git a/clang/lib/Tooling/CompilationDatabase.cpp b/clang/lib/Tooling/CompilationDatabase.cpp
310 index 8fc4a1fe5b..6f95bf01f6 100644
311 --- a/clang/lib/Tooling/CompilationDatabase.cpp
312 +++ b/clang/lib/Tooling/CompilationDatabase.cpp
313 @@ -32,6 +32,8 @@
314 using namespace clang;
315 using namespace tooling;
317 +LLVM_INSTANTIATE_REGISTRY(CompilationDatabasePluginRegistry)
319 CompilationDatabase::~CompilationDatabase() {}
321 std::unique_ptr<CompilationDatabase>