]> granicus.if.org Git - clang/commitdiff
Move -add-plugin validation after -load was executed.
authorNico Weber <nicolasweber@gmx.de>
Sat, 5 Jan 2019 01:10:20 +0000 (01:10 +0000)
committerNico Weber <nicolasweber@gmx.de>
Sat, 5 Jan 2019 01:10:20 +0000 (01:10 +0000)
Moves the code added in r350340 around a bit, to hopefully make the existing
plugin tests pass when clang is built with examples enabled.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@350451 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/CompilerInvocation.cpp
lib/Frontend/FrontendAction.cpp

index 00083bd6225ab3bafbe6def5d6e2747631752522..04105f0980e61bd639dc94384f4a84ab497bcac8 100644 (file)
@@ -1666,20 +1666,7 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
     Opts.ProgramAction = frontend::PluginAction;
     Opts.ActionName = A->getValue();
   }
-  for (const std::string &Arg : Args.getAllArgValues(OPT_add_plugin)) {
-    bool Found = false;
-    for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
-                                          ie = FrontendPluginRegistry::end();
-         it != ie; ++it) {
-      if (it->getName() == Arg)
-        Found = true;
-    }
-    if (!Found) {
-      Diags.Report(diag::err_fe_invalid_plugin_name) << Arg;
-      continue;
-    }
-    Opts.AddPluginActions.push_back(Arg);
-  }
+  Opts.AddPluginActions = Args.getAllArgValues(OPT_add_plugin);
   for (const auto *AA : Args.filtered(OPT_plugin_arg))
     Opts.PluginArgs[AA->getValue(0)].emplace_back(AA->getValue(1));
 
index 83152bd353363d4aa2266f571cf2bf4f359d35fd..a1866e48cc46bfe8253e162fb098b6fd7a09d0f5 100644 (file)
@@ -156,6 +156,24 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI,
   if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end())
     return Consumer;
 
+  // Validate -add-plugin args.
+  bool FoundAllPlugins = true;
+  for (const std::string &Arg : CI.getFrontendOpts().AddPluginActions) {
+    bool Found = false;
+    for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
+                                          ie = FrontendPluginRegistry::end();
+         it != ie; ++it) {
+      if (it->getName() == Arg)
+        Found = true;
+    }
+    if (!Found) {
+      CI.getDiagnostics().Report(diag::err_fe_invalid_plugin_name) << Arg;
+      FoundAllPlugins = false;
+    }
+  }
+  if (!FoundAllPlugins)
+    return nullptr;
+
   // If this is a code completion run, avoid invoking the plugin consumers
   if (CI.hasCodeCompletionConsumer())
     return Consumer;