summaryrefslogtreecommitdiff
path: root/lib/Bitcode/Reader/BitReader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Bitcode/Reader/BitReader.cpp')
-rw-r--r--lib/Bitcode/Reader/BitReader.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/Bitcode/Reader/BitReader.cpp b/lib/Bitcode/Reader/BitReader.cpp
index 23630e5525..4136cec7c3 100644
--- a/lib/Bitcode/Reader/BitReader.cpp
+++ b/lib/Bitcode/Reader/BitReader.cpp
@@ -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;
}