OSDN Git Service

Update to LLVM 3.5a.
[android-x86/external-llvm.git] / lib / Bitcode / Reader / BitReader.cpp
index 23630e5..3e360a8 100644 (file)
@@ -30,16 +30,16 @@ LLVMBool LLVMParseBitcodeInContext(LLVMContextRef ContextRef,
                                    LLVMMemoryBufferRef MemBuf,
                                    LLVMModuleRef *OutModule,
                                    char **OutMessage) {
-  std::string Message;
-
-  *OutModule = wrap(ParseBitcodeFile(unwrap(MemBuf), *unwrap(ContextRef),
-                                     &Message));
-  if (!*OutModule) {
+  ErrorOr<Module *> ModuleOrErr =
+      parseBitcodeFile(unwrap(MemBuf), *unwrap(ContextRef));
+  if (error_code EC = ModuleOrErr.getError()) {
     if (OutMessage)
-      *OutMessage = strdup(Message.c_str());
+      *OutMessage = strdup(EC.message().c_str());
+    *OutModule = wrap((Module*)0);
     return 1;
   }
 
+  *OutModule = wrap(ModuleOrErr.get());
   return 0;
 }
 
@@ -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;
 
 }