diff options
author | Tobias Grosser <grosser@fim.uni-passau.de> | 2011-10-10 01:23:06 +0000 |
---|---|---|
committer | Tobias Grosser <grosser@fim.uni-passau.de> | 2011-10-10 01:23:06 +0000 |
commit | 6e0afc8610d3ebe8f1ffae54597dd1dab9b865f5 (patch) | |
tree | fc903bd5cf05e22daf6dae908731ab237b2d66b4 /lib/FrontendTool/ExecuteCompilerInvocation.cpp | |
parent | 883af83bd6f9b0b60b8c7a78b8682eb8ab40a4a8 (diff) |
Parse LLVM command line arguments after plugins have been loaded
This fixes a crash due to command line options, that are not available
before the loading of plugins finished.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141525 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/FrontendTool/ExecuteCompilerInvocation.cpp')
-rw-r--r-- | lib/FrontendTool/ExecuteCompilerInvocation.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/lib/FrontendTool/ExecuteCompilerInvocation.cpp index 1b808c143e..c9af3cc3ff 100644 --- a/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -133,9 +133,20 @@ bool clang::ExecuteCompilerInvocation(CompilerInstance *Clang) { return 0; } + // Load any requested plugins. + for (unsigned i = 0, + e = Clang->getFrontendOpts().Plugins.size(); i != e; ++i) { + const std::string &Path = Clang->getFrontendOpts().Plugins[i]; + std::string Error; + if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &Error)) + Clang->getDiagnostics().Report(diag::err_fe_unable_to_load_plugin) + << Path << Error; + } + // Honor -mllvm. // // FIXME: Remove this, one day. + // This should happen AFTER plugins have been loaded! if (!Clang->getFrontendOpts().LLVMArgs.empty()) { unsigned NumArgs = Clang->getFrontendOpts().LLVMArgs.size(); const char **Args = new const char*[NumArgs + 2]; @@ -146,16 +157,6 @@ bool clang::ExecuteCompilerInvocation(CompilerInstance *Clang) { llvm::cl::ParseCommandLineOptions(NumArgs + 1, const_cast<char **>(Args)); } - // Load any requested plugins. - for (unsigned i = 0, - e = Clang->getFrontendOpts().Plugins.size(); i != e; ++i) { - const std::string &Path = Clang->getFrontendOpts().Plugins[i]; - std::string Error; - if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &Error)) - Clang->getDiagnostics().Report(diag::err_fe_unable_to_load_plugin) - << Path << Error; - } - // Honor -analyzer-checker-help. // This should happen AFTER plugins have been loaded! if (Clang->getAnalyzerOpts().ShowCheckerHelp) { |