diff options
Diffstat (limited to 'llvm/include/llvm/LTO/Config.h')
| -rw-r--r-- | llvm/include/llvm/LTO/Config.h | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/llvm/include/llvm/LTO/Config.h b/llvm/include/llvm/LTO/Config.h index 4bd981c090b..60a5fa6eb36 100644 --- a/llvm/include/llvm/LTO/Config.h +++ b/llvm/include/llvm/LTO/Config.h @@ -171,27 +171,20 @@ struct Config { bool UseInputModulePath = false); }; -struct LTOLLVMDiagnosticHandler : public DiagnosticHandler { - DiagnosticHandlerFunction *Fn; - LTOLLVMDiagnosticHandler(DiagnosticHandlerFunction *DiagHandlerFn) - : Fn(DiagHandlerFn) {} - bool handleDiagnostics(const DiagnosticInfo &DI) override { - (*Fn)(DI); - return true; - } -}; /// A derived class of LLVMContext that initializes itself according to a given /// Config object. The purpose of this class is to tie ownership of the /// diagnostic handler to the context, as opposed to the Config object (which /// may be ephemeral). -// FIXME: This should not be required as diagnostic handler is not callback. struct LTOLLVMContext : LLVMContext { + static void funcDiagHandler(const DiagnosticInfo &DI, void *Context) { + auto *Fn = static_cast<DiagnosticHandlerFunction *>(Context); + (*Fn)(DI); + } LTOLLVMContext(const Config &C) : DiagHandler(C.DiagHandler) { setDiscardValueNames(C.ShouldDiscardValueNames); enableDebugTypeODRUniquing(); - setDiagnosticHandler( - llvm::make_unique<LTOLLVMDiagnosticHandler>(&DiagHandler), true); + setDiagnosticHandler(funcDiagHandler, &DiagHandler, true); } DiagnosticHandlerFunction DiagHandler; }; |

