Add a libLTO diagnostic handler that supports lto_get_error_message API
This is a follow-up from the previous discussion on the thread:
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151019/307763.html
The LibLTO lto_get_error_message() API reads error messages from a std::string
sLastErrorString. Instead of passing this string around as an argument, this
patch creates a diagnostic handler and then sends this handler to the
constructor of LTOCodeGenerator.
Differential Revision: http://reviews.llvm.org/D14313
llvm-svn: 252791
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index 8dcc53c..5624050 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -64,23 +64,17 @@
#endif
}
-static void handleLTODiagnostic(const DiagnosticInfo &DI) {
- DiagnosticPrinterRawOStream DP(errs());
- DI.print(DP);
- errs() << "\n";
-}
-
LTOCodeGenerator::LTOCodeGenerator()
: Context(getGlobalContext()),
MergedModule(new Module("ld-temp.o", Context)),
- IRLinker(MergedModule.get(), handleLTODiagnostic) {
+ IRLinker(MergedModule.get()) {
initializeLTOPasses();
}
LTOCodeGenerator::LTOCodeGenerator(std::unique_ptr<LLVMContext> Context)
: OwnedContext(std::move(Context)), Context(*OwnedContext),
MergedModule(new Module("ld-temp.o", *OwnedContext)),
- IRLinker(MergedModule.get(), handleLTODiagnostic) {
+ IRLinker(MergedModule.get()) {
initializeLTOPasses();
}