aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenAction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/CodeGenAction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenAction.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp
index 778d4df..da35246 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -1115,6 +1115,14 @@ void CodeGenAction::ExecuteAction() {
LLVMContext &Ctx = TheModule->getContext();
Ctx.setInlineAsmDiagnosticHandler(BitcodeInlineAsmDiagHandler, &Diagnostics);
+ // Restore any diagnostic handler previously set before returning from this
+ // function.
+ struct RAII {
+ LLVMContext &Ctx;
+ std::unique_ptr<DiagnosticHandler> PrevHandler = Ctx.getDiagnosticHandler();
+ ~RAII() { Ctx.setDiagnosticHandler(std::move(PrevHandler)); }
+ } _{Ctx};
+
// Set clang diagnostic handler. To do this we need to create a fake
// BackendConsumer.
BackendConsumer Result(BA, CI.getDiagnostics(), CI.getHeaderSearchOpts(),