Skip to content

Commit 265f2fa

Browse files
committed
rustc_codegen_llvm: fix tidy errors.
1 parent ba00644 commit 265f2fa

File tree

10 files changed

+77
-24
lines changed

10 files changed

+77
-24
lines changed

src/librustc_codegen_llvm/back/write.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ fn get_llvm_opt_size(optimize: config::OptLevel) -> llvm::CodeGenOptSize {
128128
}
129129
}
130130

131-
pub fn create_target_machine(sess: &Session, find_features: bool) -> &'static mut llvm::TargetMachine {
131+
pub fn create_target_machine(
132+
sess: &Session,
133+
find_features: bool,
134+
) -> &'static mut llvm::TargetMachine {
132135
target_machine_factory(sess, find_features)().unwrap_or_else(|err| {
133136
llvm_err(sess.diagnostic(), err).raise()
134137
})

src/librustc_codegen_llvm/base.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,14 +395,22 @@ pub fn from_immediate(bx: &Builder<'_, 'll, '_>, val: &'ll Value) -> &'ll Value
395395
}
396396
}
397397

398-
pub fn to_immediate(bx: &Builder<'_, 'll, '_>, val: &'ll Value, layout: layout::TyLayout) -> &'ll Value {
398+
pub fn to_immediate(
399+
bx: &Builder<'_, 'll, '_>,
400+
val: &'ll Value,
401+
layout: layout::TyLayout,
402+
) -> &'ll Value {
399403
if let layout::Abi::Scalar(ref scalar) = layout.abi {
400404
return to_immediate_scalar(bx, val, scalar);
401405
}
402406
val
403407
}
404408

405-
pub fn to_immediate_scalar(bx: &Builder<'_, 'll, '_>, val: &'ll Value, scalar: &layout::Scalar) -> &'ll Value {
409+
pub fn to_immediate_scalar(
410+
bx: &Builder<'_, 'll, '_>,
411+
val: &'ll Value,
412+
scalar: &layout::Scalar,
413+
) -> &'ll Value {
406414
if scalar.is_bool() {
407415
return bx.trunc(val, Type::i1(bx.cx));
408416
}

src/librustc_codegen_llvm/builder.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,24 @@ impl Builder<'a, 'll, 'tcx> {
157157
}
158158
}
159159

160-
pub fn cond_br(&self, cond: &'ll Value, then_llbb: &'ll BasicBlock, else_llbb: &'ll BasicBlock) {
160+
pub fn cond_br(
161+
&self,
162+
cond: &'ll Value,
163+
then_llbb: &'ll BasicBlock,
164+
else_llbb: &'ll BasicBlock,
165+
) {
161166
self.count_insn("condbr");
162167
unsafe {
163168
llvm::LLVMBuildCondBr(self.llbuilder, cond, then_llbb, else_llbb);
164169
}
165170
}
166171

167-
pub fn switch(&self, v: &'ll Value, else_llbb: &'ll BasicBlock, num_cases: usize) -> &'ll Value {
172+
pub fn switch(
173+
&self,
174+
v: &'ll Value,
175+
else_llbb: &'ll BasicBlock,
176+
num_cases: usize,
177+
) -> &'ll Value {
168178
unsafe {
169179
llvm::LLVMBuildSwitch(self.llbuilder, v, else_llbb, num_cases as c_uint)
170180
}
@@ -814,8 +824,8 @@ impl Builder<'a, 'll, 'tcx> {
814824
// FIXME: add a non-fast math version once
815825
// https://bugs.llvm.org/show_bug.cgi?id=36732
816826
// is fixed.
817-
let instr = llvm::LLVMRustBuildVectorReduceFAdd(self.llbuilder, acc, src);
818-
let instr = instr.expect("LLVMRustBuildVectorReduceFAdd is not available in LLVM version < 5.0");
827+
let instr = llvm::LLVMRustBuildVectorReduceFAdd(self.llbuilder, acc, src)
828+
.expect("LLVMRustBuildVectorReduceFAdd is not available in LLVM version < 5.0");
819829
llvm::LLVMRustSetHasUnsafeAlgebra(instr);
820830
instr
821831
}
@@ -826,8 +836,8 @@ impl Builder<'a, 'll, 'tcx> {
826836
// FIXME: add a non-fast math version once
827837
// https://bugs.llvm.org/show_bug.cgi?id=36732
828838
// is fixed.
829-
let instr = llvm::LLVMRustBuildVectorReduceFMul(self.llbuilder, acc, src);
830-
let instr = instr.expect("LLVMRustBuildVectorReduceFMul is not available in LLVM version < 5.0");
839+
let instr = llvm::LLVMRustBuildVectorReduceFMul(self.llbuilder, acc, src)
840+
.expect("LLVMRustBuildVectorReduceFMul is not available in LLVM version < 5.0");
831841
llvm::LLVMRustSetHasUnsafeAlgebra(instr);
832842
instr
833843
}
@@ -884,17 +894,17 @@ impl Builder<'a, 'll, 'tcx> {
884894
pub fn vector_reduce_fmin_fast(&self, src: &'ll Value) -> &'ll Value {
885895
self.count_insn("vector.reduce.fmin_fast");
886896
unsafe {
887-
let instr = llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, /*NoNaNs:*/ true);
888-
let instr = instr.expect("LLVMRustBuildVectorReduceFMin is not available in LLVM version < 5.0");
897+
let instr = llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, /*NoNaNs:*/ true)
898+
.expect("LLVMRustBuildVectorReduceFMin is not available in LLVM version < 5.0");
889899
llvm::LLVMRustSetHasUnsafeAlgebra(instr);
890900
instr
891901
}
892902
}
893903
pub fn vector_reduce_fmax_fast(&self, src: &'ll Value) -> &'ll Value {
894904
self.count_insn("vector.reduce.fmax_fast");
895905
unsafe {
896-
let instr = llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, /*NoNaNs:*/ true);
897-
let instr = instr.expect("LLVMRustBuildVectorReduceFMax is not available in LLVM version < 5.0");
906+
let instr = llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, /*NoNaNs:*/ true)
907+
.expect("LLVMRustBuildVectorReduceFMax is not available in LLVM version < 5.0");
898908
llvm::LLVMRustSetHasUnsafeAlgebra(instr);
899909
instr
900910
}

src/librustc_codegen_llvm/common.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,11 @@ pub fn C_u8(cx: &CodegenCx<'ll, '_>, i: u8) -> &'ll Value {
183183

184184
// This is a 'c-like' raw string, which differs from
185185
// our boxed-and-length-annotated strings.
186-
pub fn C_cstr(cx: &CodegenCx<'ll, '_>, s: LocalInternedString, null_terminated: bool) -> &'ll Value {
186+
pub fn C_cstr(
187+
cx: &CodegenCx<'ll, '_>,
188+
s: LocalInternedString,
189+
null_terminated: bool,
190+
) -> &'ll Value {
187191
unsafe {
188192
if let Some(&llval) = cx.const_cstr_cache.borrow().get(&s) {
189193
return llval;
@@ -225,7 +229,11 @@ pub fn C_struct(cx: &CodegenCx<'ll, '_>, elts: &[&'ll Value], packed: bool) -> &
225229
C_struct_in_context(cx.llcx, elts, packed)
226230
}
227231

228-
pub fn C_struct_in_context(llcx: &'ll llvm::Context, elts: &[&'ll Value], packed: bool) -> &'ll Value {
232+
pub fn C_struct_in_context(
233+
llcx: &'ll llvm::Context,
234+
elts: &[&'ll Value],
235+
packed: bool,
236+
) -> &'ll Value {
229237
unsafe {
230238
llvm::LLVMConstStructInContext(llcx,
231239
elts.as_ptr(), elts.len() as c_uint,

src/librustc_codegen_llvm/context.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ pub fn is_pie_binary(sess: &Session) -> bool {
155155
!is_any_library(sess) && get_reloc_model(sess) == llvm::RelocMode::PIC
156156
}
157157

158-
pub unsafe fn create_module(sess: &Session, llcx: &'ll llvm::Context, mod_name: &str) -> &'ll llvm::Module {
158+
pub unsafe fn create_module(
159+
sess: &Session,
160+
llcx: &'ll llvm::Context,
161+
mod_name: &str,
162+
) -> &'ll llvm::Module {
159163
let mod_name = CString::new(mod_name).unwrap();
160164
let llmod = llvm::LLVMModuleCreateWithNameInContext(mod_name.as_ptr(), llcx);
161165

src/librustc_codegen_llvm/debuginfo/create_scope_map.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ impl MirDebugScope<'ll> {
4343

4444
/// Produce DIScope DIEs for each MIR Scope which has variables defined in it.
4545
/// If debuginfo is disabled, the returned vector is empty.
46-
pub fn create_mir_scopes(cx: &CodegenCx<'ll, '_>, mir: &Mir, debug_context: &FunctionDebugContext<'ll>)
47-
-> IndexVec<SourceScope, MirDebugScope<'ll>> {
46+
pub fn create_mir_scopes(
47+
cx: &CodegenCx<'ll, '_>,
48+
mir: &Mir,
49+
debug_context: &FunctionDebugContext<'ll>,
50+
) -> IndexVec<SourceScope, MirDebugScope<'ll>> {
4851
let null_scope = MirDebugScope {
4952
scope_metadata: None,
5053
file_start_pos: BytePos(0),

src/librustc_codegen_llvm/declare.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ pub fn declare_global(cx: &CodegenCx<'ll, '_>, name: &str, ty: &'ll Type) -> &'l
5555
///
5656
/// If there’s a value with the same name already declared, the function will
5757
/// update the declaration and return existing Value instead.
58-
fn declare_raw_fn(cx: &CodegenCx<'ll, '_>, name: &str, callconv: llvm::CallConv, ty: &'ll Type) -> &'ll Value {
58+
fn declare_raw_fn(
59+
cx: &CodegenCx<'ll, '_>,
60+
name: &str,
61+
callconv: llvm::CallConv,
62+
ty: &'ll Type,
63+
) -> &'ll Value {
5964
debug!("declare_raw_fn(name={:?}, ty={:?})", name, ty);
6065
let namebuf = CString::new(name).unwrap_or_else(|_|{
6166
bug!("name {:?} contains an interior null byte", name)

src/librustc_codegen_llvm/llvm/archive_ro.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ impl ArchiveRO {
3939
pub fn open(dst: &Path) -> Result<ArchiveRO, String> {
4040
return unsafe {
4141
let s = path2cstr(dst);
42-
let ar = super::LLVMRustOpenArchive(s.as_ptr())
43-
.ok_or_else(|| super::last_error().unwrap_or("failed to open archive".to_string()))?;
42+
let ar = super::LLVMRustOpenArchive(s.as_ptr()).ok_or_else(|| {
43+
super::last_error().unwrap_or("failed to open archive".to_string())
44+
})?;
4445
Ok(ArchiveRO { raw: ar })
4546
};
4647

src/librustc_codegen_llvm/llvm/ffi.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,11 @@ extern "C" {
740740
Args: *const &'a Value,
741741
Name: *const c_char)
742742
-> Option<&'a Value>;
743-
pub fn LLVMRustBuildCatchRet(B: &'a Builder, Pad: &'a Value, BB: &'a BasicBlock) -> Option<&'a Value>;
743+
pub fn LLVMRustBuildCatchRet(
744+
B: &'a Builder,
745+
Pad: &'a Value,
746+
BB: &'a BasicBlock,
747+
) -> Option<&'a Value>;
744748
pub fn LLVMRustBuildCatchSwitch(Builder: &'a Builder,
745749
ParentPad: Option<&'a Value>,
746750
BB: Option<&'a BasicBlock>,
@@ -1480,7 +1484,9 @@ extern "C" {
14801484

14811485
pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
14821486
pub fn LLVMRustArchiveIteratorNew(AR: &'a Archive) -> &'a mut ArchiveIterator<'a>;
1483-
pub fn LLVMRustArchiveIteratorNext(AIR: &ArchiveIterator<'a>) -> Option<&'a mut ArchiveChild<'a>>;
1487+
pub fn LLVMRustArchiveIteratorNext(
1488+
AIR: &ArchiveIterator<'a>,
1489+
) -> Option<&'a mut ArchiveChild<'a>>;
14841490
pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild, size: &mut size_t) -> *const c_char;
14851491
pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild, size: &mut size_t) -> *const c_char;
14861492
pub fn LLVMRustArchiveChildFree(ACR: &'a mut ArchiveChild<'a>);

src/librustc_codegen_llvm/mir/operand.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,12 @@ impl OperandValue<'ll> {
266266
self.store_with_flags(bx, dest, MemFlags::NONTEMPORAL);
267267
}
268268

269-
fn store_with_flags(self, bx: &Builder<'a, 'll, 'tcx>, dest: PlaceRef<'ll, 'tcx>, flags: MemFlags) {
269+
fn store_with_flags(
270+
self,
271+
bx: &Builder<'a, 'll, 'tcx>,
272+
dest: PlaceRef<'ll, 'tcx>,
273+
flags: MemFlags,
274+
) {
270275
debug!("OperandRef::store: operand={:?}, dest={:?}", self, dest);
271276
// Avoid generating stores of zero-sized values, because the only way to have a zero-sized
272277
// value is through `undef`, and store itself is useless.

0 commit comments

Comments
 (0)