[clang-tools-extra] r276973 - Reapply r276856 "Adjust Registry interface to not require plugins to export a registry"

John Brawn via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 28 05:48:18 PDT 2016


Author: john.brawn
Date: Thu Jul 28 07:48:17 2016
New Revision: 276973

URL: http://llvm.org/viewvc/llvm-project?rev=276973&view=rev
Log:
Reapply r276856 "Adjust Registry interface to not require plugins to export a registry"

This version has two fixes compared to the original:
 * In Registry.h the template static members are instantiated before they are
   used, as clang gives an error if you do it the other way around.
 * The use of the Registry template in clang-tidy is updated in the same way as
   has been done everywhere else.

Original commit message:

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.

Modified:
    clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
    clang-tools-extra/trunk/clang-tidy/ClangTidyModuleRegistry.h

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=276973&r1=276972&r2=276973&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu Jul 28 07:48:17 2016
@@ -47,7 +47,7 @@ using namespace clang::driver;
 using namespace clang::tooling;
 using namespace llvm;
 
-template class llvm::Registry<clang::tidy::ClangTidyModule>;
+LLVM_INSTANTIATE_REGISTRY(clang::tidy::ClangTidyModuleRegistry)
 
 namespace clang {
 namespace tidy {

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyModuleRegistry.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyModuleRegistry.h?rev=276973&r1=276972&r2=276973&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidyModuleRegistry.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyModuleRegistry.h Thu Jul 28 07:48:17 2016
@@ -13,8 +13,6 @@
 #include "ClangTidyModule.h"
 #include "llvm/Support/Registry.h"
 
-extern template class llvm::Registry<clang::tidy::ClangTidyModule>;
-
 namespace clang {
 namespace tidy {
 




More information about the cfe-commits mailing list