]> granicus.if.org Git - clang/commitdiff
Adjust Registry interface to not require plugins to export a registry
authorJohn Brawn <john.brawn@arm.com>
Wed, 27 Jul 2016 11:18:38 +0000 (11:18 +0000)
committerJohn Brawn <john.brawn@arm.com>
Wed, 27 Jul 2016 11:18:38 +0000 (11:18 +0000)
Currently the Registry class contains the vestiges of a previous attempt to
allow plugins to be used on Windows without using BUILD_SHARED_LIBS, where a
plugin would have its own copy of a registry and export it to be imported by
the tool that's loading the plugin. This only works if the plugin is entirely
self-contained with the only interface between the plugin and tool being the
registry, and in particular this conflicts with how IR pass plugins work.

This patch changes things so that instead the add_node function of the registry
is exported by the tool and then imported by the plugin, which solves this
problem and also means that instead of every plugin having to export every
registry they use instead LLVM only has to export the add_node functions. This
allows plugins that use a registry to work on Windows if
LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is used.

Differential Revision: http://reviews.llvm.org/D21385

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@276856 91177308-0d34-0410-b5e6-96231b3b80d8

examples/AnnotateFunctions/CMakeLists.txt
examples/PrintFunctionNames/CMakeLists.txt
include/clang/Frontend/FrontendPluginRegistry.h
include/clang/Lex/Preprocessor.h
lib/Frontend/FrontendAction.cpp
lib/Lex/Preprocessor.cpp
lib/Tooling/CompilationDatabase.cpp

index cf564d527d6a8f692599024eed62a4578c3d83ff..5684abf2380d14ccea063a5629737560fc36cd36 100644 (file)
@@ -1,4 +1,4 @@
-add_llvm_loadable_module(AnnotateFunctions AnnotateFunctions.cpp)
+add_llvm_loadable_module(AnnotateFunctions AnnotateFunctions.cpp PLUGIN_TOOL clang)
 
 if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
   target_link_libraries(AnnotateFunctions PRIVATE
index 5a00d5036fb1631be836365652f40851eece869c..f5f818866ca60e9f89489d04b23532c87a076f4e 100644 (file)
@@ -9,7 +9,7 @@ if( NOT MSVC ) # MSVC mangles symbols differently, and
   endif()
 endif()
 
-add_llvm_loadable_module(PrintFunctionNames PrintFunctionNames.cpp)
+add_llvm_loadable_module(PrintFunctionNames PrintFunctionNames.cpp PLUGIN_TOOL clang)
 
 if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
   target_link_libraries(PrintFunctionNames PRIVATE
index ecab630c1228c9adac60a33319c9615c82e9a142..9d7ee08d95d4b5dcab31d97e0177d35782337ede 100644 (file)
@@ -13,9 +13,6 @@
 #include "clang/Frontend/FrontendAction.h"
 #include "llvm/Support/Registry.h"
 
-// Instantiated in FrontendAction.cpp.
-extern template class llvm::Registry<clang::PluginASTAction>;
-
 namespace clang {
 
 /// The frontend plugin registry.
index 30cc37f6f884fb26567ed267bef7082b4a7e3c08..4a46bb8d05f54ddf90a6e6cbb61ae18804e422e6 100644 (file)
@@ -1956,6 +1956,4 @@ typedef llvm::Registry<PragmaHandler> PragmaHandlerRegistry;
 
 }  // end namespace clang
 
-extern template class llvm::Registry<clang::PragmaHandler>;
-
 #endif
index d2c2a80394db860578abd112506f309da305de83..2945b8925f9b2404349a6c314ba13224a312155d 100644 (file)
@@ -33,7 +33,7 @@
 #include <system_error>
 using namespace clang;
 
-template class llvm::Registry<clang::PluginASTAction>;
+LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry)
 
 namespace {
 
index 3654ba080d47c49c9b3b0038d20d6451af3f8ee7..6812da821297df5c624e6beaaa6431702c037782 100644 (file)
@@ -54,7 +54,7 @@
 #include <utility>
 using namespace clang;
 
-template class llvm::Registry<clang::PragmaHandler>;
+LLVM_INSTANTIATE_REGISTRY(PragmaHandlerRegistry)
 
 //===----------------------------------------------------------------------===//
 ExternalPreprocessorSource::~ExternalPreprocessorSource() { }
index 8fc4a1fe5beb0d2d8b022aaf25c179114420954e..6f95bf01f690bd827da820fe4fbe5f39bae95470 100644 (file)
@@ -32,6 +32,8 @@
 using namespace clang;
 using namespace tooling;
 
+LLVM_INSTANTIATE_REGISTRY(CompilationDatabasePluginRegistry)
+
 CompilationDatabase::~CompilationDatabase() {}
 
 std::unique_ptr<CompilationDatabase>