From: Eric Liu Date: Fri, 3 Nov 2017 15:57:27 +0000 (+0000) Subject: [Tooling] Fix linking of StandaloneToolExecutorPlugin. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5e73ee6e4fd225c7b40b132889ec08de0977777f;p=clang [Tooling] Fix linking of StandaloneToolExecutorPlugin. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@317332 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Tooling/Execution.cpp b/lib/Tooling/Execution.cpp index 0e3404f91c..498d683f89 100644 --- a/lib/Tooling/Execution.cpp +++ b/lib/Tooling/Execution.cpp @@ -61,7 +61,7 @@ createExecutorFromCommandLineArgsImpl(int &argc, const char **argv, const char *Overview) { auto OptionsParser = CommonOptionsParser::create(argc, argv, Category, llvm::cl::ZeroOrMore, - /*Overview=*/nullptr); + /*Overview=*/Overview); if (!OptionsParser) return OptionsParser.takeError(); for (auto I = ToolExecutorPluginRegistry::begin(), @@ -95,5 +95,11 @@ createExecutorFromCommandLineArgs(int &argc, const char **argv, Overview); } +// This anchor is used to force the linker to link in the generated object file +// and thus register the StandaloneToolExecutorPlugin. +extern volatile int StandaloneToolExecutorAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED StandaloneToolExecutorAnchorDest = + StandaloneToolExecutorAnchorSource; + } // end namespace tooling } // end namespace clang diff --git a/lib/Tooling/StandaloneExecution.cpp b/lib/Tooling/StandaloneExecution.cpp index e52e4a611f..eea8e39d13 100644 --- a/lib/Tooling/StandaloneExecution.cpp +++ b/lib/Tooling/StandaloneExecution.cpp @@ -79,13 +79,13 @@ public: } }; -// This anchor is used to force the linker to link in the generated object file -// and thus register the plugin. -volatile int ToolExecutorPluginAnchorSource = 0; - static ToolExecutorPluginRegistry::Add X("standalone", "Runs FrontendActions on a set of files provided " "via positional arguments."); +// This anchor is used to force the linker to link in the generated object file +// and thus register the plugin. +volatile int StandaloneToolExecutorAnchorSource = 0; + } // end namespace tooling } // end namespace clang diff --git a/unittests/Tooling/ExecutionTest.cpp b/unittests/Tooling/ExecutionTest.cpp index 44e37b4009..09dfdb6cf0 100644 --- a/unittests/Tooling/ExecutionTest.cpp +++ b/unittests/Tooling/ExecutionTest.cpp @@ -125,13 +125,6 @@ public: } }; -// This anchor is used to force the linker to link in the generated object file -// and thus register the plugin. -extern volatile int ToolExecutorPluginAnchorSource; - -static int LLVM_ATTRIBUTE_UNUSED TestToolExecutorPluginAnchorDest = - ToolExecutorPluginAnchorSource; - static ToolExecutorPluginRegistry::Add X("test-executor", "Plugin for TestToolExecutor.");