mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Allow the C API users to keep relying on the OutMessages parameter.
Should fix the Ocaml tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220611 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e272236d69
commit
f4a288c0f0
@ -1766,8 +1766,33 @@ bool Linker::LinkModules(Module *Dest, Module *Src, unsigned Mode) {
|
||||
// C API.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
static void bindingDiagnosticHandler(const llvm::DiagnosticInfo &DI,
|
||||
void *Context) {
|
||||
if (DI.getSeverity() != DS_Error)
|
||||
return;
|
||||
|
||||
std::string *Message = (std::string *)Context;
|
||||
{
|
||||
raw_string_ostream Stream(*Message);
|
||||
DiagnosticPrinterRawOStream DP(Stream);
|
||||
DI.print(DP);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LLVMBool LLVMLinkModules(LLVMModuleRef Dest, LLVMModuleRef Src,
|
||||
LLVMLinkerMode Mode, char **OutMessages) {
|
||||
LLVMBool Result = Linker::LinkModules(unwrap(Dest), unwrap(Src), Mode);
|
||||
Module *D = unwrap(Dest);
|
||||
LLVMContext &Ctx = D->getContext();
|
||||
|
||||
LLVMContext::DiagnosticHandlerTy OldHandler = Ctx.getDiagnosticHandler();
|
||||
void *OldDiagnosticContext = Ctx.getDiagnosticContext();
|
||||
std::string Message;
|
||||
Ctx.setDiagnosticHandler(bindingDiagnosticHandler, &Message);
|
||||
LLVMBool Result = Linker::LinkModules(D, unwrap(Src), Mode);
|
||||
Ctx.setDiagnosticHandler(OldHandler, OldDiagnosticContext);
|
||||
|
||||
if (OutMessages && Result)
|
||||
*OutMessages = strdup(Message.c_str());
|
||||
return Result;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user