Skip to content

Commit

Permalink
rustc_codegen_llvm: use safe mutable references for output parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
irinagpopa committed Jul 30, 2018
1 parent c1eeb69 commit 92af969
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/common.rs
Expand Up @@ -273,7 +273,7 @@ pub fn const_get_real(v: &'ll Value) -> Option<(f64, bool)> {
unsafe {
if is_const_real(v) {
let mut loses_info: llvm::Bool = ::std::mem::uninitialized();
let r = llvm::LLVMConstRealGetDouble(v, &mut loses_info as *mut llvm::Bool);
let r = llvm::LLVMConstRealGetDouble(v, &mut loses_info);
let loses_info = if loses_info == 1 { true } else { false };
Some((r, loses_info))
} else {
Expand Down Expand Up @@ -311,7 +311,7 @@ pub fn const_to_opt_u128(v: &'ll Value, sign_ext: bool) -> Option<u128> {
if is_const_integral(v) {
let (mut lo, mut hi) = (0u64, 0u64);
let success = llvm::LLVMRustConstInt128Get(v, sign_ext,
&mut hi as *mut u64, &mut lo as *mut u64);
&mut hi, &mut lo);
if success {
Some(hi_lo_to_u128(lo, hi))
} else {
Expand Down
20 changes: 10 additions & 10 deletions src/librustc_codegen_llvm/llvm/ffi.rs
Expand Up @@ -559,8 +559,8 @@ extern "C" {
pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
pub fn LLVMConstIntGetZExtValue(ConstantVal: &Value) -> c_ulonglong;
pub fn LLVMRustConstInt128Get(ConstantVal: &Value, SExt: bool,
high: *mut u64, low: *mut u64) -> bool;
pub fn LLVMConstRealGetDouble (ConstantVal: &Value, losesInfo: *mut Bool) -> f64;
high: &mut u64, low: &mut u64) -> bool;
pub fn LLVMConstRealGetDouble (ConstantVal: &Value, losesInfo: &mut Bool) -> f64;


// Operations on composite constants
Expand Down Expand Up @@ -1470,13 +1470,13 @@ extern "C" {
pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
pub fn LLVMRustArchiveIteratorNew(AR: &Archive) -> ArchiveIteratorRef;
pub fn LLVMRustArchiveIteratorNext(AIR: ArchiveIteratorRef) -> ArchiveChildRef;
pub fn LLVMRustArchiveChildName(ACR: ArchiveChildRef, size: *mut size_t) -> *const c_char;
pub fn LLVMRustArchiveChildData(ACR: ArchiveChildRef, size: *mut size_t) -> *const c_char;
pub fn LLVMRustArchiveChildName(ACR: ArchiveChildRef, size: &mut size_t) -> *const c_char;
pub fn LLVMRustArchiveChildData(ACR: ArchiveChildRef, size: &mut size_t) -> *const c_char;
pub fn LLVMRustArchiveChildFree(ACR: ArchiveChildRef);
pub fn LLVMRustArchiveIteratorFree(AIR: ArchiveIteratorRef);
pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);

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

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

Expand All @@ -1492,9 +1492,9 @@ extern "C" {
loc_filename_out: &RustString,
message_out: &RustString);
pub fn LLVMRustUnpackInlineAsmDiagnostic(DI: &'a DiagnosticInfo,
cookie_out: *mut c_uint,
message_out: *mut Option<&'a Twine>,
instruction_out: *mut Option<&'a Value>);
cookie_out: &mut c_uint,
message_out: &mut Option<&'a Twine>,
instruction_out: &mut Option<&'a Value>);

pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
Expand Down Expand Up @@ -1572,8 +1572,8 @@ extern "C" {
Identifier: *const c_char,
) -> Option<&Module>;
pub fn LLVMRustThinLTOGetDICompileUnit(M: &Module,
CU1: *mut *mut c_void,
CU2: *mut *mut c_void);
CU1: &mut *mut c_void,
CU2: &mut *mut c_void);
pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void);

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

0 comments on commit 92af969

Please sign in to comment.