aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/FrontendAction.cpp
diff options
context:
space:
mode:
authorArthur Eubanks <aeubanks@google.com>2021-10-20 15:43:10 -0700
committerArthur Eubanks <aeubanks@google.com>2021-10-21 09:03:57 -0700
commit2dcad7754a204d5dbb78fef8f6b13cd005456e33 (patch)
tree7421630d2dcac1fd76a68f8eb3c1db0764f51358 /clang/lib/Frontend/FrontendAction.cpp
parentb8da594750762f811283820c19b02cedfb6632d4 (diff)
downloadllvm-2dcad7754a204d5dbb78fef8f6b13cd005456e33.zip
llvm-2dcad7754a204d5dbb78fef8f6b13cd005456e33.tar.gz
llvm-2dcad7754a204d5dbb78fef8f6b13cd005456e33.tar.bz2
[clang] Don't clear AST if we have consumers running after the main action
Downstream users may have Clang plugins. By default these plugins run after the main action if they are specified on the command line. Since these plugins are ASTConsumers, presumably they inspect the AST. So we shouldn't clear it if any plugins run after the main action. Reviewed By: dblaikie, hans Differential Revision: https://reviews.llvm.org/D112190
Diffstat (limited to 'clang/lib/Frontend/FrontendAction.cpp')
-rw-r--r--clang/lib/Frontend/FrontendAction.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp
index b56db78..089f40b 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -217,8 +217,13 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI,
// Add to Consumers the main consumer, then all the plugins that go after it
Consumers.push_back(std::move(Consumer));
- for (auto &C : AfterConsumers) {
- Consumers.push_back(std::move(C));
+ if (!AfterConsumers.empty()) {
+ // If we have plugins after the main consumer, which may be the codegen
+ // action, they likely will need the ASTContext, so don't clear it in the
+ // codegen action.
+ CI.getCodeGenOpts().ClearASTBeforeBackend = false;
+ for (auto &C : AfterConsumers)
+ Consumers.push_back(std::move(C));
}
return std::make_unique<MultiplexConsumer>(std::move(Consumers));