diff options
author | Nico Weber <nicolasweber@gmx.de> | 2011-01-29 21:21:49 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2011-01-29 21:21:49 +0000 |
commit | 741bf9d872dfe9bdbf5b7e65bc84b97fb17bb328 (patch) | |
tree | 22937669eb86bb8a890e6c4d16e00603305a6e6c | |
parent | 537fdceded86b5c4c06eb0ac0ff80189c82d7193 (diff) | |
download | bcm5719-llvm-741bf9d872dfe9bdbf5b7e65bc84b97fb17bb328.tar.gz bcm5719-llvm-741bf9d872dfe9bdbf5b7e65bc84b97fb17bb328.zip |
Support for -plugin-arg- with -add-plugin
llvm-svn: 124551
-rw-r--r-- | clang/include/clang/Frontend/FrontendOptions.h | 5 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 12 | ||||
-rw-r--r-- | clang/lib/Frontend/FrontendAction.cpp | 2 |
3 files changed, 17 insertions, 2 deletions
diff --git a/clang/include/clang/Frontend/FrontendOptions.h b/clang/include/clang/Frontend/FrontendOptions.h index fe953a45958..f19914ecd78 100644 --- a/clang/include/clang/Frontend/FrontendOptions.h +++ b/clang/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<std::string> PluginArgs; /// The list of plugin actions to run in addition to the normal action. std::vector<std::string> AddPluginActions; + /// Args to pass to the additional plugins + std::vector<std::vector<std::string> > AddPluginArgs; + /// The list of plugins to load. std::vector<std::string> Plugins; diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 28cae64bff2..3fdbc1683cd 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/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/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 1a5c0422477..5f78fb17723 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -112,7 +112,7 @@ ASTConsumer* FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI, if (it->getName() == CI.getFrontendOpts().AddPluginActions[i]) { llvm::OwningPtr<PluginASTAction> 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)); } } |