codegen_llvm/misc: whitespace & formatting improvements
This commit is contained in:
parent
b1a137d015
commit
8efd9dd81b
5 changed files with 46 additions and 45 deletions
|
@ -582,12 +582,12 @@ pub fn type_metadata(
|
|||
}
|
||||
ty::Dynamic(..) => {
|
||||
MetadataCreationResult::new(
|
||||
trait_pointer_metadata(cx, t, None, unique_type_id),
|
||||
false)
|
||||
trait_pointer_metadata(cx, t, None, unique_type_id),
|
||||
false)
|
||||
}
|
||||
ty::Foreign(..) => {
|
||||
MetadataCreationResult::new(
|
||||
foreign_type_metadata(cx, t, unique_type_id),
|
||||
foreign_type_metadata(cx, t, unique_type_id),
|
||||
false)
|
||||
}
|
||||
ty::RawPtr(ty::TypeAndMut{ty, ..}) |
|
||||
|
@ -646,16 +646,16 @@ pub fn type_metadata(
|
|||
}
|
||||
AdtKind::Union => {
|
||||
prepare_union_metadata(cx,
|
||||
t,
|
||||
unique_type_id,
|
||||
usage_site_span).finalize(cx)
|
||||
t,
|
||||
unique_type_id,
|
||||
usage_site_span).finalize(cx)
|
||||
}
|
||||
AdtKind::Enum => {
|
||||
prepare_enum_metadata(cx,
|
||||
t,
|
||||
def.did,
|
||||
unique_type_id,
|
||||
usage_site_span).finalize(cx)
|
||||
t,
|
||||
def.did,
|
||||
unique_type_id,
|
||||
usage_site_span).finalize(cx)
|
||||
}
|
||||
},
|
||||
ty::Tuple(ref elements) => {
|
||||
|
@ -943,7 +943,7 @@ enum MemberDescriptionFactory<'ll, 'tcx> {
|
|||
|
||||
impl MemberDescriptionFactory<'ll, 'tcx> {
|
||||
fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>)
|
||||
-> Vec<MemberDescription<'ll>> {
|
||||
-> Vec<MemberDescription<'ll>> {
|
||||
match *self {
|
||||
StructMDF(ref this) => {
|
||||
this.create_member_descriptions(cx)
|
||||
|
@ -977,7 +977,7 @@ struct StructMemberDescriptionFactory<'tcx> {
|
|||
|
||||
impl<'tcx> StructMemberDescriptionFactory<'tcx> {
|
||||
fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>)
|
||||
-> Vec<MemberDescription<'ll>> {
|
||||
-> Vec<MemberDescription<'ll>> {
|
||||
let layout = cx.layout_of(self.ty);
|
||||
self.variant.fields.iter().enumerate().map(|(i, f)| {
|
||||
let name = if self.variant.ctor_kind == CtorKind::Fn {
|
||||
|
@ -1047,7 +1047,7 @@ struct TupleMemberDescriptionFactory<'tcx> {
|
|||
|
||||
impl<'tcx> TupleMemberDescriptionFactory<'tcx> {
|
||||
fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>)
|
||||
-> Vec<MemberDescription<'ll>> {
|
||||
-> Vec<MemberDescription<'ll>> {
|
||||
let layout = cx.layout_of(self.ty);
|
||||
self.component_types.iter().enumerate().map(|(i, &component_type)| {
|
||||
let (size, align) = cx.size_and_align_of(component_type);
|
||||
|
@ -1101,7 +1101,7 @@ struct UnionMemberDescriptionFactory<'tcx> {
|
|||
|
||||
impl<'tcx> UnionMemberDescriptionFactory<'tcx> {
|
||||
fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>)
|
||||
-> Vec<MemberDescription<'ll>> {
|
||||
-> Vec<MemberDescription<'ll>> {
|
||||
self.variant.fields.iter().enumerate().map(|(i, f)| {
|
||||
let field = self.layout.field(cx, i);
|
||||
let (size, align) = field.size_and_align();
|
||||
|
@ -1170,7 +1170,7 @@ struct EnumMemberDescriptionFactory<'ll, 'tcx> {
|
|||
|
||||
impl EnumMemberDescriptionFactory<'ll, 'tcx> {
|
||||
fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>)
|
||||
-> Vec<MemberDescription<'ll>> {
|
||||
-> Vec<MemberDescription<'ll>> {
|
||||
let adt = &self.enum_type.ty_adt_def().unwrap();
|
||||
match self.layout.variants {
|
||||
layout::Variants::Single { .. } if adt.variants.is_empty() => vec![],
|
||||
|
|
|
@ -179,7 +179,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
|||
ty::GeneratorWitness(..) |
|
||||
ty::Param(_) => {
|
||||
bug!("debuginfo: Trying to create type name for \
|
||||
unexpected type: {:?}", t);
|
||||
unexpected type: {:?}", t);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -151,9 +151,9 @@ impl Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'll, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_place(&mut self,
|
||||
place: &mir::Place<'tcx>,
|
||||
context: PlaceContext<'tcx>,
|
||||
location: Location) {
|
||||
place: &mir::Place<'tcx>,
|
||||
context: PlaceContext<'tcx>,
|
||||
location: Location) {
|
||||
debug!("visit_place(place={:?}, context={:?})", place, context);
|
||||
let cx = self.fx.cx;
|
||||
|
||||
|
|
|
@ -49,9 +49,9 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
}
|
||||
|
||||
fn codegen_terminator(&mut self,
|
||||
mut bx: Builder<'a, 'll, 'tcx>,
|
||||
bb: mir::BasicBlock,
|
||||
terminator: &mir::Terminator<'tcx>)
|
||||
mut bx: Builder<'a, 'll, 'tcx>,
|
||||
bb: mir::BasicBlock,
|
||||
terminator: &mir::Terminator<'tcx>)
|
||||
{
|
||||
debug!("codegen_terminator: {:?}", terminator);
|
||||
|
||||
|
@ -125,10 +125,10 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
this.unreachable_block()
|
||||
};
|
||||
let invokeret = bx.invoke(fn_ptr,
|
||||
&llargs,
|
||||
ret_bx,
|
||||
llblock(this, cleanup),
|
||||
cleanup_bundle);
|
||||
&llargs,
|
||||
ret_bx,
|
||||
llblock(this, cleanup),
|
||||
cleanup_bundle);
|
||||
fn_ty.apply_attrs_callsite(&bx, invokeret);
|
||||
|
||||
if let Some((ret_dest, target)) = destination {
|
||||
|
@ -213,7 +213,8 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
} else {
|
||||
let (otherwise, targets) = targets.split_last().unwrap();
|
||||
let switch = bx.switch(discr.immediate(),
|
||||
llblock(self, *otherwise), values.len());
|
||||
llblock(self, *otherwise),
|
||||
values.len());
|
||||
let switch_llty = bx.cx.layout_of(switch_ty).immediate_llvm_type(bx.cx);
|
||||
for (&value, target) in values.iter().zip(targets) {
|
||||
let llval = C_uint_big(switch_llty, value);
|
||||
|
@ -387,8 +388,8 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
let msg_str = Symbol::intern(str).as_str();
|
||||
let msg_str = C_str_slice(bx.cx, msg_str);
|
||||
let msg_file_line_col = C_struct(bx.cx,
|
||||
&[msg_str, filename, line, col],
|
||||
false);
|
||||
&[msg_str, filename, line, col],
|
||||
false);
|
||||
let msg_file_line_col = consts::addr_of(bx.cx,
|
||||
msg_file_line_col,
|
||||
align,
|
||||
|
@ -509,8 +510,8 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
let msg_str = Symbol::intern(&str).as_str();
|
||||
let msg_str = C_str_slice(bx.cx, msg_str);
|
||||
let msg_file_line_col = C_struct(bx.cx,
|
||||
&[msg_str, filename, line, col],
|
||||
false);
|
||||
&[msg_str, filename, line, col],
|
||||
false);
|
||||
let msg_file_line_col = consts::addr_of(bx.cx,
|
||||
msg_file_line_col,
|
||||
align,
|
||||
|
@ -619,7 +620,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
|
||||
let callee_ty = instance.as_ref().unwrap().ty(bx.cx.tcx);
|
||||
codegen_intrinsic_call(&bx, callee_ty, &fn_ty, &args, dest,
|
||||
terminator.source_info.span);
|
||||
terminator.source_info.span);
|
||||
|
||||
if let ReturnDest::IndirectOperand(dst, _) = ret_dest {
|
||||
self.store_return(&bx, ret_dest, &fn_ty.ret, dst.llval);
|
||||
|
@ -756,7 +757,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
// Have to load the argument, maybe while casting it.
|
||||
if let PassMode::Cast(ty) = arg.mode {
|
||||
llval = bx.load(bx.pointercast(llval, ty.llvm_type(bx.cx).ptr_to()),
|
||||
align.min(arg.layout.align));
|
||||
align.min(arg.layout.align));
|
||||
} else {
|
||||
// We can't use `PlaceRef::load` here because the argument
|
||||
// may have a type we don't treat as immediate, but the ABI
|
||||
|
@ -778,10 +779,10 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
}
|
||||
|
||||
fn codegen_arguments_untupled(&mut self,
|
||||
bx: &Builder<'a, 'll, 'tcx>,
|
||||
operand: &mir::Operand<'tcx>,
|
||||
llargs: &mut Vec<&'ll Value>,
|
||||
args: &[ArgType<'tcx, Ty<'tcx>>]) {
|
||||
bx: &Builder<'a, 'll, 'tcx>,
|
||||
operand: &mir::Operand<'tcx>,
|
||||
llargs: &mut Vec<&'ll Value>,
|
||||
args: &[ArgType<'tcx, Ty<'tcx>>]) {
|
||||
let tuple = self.codegen_operand(bx, operand);
|
||||
|
||||
// Handle both by-ref and immediate tuples.
|
||||
|
@ -933,8 +934,8 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
}
|
||||
|
||||
fn codegen_transmute(&mut self, bx: &Builder<'a, 'll, 'tcx>,
|
||||
src: &mir::Operand<'tcx>,
|
||||
dst: &mir::Place<'tcx>) {
|
||||
src: &mir::Operand<'tcx>,
|
||||
dst: &mir::Place<'tcx>) {
|
||||
if let mir::Place::Local(index) = *dst {
|
||||
match self.locals[index] {
|
||||
LocalRef::Place(place) => self.codegen_transmute_into(bx, src, place),
|
||||
|
@ -961,8 +962,8 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
}
|
||||
|
||||
fn codegen_transmute_into(&mut self, bx: &Builder<'a, 'll, 'tcx>,
|
||||
src: &mir::Operand<'tcx>,
|
||||
dst: PlaceRef<'ll, 'tcx>) {
|
||||
src: &mir::Operand<'tcx>,
|
||||
dst: PlaceRef<'ll, 'tcx>) {
|
||||
let src = self.codegen_operand(bx, src);
|
||||
let llty = src.layout.llvm_type(bx.cx);
|
||||
let cast_ptr = bx.pointercast(dst.llval, llty.ptr_to());
|
||||
|
|
|
@ -162,16 +162,16 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
// corresponding to span's containing source scope. If so, we need to create a DIScope
|
||||
// "extension" into that file.
|
||||
fn scope_metadata_for_loc(&self, scope_id: mir::SourceScope, pos: BytePos)
|
||||
-> Option<&'ll DIScope> {
|
||||
-> Option<&'ll DIScope> {
|
||||
let scope_metadata = self.scopes[scope_id].scope_metadata;
|
||||
if pos < self.scopes[scope_id].file_start_pos ||
|
||||
pos >= self.scopes[scope_id].file_end_pos {
|
||||
let cm = self.cx.sess().source_map();
|
||||
let defining_crate = self.debug_context.get_ref(DUMMY_SP).defining_crate;
|
||||
Some(debuginfo::extend_scope_to_file(self.cx,
|
||||
scope_metadata.unwrap(),
|
||||
&cm.lookup_char_pos(pos).file,
|
||||
defining_crate))
|
||||
scope_metadata.unwrap(),
|
||||
&cm.lookup_char_pos(pos).file,
|
||||
defining_crate))
|
||||
} else {
|
||||
scope_metadata
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue