diff options
author | Yunzhong Gao <Yunzhong_Gao@playstation.sony.com> | 2015-11-11 19:59:08 +0000 |
---|---|---|
committer | Yunzhong Gao <Yunzhong_Gao@playstation.sony.com> | 2015-11-11 19:59:08 +0000 |
commit | ea7b3a232078690ea57a45d37601fc7cfea6de3d (patch) | |
tree | c340fccb32d93b4b8081b12662e0e05b18867209 /llvm/tools | |
parent | 0c6a4f197fe6aa95435323cbdbc4fe23e3694205 (diff) | |
download | bcm5719-llvm-ea7b3a232078690ea57a45d37601fc7cfea6de3d.tar.gz bcm5719-llvm-ea7b3a232078690ea57a45d37601fc7cfea6de3d.zip |
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
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/lto/lto.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp index 62675081464..0839a566cc5 100644 --- a/llvm/tools/lto/lto.cpp +++ b/llvm/tools/lto/lto.cpp @@ -85,13 +85,21 @@ static void lto_initialize() { namespace { +static void handleLibLTODiagnostic(lto_codegen_diagnostic_severity_t Severity, + const char *Msg, void *) { + sLastErrorString = Msg; + sLastErrorString += "\n"; +} + // This derived class owns the native object file. This helps implement the // libLTO API semantics, which require that the code generator owns the object // file. struct LibLTOCodeGenerator : LTOCodeGenerator { - LibLTOCodeGenerator() {} + LibLTOCodeGenerator() { + setDiagnosticHandler(handleLibLTODiagnostic, nullptr); } LibLTOCodeGenerator(std::unique_ptr<LLVMContext> Context) - : LTOCodeGenerator(std::move(Context)) {} + : LTOCodeGenerator(std::move(Context)) { + setDiagnosticHandler(handleLibLTODiagnostic, nullptr); } std::unique_ptr<MemoryBuffer> NativeObjectFile; }; |