Skip to content

Commit 92af969

Browse files
committed
rustc_codegen_llvm: use safe mutable references for output parameters.
1 parent c1eeb69 commit 92af969

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/librustc_codegen_llvm/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ pub fn const_get_real(v: &'ll Value) -> Option<(f64, bool)> {
273273
unsafe {
274274
if is_const_real(v) {
275275
let mut loses_info: llvm::Bool = ::std::mem::uninitialized();
276-
let r = llvm::LLVMConstRealGetDouble(v, &mut loses_info as *mut llvm::Bool);
276+
let r = llvm::LLVMConstRealGetDouble(v, &mut loses_info);
277277
let loses_info = if loses_info == 1 { true } else { false };
278278
Some((r, loses_info))
279279
} else {
@@ -311,7 +311,7 @@ pub fn const_to_opt_u128(v: &'ll Value, sign_ext: bool) -> Option<u128> {
311311
if is_const_integral(v) {
312312
let (mut lo, mut hi) = (0u64, 0u64);
313313
let success = llvm::LLVMRustConstInt128Get(v, sign_ext,
314-
&mut hi as *mut u64, &mut lo as *mut u64);
314+
&mut hi, &mut lo);
315315
if success {
316316
Some(hi_lo_to_u128(lo, hi))
317317
} else {

src/librustc_codegen_llvm/llvm/ffi.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,8 @@ extern "C" {
559559
pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
560560
pub fn LLVMConstIntGetZExtValue(ConstantVal: &Value) -> c_ulonglong;
561561
pub fn LLVMRustConstInt128Get(ConstantVal: &Value, SExt: bool,
562-
high: *mut u64, low: *mut u64) -> bool;
563-
pub fn LLVMConstRealGetDouble (ConstantVal: &Value, losesInfo: *mut Bool) -> f64;
562+
high: &mut u64, low: &mut u64) -> bool;
563+
pub fn LLVMConstRealGetDouble (ConstantVal: &Value, losesInfo: &mut Bool) -> f64;
564564

565565

566566
// Operations on composite constants
@@ -1470,13 +1470,13 @@ extern "C" {
14701470
pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
14711471
pub fn LLVMRustArchiveIteratorNew(AR: &Archive) -> ArchiveIteratorRef;
14721472
pub fn LLVMRustArchiveIteratorNext(AIR: ArchiveIteratorRef) -> ArchiveChildRef;
1473-
pub fn LLVMRustArchiveChildName(ACR: ArchiveChildRef, size: *mut size_t) -> *const c_char;
1474-
pub fn LLVMRustArchiveChildData(ACR: ArchiveChildRef, size: *mut size_t) -> *const c_char;
1473+
pub fn LLVMRustArchiveChildName(ACR: ArchiveChildRef, size: &mut size_t) -> *const c_char;
1474+
pub fn LLVMRustArchiveChildData(ACR: ArchiveChildRef, size: &mut size_t) -> *const c_char;
14751475
pub fn LLVMRustArchiveChildFree(ACR: ArchiveChildRef);
14761476
pub fn LLVMRustArchiveIteratorFree(AIR: ArchiveIteratorRef);
14771477
pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
14781478

1479-
pub fn LLVMRustGetSectionName(SI: SectionIteratorRef, data: *mut *const c_char) -> size_t;
1479+
pub fn LLVMRustGetSectionName(SI: SectionIteratorRef, data: &mut *const c_char) -> size_t;
14801480

14811481
pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
14821482

@@ -1492,9 +1492,9 @@ extern "C" {
14921492
loc_filename_out: &RustString,
14931493
message_out: &RustString);
14941494
pub fn LLVMRustUnpackInlineAsmDiagnostic(DI: &'a DiagnosticInfo,
1495-
cookie_out: *mut c_uint,
1496-
message_out: *mut Option<&'a Twine>,
1497-
instruction_out: *mut Option<&'a Value>);
1495+
cookie_out: &mut c_uint,
1496+
message_out: &mut Option<&'a Twine>,
1497+
instruction_out: &mut Option<&'a Value>);
14981498

14991499
pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
15001500
pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
@@ -1572,8 +1572,8 @@ extern "C" {
15721572
Identifier: *const c_char,
15731573
) -> Option<&Module>;
15741574
pub fn LLVMRustThinLTOGetDICompileUnit(M: &Module,
1575-
CU1: *mut *mut c_void,
1576-
CU2: *mut *mut c_void);
1575+
CU1: &mut *mut c_void,
1576+
CU2: &mut *mut c_void);
15771577
pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);
15781578

15791579
pub fn LLVMRustLinkerNew(M: &Module) -> LinkerRef;

0 commit comments

Comments
 (0)