diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp index 77747f7f285..f1c5680adda 100644 --- a/tools/lto/LTOCodeGenerator.cpp +++ b/tools/lto/LTOCodeGenerator.cpp @@ -43,6 +43,7 @@ #include "llvm/Support/Host.h" #include "llvm/Support/Program.h" #include "llvm/Support/Signals.h" +#include "llvm/Support/system_error.h" #include "llvm/Config/config.h" #include #include @@ -221,9 +222,12 @@ const void* LTOCodeGenerator::compile(size_t* length, std::string& errMsg) if ( !asmResult ) { // remove old buffer if compile() called twice delete _nativeObjectFile; - + // read .o file into memory buffer - _nativeObjectFile = MemoryBuffer::getFile(uniqueObjStr.c_str(),&errMsg); + error_code ec; + _nativeObjectFile = MemoryBuffer::getFile(uniqueObjStr.c_str(), ec); + if (ec) + errMsg = ec.message(); } // remove temp files diff --git a/tools/lto/LTOModule.cpp b/tools/lto/LTOModule.cpp index 7a91562ec45..2453e2b2c2d 100644 --- a/tools/lto/LTOModule.cpp +++ b/tools/lto/LTOModule.cpp @@ -26,6 +26,7 @@ #include "llvm/Support/Host.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" +#include "llvm/Support/system_error.h" #include "llvm/Target/Mangler.h" #include "llvm/Target/SubtargetFeature.h" #include "llvm/MC/MCAsmInfo.h" @@ -56,7 +57,8 @@ bool LTOModule::isBitcodeFileForTarget(const void *mem, size_t length, bool LTOModule::isBitcodeFileForTarget(const char *path, const char *triplePrefix) { - MemoryBuffer *buffer = MemoryBuffer::getFile(path); + error_code ec; + MemoryBuffer *buffer = MemoryBuffer::getFile(path, ec); if (buffer == NULL) return false; return isTargetMatch(buffer, triplePrefix); @@ -78,9 +80,12 @@ LTOModule::LTOModule(Module *m, TargetMachine *t) LTOModule *LTOModule::makeLTOModule(const char *path, std::string &errMsg) { - OwningPtr buffer(MemoryBuffer::getFile(path, &errMsg)); - if (!buffer) + error_code ec; + OwningPtr buffer(MemoryBuffer::getFile(path, ec)); + if (!buffer) { + errMsg = ec.message(); return NULL; + } return makeLTOModule(buffer.get(), errMsg); }