Propagate a better error message to the C api.

llvm-svn: 227934
This commit is contained in:
Rafael Espindola 2015-02-03 01:53:03 +00:00
parent 6a196ce691
commit dcfd6ed183
2 changed files with 6 additions and 4 deletions

View File

@ -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;
}

View File

@ -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)