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

@ -51,15 +51,18 @@ LLVMBool LLVMGetBitcodeModuleInContext(LLVMContextRef ContextRef,
LLVMModuleRef *OutM,
char **OutMessage) {
std::string Message;
ErrorOr<Module *> ModuleOrErr =
getLazyBitcodeModule(unwrap(MemBuf), *unwrap(ContextRef));
*OutM = wrap(getLazyBitcodeModule(unwrap(MemBuf), *unwrap(ContextRef),
&Message));
if (!*OutM) {
if (error_code EC = ModuleOrErr.getError()) {
*OutM = wrap((Module *)NULL);
if (OutMessage)
*OutMessage = strdup(Message.c_str());
*OutMessage = strdup(EC.message().c_str());
return 1;
}
*OutM = wrap(ModuleOrErr.get());
return 0;
}