r220733 - Use the newer/simple API for passing a diagnostic handler to the IR linker.

Rafael Espindola rafael.espindola at gmail.com
Mon Oct 27 16:02:34 PDT 2014


Author: rafael
Date: Mon Oct 27 18:02:34 2014
New Revision: 220733

URL: http://llvm.org/viewvc/llvm-project?rev=220733&view=rev
Log:
Use the newer/simple API for passing a diagnostic handler to the IR linker.

Modified:
    cfe/trunk/lib/CodeGen/CodeGenAction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=220733&r1=220732&r2=220733&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Mon Oct 27 18:02:34 2014
@@ -153,15 +153,9 @@ namespace clang {
 
       // Link LinkModule into this module if present, preserving its validity.
       if (LinkModule) {
-        LLVMContext &Ctx = LinkModule->getContext();
-        LLVMContext::DiagnosticHandlerTy OldHandler =
-            Ctx.getDiagnosticHandler();
-        void *OldDiagnosticContext = Ctx.getDiagnosticContext();
-        Ctx.setDiagnosticHandler(linkerDiagnosticHandler, this);
-        bool Failed =
-            Linker::LinkModules(M, LinkModule.get(), Linker::PreserveSource);
-        Ctx.setDiagnosticHandler(OldHandler, OldDiagnosticContext);
-        if (Failed)
+        if (Linker::LinkModules(
+                M, LinkModule.get(), Linker::PreserveSource,
+                [=](const DiagnosticInfo &DI) { linkerDiagnosticHandler(DI); }))
           return;
       }
 
@@ -225,12 +219,7 @@ namespace clang {
       ((BackendConsumer*)Context)->InlineAsmDiagHandler2(SM, Loc);
     }
 
-    static void linkerDiagnosticHandler(const llvm::DiagnosticInfo &DI,
-                                        void *Context) {
-      ((BackendConsumer *)Context)->linkerDiagnosticHandlerImpl(DI);
-    }
-
-    void linkerDiagnosticHandlerImpl(const llvm::DiagnosticInfo &DI);
+    void linkerDiagnosticHandler(const llvm::DiagnosticInfo &DI);
 
     static void DiagnosticHandler(const llvm::DiagnosticInfo &DI,
                                   void *Context) {
@@ -507,7 +496,7 @@ void BackendConsumer::OptimizationFailur
   EmitOptimizationMessage(D, diag::warn_fe_backend_optimization_failure);
 }
 
-void BackendConsumer::linkerDiagnosticHandlerImpl(const DiagnosticInfo &DI) {
+void BackendConsumer::linkerDiagnosticHandler(const DiagnosticInfo &DI) {
   if (DI.getSeverity() != DS_Error)
     return;
 





More information about the cfe-commits mailing list