Reapply r276973 "Adjust Registry interface to not require plugins to export a registry"
authorJohn Brawn <john.brawn@arm.com>
Fri, 5 Aug 2016 11:01:08 +0000 (11:01 +0000)
committerJohn Brawn <john.brawn@arm.com>
Fri, 5 Aug 2016 11:01:08 +0000 (11:01 +0000)
commit4d79ec7fe88f05c23212778de3c69906a2bc05a6
tree12bf0f459f9620ff6b961d6088170d95defd5e4a
parent30e0ce8e9fc4598388fcd3c4d57894036cdd5903
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.

llvm-svn: 277806
12 files changed:
clang-tools-extra/clang-tidy/ClangTidy.cpp
clang-tools-extra/clang-tidy/ClangTidyModuleRegistry.h
clang/examples/AnnotateFunctions/CMakeLists.txt
clang/examples/PrintFunctionNames/CMakeLists.txt
clang/include/clang/Frontend/FrontendPluginRegistry.h
clang/include/clang/Lex/Preprocessor.h
clang/lib/Frontend/FrontendAction.cpp
clang/lib/Lex/Preprocessor.cpp
clang/lib/Tooling/CompilationDatabase.cpp
llvm/include/llvm/Support/Registry.h
llvm/lib/CodeGen/GCMetadataPrinter.cpp
llvm/lib/CodeGen/GCStrategy.cpp