mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-16 18:30:52 +00:00
Fix error handling in LLVMGetBitcodeModuleInContext.
It was not setting OutMessage. llvm-svn: 255998
This commit is contained in:
parent
888cff000a
commit
a61d61e740
@ -71,17 +71,24 @@ LLVMBool LLVMGetBitcodeModuleInContext(LLVMContextRef ContextRef,
|
||||
LLVMMemoryBufferRef MemBuf,
|
||||
LLVMModuleRef *OutM,
|
||||
char **OutMessage) {
|
||||
LLVMContext &Ctx = *unwrap(ContextRef);
|
||||
LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler =
|
||||
Ctx.getDiagnosticHandler();
|
||||
void *OldDiagnosticContext = Ctx.getDiagnosticContext();
|
||||
|
||||
std::string Message;
|
||||
Ctx.setDiagnosticHandler(diagnosticHandler, &Message, true);
|
||||
std::unique_ptr<MemoryBuffer> Owner(unwrap(MemBuf));
|
||||
|
||||
ErrorOr<std::unique_ptr<Module>> ModuleOrErr =
|
||||
getLazyBitcodeModule(std::move(Owner), *unwrap(ContextRef));
|
||||
getLazyBitcodeModule(std::move(Owner), Ctx);
|
||||
Owner.release();
|
||||
Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext, true);
|
||||
|
||||
if (std::error_code EC = ModuleOrErr.getError()) {
|
||||
if (ModuleOrErr.getError()) {
|
||||
*OutM = wrap((Module *)nullptr);
|
||||
if (OutMessage)
|
||||
*OutMessage = strdup(EC.message().c_str());
|
||||
*OutMessage = strdup(Message.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
; 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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user