summaryrefslogtreecommitdiffstats
path: root/clang/lib/FrontendTool
diff options
context:
space:
mode:
authorTobias Grosser <grosser@fim.uni-passau.de>2011-10-10 01:23:06 +0000
committerTobias Grosser <grosser@fim.uni-passau.de>2011-10-10 01:23:06 +0000
commit11ce922456c4c5ce0ef03c47e5420ec1ce0ad9f1 (patch)
treef899227c9685e8b375f36213b3b77d632651d209 /clang/lib/FrontendTool
parent16e65616d64b206e89a656ae49b7e7fed3f7e0ce (diff)
downloadbcm5719-llvm-11ce922456c4c5ce0ef03c47e5420ec1ce0ad9f1.tar.gz
bcm5719-llvm-11ce922456c4c5ce0ef03c47e5420ec1ce0ad9f1.zip
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. llvm-svn: 141525
Diffstat (limited to 'clang/lib/FrontendTool')
-rw-r--r--clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
index 1b808c143ec..c9af3cc3ff1 100644
--- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ b/clang/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) {
OpenPOWER on IntegriCloud