diff options
author | John Brawn <john.brawn@arm.com> | 2016-03-15 12:51:40 +0000 |
---|---|---|
committer | John Brawn <john.brawn@arm.com> | 2016-03-15 12:51:40 +0000 |
commit | 6c78974b298d619ec11e243fb6fdea0b16f87a66 (patch) | |
tree | a3821d2f102bdc6db560013edefad6cd3f4e983c /clang/lib/FrontendTool | |
parent | 27fc7a7b47bc9656b5af858432518e81b9d36482 (diff) | |
download | bcm5719-llvm-6c78974b298d619ec11e243fb6fdea0b16f87a66.tar.gz bcm5719-llvm-6c78974b298d619ec11e243fb6fdea0b16f87a66.zip |
Make it possible for AST plugins to enable themselves by default
Currently when an AST plugin is loaded it must then be enabled by passing
-plugin pluginname or -add-plugin pluginname to the -cc1 command line. This
patch adds a method to PluginASTAction which allows it to declare that the
action happens before, instead of, or after the main AST action, plus the
relevant changes to make the plugin action happen at that time automatically.
Differential Revision: http://reviews.llvm.org/D17959
llvm-svn: 263546
Diffstat (limited to 'clang/lib/FrontendTool')
-rw-r--r-- | clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp index 116590e5375..509c326d159 100644 --- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -66,7 +66,9 @@ CreateFrontendBaseAction(CompilerInstance &CI) { it != ie; ++it) { if (it->getName() == CI.getFrontendOpts().ActionName) { std::unique_ptr<PluginASTAction> P(it->instantiate()); - if (!P->ParseArgs(CI, CI.getFrontendOpts().PluginArgs)) + if ((P->getActionType() != PluginASTAction::ReplaceAction && + P->getActionType() != PluginASTAction::Cmdline) || + !P->ParseArgs(CI, CI.getFrontendOpts().PluginArgs[it->getName()])) return nullptr; return std::move(P); } @@ -194,6 +196,18 @@ bool clang::ExecuteCompilerInvocation(CompilerInstance *Clang) { << Path << Error; } + // Check if any of the loaded plugins replaces the main AST action + for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(), + ie = FrontendPluginRegistry::end(); + it != ie; ++it) { + std::unique_ptr<PluginASTAction> P(it->instantiate()); + if (P->getActionType() == PluginASTAction::ReplaceAction) { + Clang->getFrontendOpts().ProgramAction = clang::frontend::PluginAction; + Clang->getFrontendOpts().ActionName = it->getName(); + break; + } + } + // Honor -mllvm. // // FIXME: Remove this, one day. |