rustc: Run scope cleanups in the implicit block created by log statements. Fixes a leak.
This commit is contained in:
parent
64a5afadf3
commit
b101e26d92
1 changed files with 18 additions and 14 deletions
|
@ -5294,6 +5294,7 @@ fn trans_log(int lvl, @block_ctxt cx, @ast.expr e) -> result {
|
||||||
auto sub = trans_expr(log_cx, e);
|
auto sub = trans_expr(log_cx, e);
|
||||||
auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e);
|
auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e);
|
||||||
|
|
||||||
|
auto log_bcx = sub.bcx;
|
||||||
if (ty.type_is_fp(cx.fcx.lcx.ccx.tcx, e_ty)) {
|
if (ty.type_is_fp(cx.fcx.lcx.ccx.tcx, e_ty)) {
|
||||||
let TypeRef tr;
|
let TypeRef tr;
|
||||||
let bool is32bit = false;
|
let bool is32bit = false;
|
||||||
|
@ -5310,38 +5311,41 @@ fn trans_log(int lvl, @block_ctxt cx, @ast.expr e) -> result {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is32bit) {
|
if (is32bit) {
|
||||||
auto uval = trans_upcall(sub.bcx,
|
auto uval = trans_upcall(log_bcx,
|
||||||
"upcall_log_float",
|
"upcall_log_float",
|
||||||
vec(C_int(lvl), sub.val),
|
vec(C_int(lvl), sub.val),
|
||||||
false);
|
false);
|
||||||
uval.bcx.build.Br(after_cx.llbb);
|
log_bcx = uval.bcx;
|
||||||
} else {
|
} else {
|
||||||
auto tmp = alloca(sub.bcx, tr);
|
auto tmp = alloca(log_bcx, tr);
|
||||||
sub.bcx.build.Store(sub.val, tmp);
|
sub.bcx.build.Store(sub.val, tmp);
|
||||||
auto uval = trans_upcall(sub.bcx,
|
auto uval = trans_upcall(log_bcx,
|
||||||
"upcall_log_double",
|
"upcall_log_double",
|
||||||
vec(C_int(lvl), vp2i(sub.bcx, tmp)),
|
vec(C_int(lvl), vp2i(log_bcx, tmp)),
|
||||||
false);
|
false);
|
||||||
uval.bcx.build.Br(after_cx.llbb);
|
log_bcx = uval.bcx;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
alt (ty.struct(cx.fcx.lcx.ccx.tcx, e_ty)) {
|
alt (ty.struct(cx.fcx.lcx.ccx.tcx, e_ty)) {
|
||||||
case (ty.ty_str) {
|
case (ty.ty_str) {
|
||||||
auto v = vp2i(sub.bcx, sub.val);
|
auto v = vp2i(log_bcx, sub.val);
|
||||||
trans_upcall(sub.bcx,
|
log_bcx = trans_upcall(log_bcx,
|
||||||
"upcall_log_str",
|
"upcall_log_str",
|
||||||
vec(C_int(lvl), v),
|
vec(C_int(lvl), v),
|
||||||
false).bcx.build.Br(after_cx.llbb);
|
false).bcx;
|
||||||
}
|
}
|
||||||
case (_) {
|
case (_) {
|
||||||
auto v = vec(C_int(lvl), sub.val);
|
auto v = vec(C_int(lvl), sub.val);
|
||||||
trans_upcall(sub.bcx,
|
log_bcx = trans_upcall(log_bcx,
|
||||||
"upcall_log_int",
|
"upcall_log_int",
|
||||||
v, false).bcx.build.Br(after_cx.llbb);
|
v, false).bcx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_bcx = trans_block_cleanups(log_bcx, log_cx);
|
||||||
|
log_bcx.build.Br(after_cx.llbb);
|
||||||
|
|
||||||
ret res(after_cx, C_nil());
|
ret res(after_cx, C_nil());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue