From: Nico Weber Date: Sat, 29 Jan 2011 21:21:49 +0000 (+0000) Subject: Support for -plugin-arg- with -add-plugin X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f25649c74397d2620e6ac61f1045261644707c80;p=clang Support for -plugin-arg- with -add-plugin git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124551 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Frontend/FrontendOptions.h b/include/clang/Frontend/FrontendOptions.h index fe953a4595..f19914ecd7 100644 --- a/include/clang/Frontend/FrontendOptions.h +++ b/include/clang/Frontend/FrontendOptions.h @@ -100,12 +100,15 @@ public: /// The name of the action to run when using a plugin action. std::string ActionName; - /// Arg to pass to the plugin + /// Args to pass to the plugin std::vector PluginArgs; /// The list of plugin actions to run in addition to the normal action. std::vector AddPluginActions; + /// Args to pass to the additional plugins + std::vector > AddPluginArgs; + /// The list of plugins to load. std::vector Plugins; diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 28cae64bff..3fdbc1683c 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -438,6 +438,10 @@ static void FrontendOptsToArgs(const FrontendOptions &Opts, for (unsigned i = 0, e = Opts.AddPluginActions.size(); i != e; ++i) { Res.push_back("-add-plugin"); Res.push_back(Opts.AddPluginActions[i]); + for(unsigned ai = 0, ae = Opts.AddPluginArgs.size(); ai != ae; ++ai) { + Res.push_back("-plugin-arg-" + Opts.AddPluginActions[i]); + Res.push_back(Opts.AddPluginArgs[i][ai]); + } } for (unsigned i = 0, e = Opts.ASTMergeFiles.size(); i != e; ++i) { Res.push_back("-ast-merge"); @@ -1106,6 +1110,14 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args, } Opts.AddPluginActions = Args.getAllArgValues(OPT_add_plugin); + Opts.AddPluginArgs.resize(Opts.AddPluginActions.size()); + for (int i = 0, e = Opts.AddPluginActions.size(); i != e; ++i) { + for (arg_iterator it = Args.filtered_begin(OPT_plugin_arg), + end = Args.filtered_end(); it != end; ++it) { + if ((*it)->getValue(Args, 0) == Opts.AddPluginActions[i]) + Opts.AddPluginArgs[i].push_back((*it)->getValue(Args, 1)); + } + } if (const Arg *A = Args.getLastArg(OPT_code_completion_at)) { Opts.CodeCompletionAt = diff --git a/lib/Frontend/FrontendAction.cpp b/lib/Frontend/FrontendAction.cpp index 1a5c042247..5f78fb1772 100644 --- a/lib/Frontend/FrontendAction.cpp +++ b/lib/Frontend/FrontendAction.cpp @@ -112,7 +112,7 @@ ASTConsumer* FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI, if (it->getName() == CI.getFrontendOpts().AddPluginActions[i]) { llvm::OwningPtr P(it->instantiate()); FrontendAction* c = P.get(); - if (P->ParseArgs(CI, CI.getFrontendOpts().PluginArgs)) + if (P->ParseArgs(CI, CI.getFrontendOpts().AddPluginArgs[i])) Consumers.push_back(c->CreateASTConsumer(CI, InFile)); } }