aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/FrontendAction.cpp
diff options
context:
space:
mode:
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));