]> granicus.if.org Git - clang/commitdiff
Parse LLVM command line arguments after plugins have been loaded
authorTobias Grosser <grosser@fim.uni-passau.de>
Mon, 10 Oct 2011 01:23:06 +0000 (01:23 +0000)
committerTobias Grosser <grosser@fim.uni-passau.de>
Mon, 10 Oct 2011 01:23:06 +0000 (01:23 +0000)
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

lib/FrontendTool/ExecuteCompilerInvocation.cpp

index 1b808c143ecf854f11d767adb71fbdcdee623e79..c9af3cc3ff1e04634d436cda402a771988f06928 100644 (file)
@@ -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) {