Allow alias to point to an arbitrary ConstantExpr.
[oota-llvm.git] / lib / Bitcode / Reader / BitReader.cpp
index 4136cec7c3278b30cff6bcc8185acf8d241c2eba..716299fc68e3171c4926863e278d3c5230d218a4 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*)nullptr);
     return 1;
   }
 
+  *OutModule = wrap(ModuleOrErr.get());
   return 0;
 }
 
@@ -55,7 +55,7 @@ LLVMBool LLVMGetBitcodeModuleInContext(LLVMContextRef ContextRef,
       getLazyBitcodeModule(unwrap(MemBuf), *unwrap(ContextRef));
 
   if (error_code EC = ModuleOrErr.getError()) {
-    *OutM = wrap((Module *)NULL);
+    *OutM = wrap((Module *)nullptr);
     if (OutMessage)
       *OutMessage = strdup(EC.message().c_str());
     return 1;