rustc_codegen_llvm: use safe references for Linker.
This commit is contained in:
parent
2c1d7fbb83
commit
894467e5b4
2 changed files with 9 additions and 10 deletions
|
|
@ -294,10 +294,10 @@ fn fat_lto(cgcx: &CodegenContext,
|
|||
}])
|
||||
}
|
||||
|
||||
struct Linker(llvm::LinkerRef);
|
||||
struct Linker<'a>(&'a mut llvm::Linker<'a>);
|
||||
|
||||
impl Linker {
|
||||
fn new(llmod: &llvm::Module) -> Linker {
|
||||
impl Linker<'a> {
|
||||
fn new(llmod: &'a llvm::Module) -> Self {
|
||||
unsafe { Linker(llvm::LLVMRustLinkerNew(llmod)) }
|
||||
}
|
||||
|
||||
|
|
@ -314,9 +314,9 @@ impl Linker {
|
|||
}
|
||||
}
|
||||
|
||||
impl Drop for Linker {
|
||||
impl Drop for Linker<'a> {
|
||||
fn drop(&mut self) {
|
||||
unsafe { llvm::LLVMRustLinkerFree(self.0); }
|
||||
unsafe { llvm::LLVMRustLinkerFree(&mut *(self.0 as *mut _)); }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -414,8 +414,7 @@ extern { pub type SMDiagnostic; }
|
|||
extern { pub type RustArchiveMember; }
|
||||
pub type RustArchiveMemberRef = *mut RustArchiveMember;
|
||||
pub struct OperandBundleDef<'a>(InvariantOpaque<'a>);
|
||||
extern { pub type Linker; }
|
||||
pub type LinkerRef = *mut Linker;
|
||||
pub struct Linker<'a>(InvariantOpaque<'a>);
|
||||
|
||||
pub type DiagnosticHandler = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
|
||||
pub type InlineAsmDiagHandler = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
|
||||
|
|
@ -1580,9 +1579,9 @@ extern "C" {
|
|||
CU2: &mut *mut c_void);
|
||||
pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
|
||||
|
||||
pub fn LLVMRustLinkerNew(M: &Module) -> LinkerRef;
|
||||
pub fn LLVMRustLinkerAdd(linker: LinkerRef,
|
||||
pub fn LLVMRustLinkerNew(M: &'a Module) -> &'a mut Linker<'a>;
|
||||
pub fn LLVMRustLinkerAdd(linker: &Linker,
|
||||
bytecode: *const c_char,
|
||||
bytecode_len: usize) -> bool;
|
||||
pub fn LLVMRustLinkerFree(linker: LinkerRef);
|
||||
pub fn LLVMRustLinkerFree(linker: &'a mut Linker<'a>);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue