It was not setting OutMessage.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255998
91177308-0d34-0410-b5e6-
96231b3b80d8
LLVMMemoryBufferRef MemBuf,
LLVMModuleRef *OutM,
char **OutMessage) {
LLVMMemoryBufferRef MemBuf,
LLVMModuleRef *OutM,
char **OutMessage) {
+ LLVMContext &Ctx = *unwrap(ContextRef);
+ LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler =
+ Ctx.getDiagnosticHandler();
+ void *OldDiagnosticContext = Ctx.getDiagnosticContext();
+
+ Ctx.setDiagnosticHandler(diagnosticHandler, &Message, true);
std::unique_ptr<MemoryBuffer> Owner(unwrap(MemBuf));
ErrorOr<std::unique_ptr<Module>> ModuleOrErr =
std::unique_ptr<MemoryBuffer> Owner(unwrap(MemBuf));
ErrorOr<std::unique_ptr<Module>> ModuleOrErr =
- getLazyBitcodeModule(std::move(Owner), *unwrap(ContextRef));
+ getLazyBitcodeModule(std::move(Owner), Ctx);
+ Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext, true);
- if (std::error_code EC = ModuleOrErr.getError()) {
+ if (ModuleOrErr.getError()) {
*OutM = wrap((Module *)nullptr);
if (OutMessage)
*OutM = wrap((Module *)nullptr);
if (OutMessage)
- *OutMessage = strdup(EC.message().c_str());
+ *OutMessage = strdup(Message.c_str());
; RUN: not llvm-c-test --module-dump < %S/Inputs/invalid.ll.bc 2>&1 | FileCheck %s
; RUN: not llvm-c-test --module-dump < %S/Inputs/invalid.ll.bc 2>&1 | FileCheck %s
+; RUN: not llvm-c-test --lazy-module-dump < %S/Inputs/invalid.ll.bc 2>&1 | FileCheck %s
CHECK: Error parsing bitcode: Unknown attribute kind (52)
CHECK: Error parsing bitcode: Unknown attribute kind (52)