diff options
author | Vivek Pandya <vivekvpandya@gmail.com> | 2017-09-15 19:53:54 +0000 |
---|---|---|
committer | Vivek Pandya <vivekvpandya@gmail.com> | 2017-09-15 19:53:54 +0000 |
commit | 4abccff981adfaddf2a26bc1a6a8bce374f01574 (patch) | |
tree | f9cf7a8ab83f3e3f8413b767f045bfa77ecf32c6 /tools/llvm-lto | |
parent | 885ad98e060cd960531fd534ab850babd715d65e (diff) |
This reverts r313381
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313387 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-lto')
-rw-r--r-- | tools/llvm-lto/llvm-lto.cpp | 66 |
1 files changed, 29 insertions, 37 deletions
diff --git a/tools/llvm-lto/llvm-lto.cpp b/tools/llvm-lto/llvm-lto.cpp index bbd0edac108..dd4199112ee 100644 --- a/tools/llvm-lto/llvm-lto.cpp +++ b/tools/llvm-lto/llvm-lto.cpp @@ -235,40 +235,34 @@ static void handleDiagnostics(lto_codegen_diagnostic_severity_t Severity, } static std::string CurrentActivity; - -namespace { - struct LLVMLTODiagnosticHandler : public DiagnosticHandler { - bool handleDiagnostics(const DiagnosticInfo &DI) override { - raw_ostream &OS = errs(); - OS << "llvm-lto: "; - switch (DI.getSeverity()) { - case DS_Error: - OS << "error"; - break; - case DS_Warning: - OS << "warning"; - break; - case DS_Remark: - OS << "remark"; - break; - case DS_Note: - OS << "note"; - break; - } - if (!CurrentActivity.empty()) - OS << ' ' << CurrentActivity; - OS << ": "; - - DiagnosticPrinterRawOStream DP(OS); - DI.print(DP); - OS << '\n'; - - if (DI.getSeverity() == DS_Error) - exit(1); - return true; - } - }; +static void diagnosticHandler(const DiagnosticInfo &DI, void *Context) { + raw_ostream &OS = errs(); + OS << "llvm-lto: "; + switch (DI.getSeverity()) { + case DS_Error: + OS << "error"; + break; + case DS_Warning: + OS << "warning"; + break; + case DS_Remark: + OS << "remark"; + break; + case DS_Note: + OS << "note"; + break; } + if (!CurrentActivity.empty()) + OS << ' ' << CurrentActivity; + OS << ": "; + + DiagnosticPrinterRawOStream DP(OS); + DI.print(DP); + OS << '\n'; + + if (DI.getSeverity() == DS_Error) + exit(1); +} static void error(const Twine &Msg) { errs() << "llvm-lto: " << Msg << '\n'; @@ -299,8 +293,7 @@ getLocalLTOModule(StringRef Path, std::unique_ptr<MemoryBuffer> &Buffer, Buffer = std::move(BufferOrErr.get()); CurrentActivity = ("loading file '" + Path + "'").str(); std::unique_ptr<LLVMContext> Context = llvm::make_unique<LLVMContext>(); - Context->setDiagnosticHandler(llvm::make_unique<LLVMLTODiagnosticHandler>(), - true); + Context->setDiagnosticHandler(diagnosticHandler, nullptr, true); ErrorOr<std::unique_ptr<LTOModule>> Ret = LTOModule::createInLocalContext( std::move(Context), Buffer->getBufferStart(), Buffer->getBufferSize(), Options, Path); @@ -844,8 +837,7 @@ int main(int argc, char **argv) { unsigned BaseArg = 0; LLVMContext Context; - Context.setDiagnosticHandler(llvm::make_unique<LLVMLTODiagnosticHandler>(), - true); + Context.setDiagnosticHandler(diagnosticHandler, nullptr, true); LTOCodeGenerator CodeGen(Context); |