From 99c7fec2c94bd44fd16ba50340896287438e6a0e Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 13 Jan 2014 18:31:04 +0000 Subject: 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 --- lib/Bitcode/Reader/BitReader.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/Bitcode/Reader/BitReader.cpp') 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 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; } -- cgit v1.2.3