diff options
Diffstat (limited to 'llvm/include/llvm/LTO/Config.h')
-rw-r--r-- | llvm/include/llvm/LTO/Config.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/include/llvm/LTO/Config.h b/llvm/include/llvm/LTO/Config.h index 60a5fa6eb36..4bd981c090b 100644 --- a/llvm/include/llvm/LTO/Config.h +++ b/llvm/include/llvm/LTO/Config.h @@ -171,20 +171,27 @@ 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(funcDiagHandler, &DiagHandler, true); + setDiagnosticHandler( + llvm::make_unique<LTOLLVMDiagnosticHandler>(&DiagHandler), true); } DiagnosticHandlerFunction DiagHandler; }; |