diff --git a/llvm/lib/Bytecode/Reader/Reader.cpp b/llvm/lib/Bytecode/Reader/Reader.cpp index e2ab8c10e671..1c747af948c7 100644 --- a/llvm/lib/Bytecode/Reader/Reader.cpp +++ b/llvm/lib/Bytecode/Reader/Reader.cpp @@ -1758,8 +1758,13 @@ void BytecodeReader::ParseFunctionLazily() { /// @see ParseBytecode bool BytecodeReader::ParseFunction(Function* Func, std::string* ErrMsg) { - if (setjmp(context)) + if (setjmp(context)) { + // Set caller's error message, if requested + if (ErrMsg) + *ErrMsg = ErrorMsg; + // Indicate an error occurred return true; + } // Find {start, end} pointers and slot in the map. If not there, we're done. LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.find(Func); @@ -1788,8 +1793,13 @@ bool BytecodeReader::ParseFunction(Function* Func, std::string* ErrMsg) { /// to materialize the functions. /// @see ParseBytecode bool BytecodeReader::ParseAllFunctionBodies(std::string* ErrMsg) { - if (setjmp(context)) + if (setjmp(context)) { + // Set caller's error message, if requested + if (ErrMsg) + *ErrMsg = ErrorMsg; + // Indicate an error occurred return true; + } LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.begin(); LazyFunctionMap::iterator Fe = LazyFunctionLoadMap.end(); diff --git a/llvm/lib/Bytecode/Reader/ReaderWrappers.cpp b/llvm/lib/Bytecode/Reader/ReaderWrappers.cpp index d45a0f79bf38..a69f297ff092 100644 --- a/llvm/lib/Bytecode/Reader/ReaderWrappers.cpp +++ b/llvm/lib/Bytecode/Reader/ReaderWrappers.cpp @@ -309,7 +309,7 @@ Module *llvm::ParseBytecodeBuffer(const unsigned char *Buffer, unsigned Length, ModuleProvider *MP = getBytecodeBufferModuleProvider(Buffer, Length, ModuleID, ErrMsg, 0); if (!MP) return 0; - Module *M = MP->releaseModule(); + Module *M = MP->releaseModule(ErrMsg); delete MP; return M; } @@ -341,7 +341,7 @@ Module *llvm::ParseBytecodeFile(const std::string &Filename, std::string *ErrMsg) { ModuleProvider* MP = getBytecodeModuleProvider(Filename, ErrMsg); if (!MP) return 0; - Module *M = MP->releaseModule(); + Module *M = MP->releaseModule(ErrMsg); delete MP; return M; } @@ -356,7 +356,7 @@ Module* llvm::AnalyzeBytecodeFile( BytecodeHandler* AH = createBytecodeAnalyzerHandler(bca,output); ModuleProvider* MP = getBytecodeModuleProvider(Filename, ErrMsg, AH); if (!MP) return 0; - Module *M = MP->releaseModule(); + Module *M = MP->releaseModule(ErrMsg); delete MP; return M; } @@ -375,7 +375,7 @@ Module* llvm::AnalyzeBytecodeBuffer( ModuleProvider* MP = getBytecodeBufferModuleProvider(Buffer, Length, ModuleID, ErrMsg, hdlr); if (!MP) return 0; - Module *M = MP->releaseModule(); + Module *M = MP->releaseModule(ErrMsg); delete MP; return M; } @@ -388,7 +388,7 @@ bool llvm::GetBytecodeDependentLibraries(const std::string &fname, deplibs.clear(); return true; } - Module* M = MP->releaseModule(); + Module* M = MP->releaseModule(ErrMsg); deplibs = M->getLibraries(); delete M; delete MP;