From 52288fa1e6a208812ab6be650a686c5fa3b15834 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 3 Feb 2015 01:53:03 +0000 Subject: [PATCH] Propagate a better error message to the C api. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227934 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Reader/BitReader.cpp | 8 +++++--- test/Bindings/llvm-c/invalid-bitcode.test | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Bitcode/Reader/BitReader.cpp b/lib/Bitcode/Reader/BitReader.cpp index 8641cd1487c..868fbf010db 100644 --- a/lib/Bitcode/Reader/BitReader.cpp +++ b/lib/Bitcode/Reader/BitReader.cpp @@ -41,9 +41,11 @@ LLVMBool LLVMParseBitcodeInContext(LLVMContextRef ContextRef, ErrorOr 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; } diff --git a/test/Bindings/llvm-c/invalid-bitcode.test b/test/Bindings/llvm-c/invalid-bitcode.test index 997f7b5d5b7..6318a9bf13d 100644 --- a/test/Bindings/llvm-c/invalid-bitcode.test +++ b/test/Bindings/llvm-c/invalid-bitcode.test @@ -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) -- 2.40.0