Ubsan this newly discovered dead code
This commit is contained in:
parent
1caa593cb6
commit
ecab96fd7c
|
@ -399,10 +399,7 @@ impl CodegenContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DiagnosticHandlers<'a> {
|
struct DiagnosticHandlers<'a> {
|
||||||
#[allow(dead_code)]
|
data: *mut (&'a CodegenContext, &'a Handler),
|
||||||
// This value is not actually dead, llcx has pointers to it and needs these pointers to be alive
|
|
||||||
// until Drop is executed on this object
|
|
||||||
inner: Box<(&'a CodegenContext, &'a Handler)>,
|
|
||||||
llcx: ContextRef,
|
llcx: ContextRef,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,24 +407,22 @@ impl<'a> DiagnosticHandlers<'a> {
|
||||||
fn new(cgcx: &'a CodegenContext,
|
fn new(cgcx: &'a CodegenContext,
|
||||||
handler: &'a Handler,
|
handler: &'a Handler,
|
||||||
llcx: ContextRef) -> DiagnosticHandlers<'a> {
|
llcx: ContextRef) -> DiagnosticHandlers<'a> {
|
||||||
let data = Box::new((cgcx, handler));
|
let data = Box::into_raw(Box::new((cgcx, handler)));
|
||||||
unsafe {
|
unsafe {
|
||||||
let arg = &*data as &(_, _) as *const _ as *mut _;
|
llvm::LLVMRustSetInlineAsmDiagnosticHandler(llcx, inline_asm_handler, data as *mut _);
|
||||||
llvm::LLVMRustSetInlineAsmDiagnosticHandler(llcx, inline_asm_handler, arg);
|
llvm::LLVMContextSetDiagnosticHandler(llcx, diagnostic_handler, data as *mut _);
|
||||||
llvm::LLVMContextSetDiagnosticHandler(llcx, diagnostic_handler, arg);
|
|
||||||
}
|
|
||||||
DiagnosticHandlers {
|
|
||||||
inner: data,
|
|
||||||
llcx: llcx,
|
|
||||||
}
|
}
|
||||||
|
DiagnosticHandlers { data, llcx }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Drop for DiagnosticHandlers<'a> {
|
impl<'a> Drop for DiagnosticHandlers<'a> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
|
use std::ptr::null_mut;
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMRustSetInlineAsmDiagnosticHandler(self.llcx, inline_asm_handler, 0 as *mut _);
|
llvm::LLVMRustSetInlineAsmDiagnosticHandler(self.llcx, inline_asm_handler, null_mut());
|
||||||
llvm::LLVMContextSetDiagnosticHandler(self.llcx, diagnostic_handler, 0 as *mut _);
|
llvm::LLVMContextSetDiagnosticHandler(self.llcx, diagnostic_handler, null_mut());
|
||||||
|
drop(Box::from_raw(self.data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue