Skip to content

Commit

Permalink
Propagate a better error message to the C api.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227934 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
espindola committed Feb 3, 2015
1 parent d0d95db commit 52288fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/Bitcode/Reader/BitReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ LLVMBool LLVMParseBitcodeInContext(LLVMContextRef ContextRef,

ErrorOr<Module *> ModuleOrErr = parseBitcodeFile(
Buf, Ctx, [&](const DiagnosticInfo &DI) { DI.print(DP); });
if (std::error_code EC = ModuleOrErr.getError()) {
if (OutMessage)
*OutMessage = strdup(EC.message().c_str());
if (ModuleOrErr.getError()) {
if (OutMessage) {
Stream.flush();
*OutMessage = strdup(Message.c_str());
}
*OutModule = wrap((Module*)nullptr);
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion test/Bindings/llvm-c/invalid-bitcode.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
; RUN: not llvm-c-test --module-dump < %S/Inputs/invalid.ll.bc 2>&1 | FileCheck %s

CHECK: Error parsing bitcode: Corrupted bitcode
CHECK: Error parsing bitcode: Unknown attribute kind (48)

0 comments on commit 52288fa

Please sign in to comment.