Skip to content

Commit 418b23a

Browse files
committed
Various bits of trans lint, nothing major.
1 parent 2746d20 commit 418b23a

File tree

1 file changed

+36
-25
lines changed

1 file changed

+36
-25
lines changed

src/comp/middle/trans.rs

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ fn dynamic_size_of(@block_ctxt cx, ty.t t) -> result {
12281228
auto elt_size = size_of(bcx, e);
12291229
bcx = elt_size.bcx;
12301230
auto aligned_off = align_to(bcx, off, elt_align.val);
1231-
off = cx.build.Add(aligned_off, elt_size.val);
1231+
off = bcx.build.Add(aligned_off, elt_size.val);
12321232
max_align = umax(bcx, max_align, elt_align.val);
12331233
}
12341234
off = align_to(bcx, off, max_align);
@@ -1488,7 +1488,7 @@ fn trans_raw_malloc(@block_ctxt cx, TypeRef llptr_ty, ValueRef llsize)
14881488
// FIXME: need a table to collect tydesc globals.
14891489
auto tydesc = C_int(0);
14901490
auto rslt = trans_upcall(cx, "upcall_malloc", vec(llsize, tydesc));
1491-
rslt = res(rslt.bcx, vi2p(cx, rslt.val, llptr_ty));
1491+
rslt = res(rslt.bcx, vi2p(rslt.bcx, rslt.val, llptr_ty));
14921492
ret rslt;
14931493
}
14941494

@@ -1949,6 +1949,8 @@ fn make_drop_glue(@block_ctxt cx, ValueRef v0, ty.t t) {
19491949
ty.type_is_native(cx.fcx.lcx.ccx.tcx, t) ||
19501950
ty.type_is_nil(cx.fcx.lcx.ccx.tcx, t)) {
19511951
rslt = res(cx, C_nil());
1952+
} else {
1953+
rslt = res(cx, C_nil());
19521954
}
19531955
}
19541956
}
@@ -2356,7 +2358,7 @@ fn iter_structural_ty_full(@block_ctxt cx,
23562358

23572359
auto r = f(inner_cx, box_a_ptr, box_b_ptr, tbox);
23582360
r.bcx.build.Br(next_cx.llbb);
2359-
ret res(next_cx, r.val);
2361+
ret res(next_cx, C_nil());
23602362
}
23612363

23622364
alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
@@ -2626,7 +2628,7 @@ fn iter_sequence(@block_ctxt cx,
26262628
auto p1 = vi2p(bcx, bcx.build.Add(vp2i(bcx, p0), len),
26272629
T_ptr(llunit_ty));
26282630

2629-
ret iter_sequence_inner(cx, p0, p1, elt_ty, f);
2631+
ret iter_sequence_inner(bcx, p0, p1, elt_ty, f);
26302632
}
26312633

26322634
alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
@@ -2660,11 +2662,13 @@ fn call_tydesc_glue_full(@block_ctxt cx, ValueRef v,
26602662
llrawptr));
26612663
}
26622664

2663-
fn call_tydesc_glue(@block_ctxt cx, ValueRef v, ty.t t, int field) {
2665+
fn call_tydesc_glue(@block_ctxt cx, ValueRef v,
2666+
ty.t t, int field) -> result {
26642667
auto td = get_tydesc(cx, t);
26652668
call_tydesc_glue_full(td.bcx,
26662669
spill_if_immediate(td.bcx, v, t),
26672670
td.val, field);
2671+
ret res(td.bcx, C_nil());
26682672
}
26692673

26702674
fn call_cmp_glue(@block_ctxt cx, ValueRef lhs, ValueRef rhs, ty.t t,
@@ -2705,7 +2709,7 @@ fn call_cmp_glue(@block_ctxt cx, ValueRef lhs, ValueRef rhs, ty.t t,
27052709

27062710
fn take_ty(@block_ctxt cx, ValueRef v, ty.t t) -> result {
27072711
if (!ty.type_is_scalar(cx.fcx.lcx.ccx.tcx, t)) {
2708-
call_tydesc_glue(cx, v, t, abi.tydesc_field_take_glue);
2712+
ret call_tydesc_glue(cx, v, t, abi.tydesc_field_take_glue);
27092713
}
27102714
ret res(cx, C_nil());
27112715
}
@@ -2727,7 +2731,7 @@ fn drop_ty(@block_ctxt cx,
27272731
ty.t t) -> result {
27282732

27292733
if (!ty.type_is_scalar(cx.fcx.lcx.ccx.tcx, t)) {
2730-
call_tydesc_glue(cx, v, t, abi.tydesc_field_drop_glue);
2734+
ret call_tydesc_glue(cx, v, t, abi.tydesc_field_drop_glue);
27312735
}
27322736
ret res(cx, C_nil());
27332737
}
@@ -3529,7 +3533,7 @@ fn trans_for_each(@block_ctxt cx,
35293533
auto lltydescsptr = cx.build.GEP(llenvptr,
35303534
vec(C_int(0),
35313535
C_int(abi.box_rc_field_body),
3532-
C_int(3)));
3536+
C_int(abi.closure_elt_ty_params)));
35333537
auto i = 0u;
35343538
while (i < tydesc_count) {
35353539
auto lltydescptr = cx.build.GEP(lltydescsptr,
@@ -3563,8 +3567,10 @@ fn trans_for_each(@block_ctxt cx,
35633567

35643568
// Populate the upvars from the environment.
35653569
auto llremoteenvptr = bcx.build.PointerCast(fcx.llenv, llenvptrty);
3566-
auto llremotebindingsptrptr = bcx.build.GEP(llremoteenvptr,
3567-
vec(C_int(0), C_int(abi.box_rc_field_body), C_int(2)));
3570+
auto llremotebindingsptrptr =
3571+
bcx.build.GEP(llremoteenvptr, vec(C_int(0),
3572+
C_int(abi.box_rc_field_body),
3573+
C_int(abi.closure_elt_bindings)));
35683574
auto llremotebindingsptr = bcx.build.Load(llremotebindingsptrptr);
35693575

35703576
i = 0u;
@@ -3579,10 +3585,11 @@ fn trans_for_each(@block_ctxt cx,
35793585
}
35803586

35813587
// Populate the type parameters from the environment.
3582-
auto llremotetydescsptr = bcx.build.GEP(llremoteenvptr,
3583-
vec(C_int(0),
3584-
C_int(abi.box_rc_field_body),
3585-
C_int(3)));
3588+
auto llremotetydescsptr =
3589+
bcx.build.GEP(llremoteenvptr,
3590+
vec(C_int(0),
3591+
C_int(abi.box_rc_field_body),
3592+
C_int(abi.closure_elt_ty_params)));
35863593

35873594
i = 0u;
35883595
while (i < tydesc_count) {
@@ -3903,7 +3910,7 @@ fn lval_generic_fn(@block_ctxt cx,
39033910
}
39043911

39053912
if (_vec.len[ty.t](tys) != 0u) {
3906-
auto bcx = cx;
3913+
auto bcx = lv.res.bcx;
39073914
let vec[ValueRef] tydescs = vec();
39083915
for (ty.t t in tys) {
39093916
auto td = get_tydesc(bcx, t);
@@ -4497,7 +4504,7 @@ fn trans_bind(@block_ctxt cx, @ast.expr f,
44974504
for (ValueRef v in bound_vals) {
44984505
auto bound = bcx.build.GEP(bindings,
44994506
vec(C_int(0), C_int(i as int)));
4500-
bcx = copy_ty(r.bcx, INIT, bound, v, bound_tys.(i)).bcx;
4507+
bcx = copy_ty(bcx, INIT, bound, v, bound_tys.(i)).bcx;
45014508
i += 1u;
45024509
}
45034510

@@ -5324,7 +5331,7 @@ fn trans_break_cont(@block_ctxt cx, bool to_end) -> result {
53245331
}
53255332
}
53265333
}
5327-
ret res(new_sub_block_ctxt(cx, "unreachable"), C_nil());
5334+
ret res(bcx, C_nil());
53285335
}
53295336
case (_) {
53305337
alt (cleanup_cx.parent) {
@@ -5333,7 +5340,7 @@ fn trans_break_cont(@block_ctxt cx, bool to_end) -> result {
53335340
}
53345341
}
53355342
}
5336-
ret res(cx, C_nil()); // Never reached. Won't compile otherwise.
5343+
fail;
53375344
}
53385345

53395346
fn trans_break(@block_ctxt cx) -> result {
@@ -5357,7 +5364,11 @@ fn trans_ret(@block_ctxt cx, &option.t[@ast.expr] e) -> result {
53575364
val = r.val;
53585365
bcx = copy_ty(bcx, INIT, cx.fcx.llretptr, val, t).bcx;
53595366
}
5360-
case (_) { /* fall through */ }
5367+
case (_) {
5368+
auto t = llvm.LLVMGetElementType(val_ty(cx.fcx.llretptr));
5369+
auto null = lib.llvm.llvm.LLVMConstNull(t);
5370+
bcx.build.Store(null, cx.fcx.llretptr);
5371+
}
53615372
}
53625373

53635374
// Run all cleanups and back out.
@@ -6052,7 +6063,7 @@ fn trans_fn(@local_ctxt cx, &ast._fn f, ast.def_id fid,
60526063
new_builder(fcx.llallocas).Br(lltop);
60536064
}
60546065

6055-
fn trans_vtbl(@local_ctxt cx,
6066+
fn trans_vtbl(@local_ctxt cx,
60566067
TypeRef llself_ty,
60576068
ty.t self_ty,
60586069
&ast._obj ob,
@@ -6085,7 +6096,7 @@ fn trans_vtbl(@local_ctxt cx,
60856096
cx.ccx.item_ids.insert(m.node.id, llfn);
60866097
cx.ccx.item_symbols.insert(m.node.id, s);
60876098

6088-
trans_fn(mcx, m.node.meth, m.node.id,
6099+
trans_fn(mcx, m.node.meth, m.node.id,
60896100
some[tup(TypeRef, ty.t)](tup(llself_ty, self_ty)),
60906101
ty_params, m.node.ann);
60916102
methods += vec(llfn);
@@ -6146,7 +6157,7 @@ fn trans_obj(@local_ctxt cx, &ast._obj ob, ast.def_id oid,
61466157

61476158
auto fcx = new_fn_ctxt(cx, llctor_decl);
61486159
create_llargs_for_fn_args(fcx, ast.proto_fn,
6149-
none[tup(TypeRef, ty.t)],
6160+
none[tup(TypeRef, ty.t)],
61506161
ret_ty_of_fn(cx.ccx, ann),
61516162
fn_args, ty_params);
61526163

@@ -6289,7 +6300,7 @@ fn trans_tag_variant(@local_ctxt cx, ast.def_id tag_id,
62896300
auto fcx = new_fn_ctxt(cx, llfndecl);
62906301

62916302
create_llargs_for_fn_args(fcx, ast.proto_fn,
6292-
none[tup(TypeRef, ty.t)],
6303+
none[tup(TypeRef, ty.t)],
62936304
ret_ty_of_fn(cx.ccx, variant.node.ann),
62946305
fn_args, ty_params);
62956306

@@ -6718,7 +6729,7 @@ fn collect_item_2(@crate_ctxt ccx, @walk_ctxt wcx, @ast.item i) {
67186729
fn collect_items(@crate_ctxt ccx, @ast.crate crate) {
67196730
auto wcx = new_walk_ctxt();
67206731
auto visitor0 = walk.default_visitor();
6721-
auto visitor1 = rec(visit_native_item_pre =
6732+
auto visitor1 = rec(visit_native_item_pre =
67226733
bind collect_native_item(ccx, wcx, _),
67236734
visit_item_pre = bind collect_item_1(ccx, wcx, _),
67246735
visit_item_post = bind leave_item(wcx, _)
@@ -6760,7 +6771,7 @@ fn collect_tag_ctors(@crate_ctxt ccx, @ast.crate crate) {
67606771

67616772
fn trans_constant(@crate_ctxt ccx, @walk_ctxt wcx, @ast.item it) {
67626773
enter_item(wcx, it);
6763-
6774+
67646775
alt (it.node) {
67656776
case (ast.item_tag(?ident, ?variants, _, ?tag_id, _)) {
67666777
auto i = 0u;

0 commit comments

Comments
 (0)