Update getLazyBitcodeModule to use ErrorOr for error handling.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199125 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2014-01-13 18:31:04 +00:00
parent 36713c2c0a
commit 99c7fec2c9
7 changed files with 41 additions and 34 deletions

View File

@@ -36,15 +36,16 @@ Module *llvm::getLazyIRModule(MemoryBuffer *Buffer, SMDiagnostic &Err,
if (isBitcode((const unsigned char *)Buffer->getBufferStart(),
(const unsigned char *)Buffer->getBufferEnd())) {
std::string ErrMsg;
Module *M = getLazyBitcodeModule(Buffer, Context, &ErrMsg);
if (M == 0) {
ErrorOr<Module *> ModuleOrErr = getLazyBitcodeModule(Buffer, Context);
if (error_code EC = ModuleOrErr.getError()) {
Err = SMDiagnostic(Buffer->getBufferIdentifier(), SourceMgr::DK_Error,
ErrMsg);
EC.message());
// ParseBitcodeFile does not take ownership of the Buffer in the
// case of an error.
delete Buffer;
return NULL;
}
return M;
return ModuleOrErr.get();
}
return ParseAssembly(Buffer, 0, Err, Context);