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

John Brawn via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 5 04:01:09 PDT 2016


Author: john.brawn
Date: Fri Aug  5 06:01:08 2016
New Revision: 277806

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

This differs from the previous version by being more careful about template
instantiation/specialization in order to prevent errors when building with
clang -Werror. Specifically:
 * begin is not defined in the template and is instead instantiated when Head
   is. I think the warning when we don't do that is wrong (PR28815) but for now
   at least do it this way to avoid the warning.
 * Instead of performing template specializations in LLVM_INSTANTIATE_REGISTRY
   instead provide a template definition then do explicit instantiation. No
   compiler I've tried has problems with doing it the other way, but strictly
   speaking it's not permitted by the C++ standard so better safe than sorry.

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=277806&r1=277805&r2=277806&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Fri Aug  5 06:01:08 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=277806&r1=277805&r2=277806&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidyModuleRegistry.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyModuleRegistry.h Fri Aug  5 06:01:08 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