diff options
| author | Patrick Walton <[email protected]> | 2011-04-29 19:19:54 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-04-29 19:19:54 -0700 |
| commit | b101e26d92aa246271fcee3d66ea34f569e78cf8 (patch) | |
| tree | a5706d021e14c198d455683ef055326a6f3a490e /src/comp | |
| parent | rustc: Add constants for LLVM function attributes (diff) | |
| download | rust-b101e26d92aa246271fcee3d66ea34f569e78cf8.tar.xz rust-b101e26d92aa246271fcee3d66ea34f569e78cf8.zip | |
rustc: Run scope cleanups in the implicit block created by log statements. Fixes a leak.
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/middle/trans.rs | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 1447c643..93cc0b49 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -5294,6 +5294,7 @@ fn trans_log(int lvl, @block_ctxt cx, @ast.expr e) -> result { auto sub = trans_expr(log_cx, 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)) { let TypeRef tr; let bool is32bit = false; @@ -5310,38 +5311,41 @@ fn trans_log(int lvl, @block_ctxt cx, @ast.expr e) -> result { } } if (is32bit) { - auto uval = trans_upcall(sub.bcx, + auto uval = trans_upcall(log_bcx, "upcall_log_float", vec(C_int(lvl), sub.val), false); - uval.bcx.build.Br(after_cx.llbb); + log_bcx = uval.bcx; } else { - auto tmp = alloca(sub.bcx, tr); + auto tmp = alloca(log_bcx, tr); sub.bcx.build.Store(sub.val, tmp); - auto uval = trans_upcall(sub.bcx, + auto uval = trans_upcall(log_bcx, "upcall_log_double", - vec(C_int(lvl), vp2i(sub.bcx, tmp)), + vec(C_int(lvl), vp2i(log_bcx, tmp)), false); - uval.bcx.build.Br(after_cx.llbb); + log_bcx = uval.bcx; } } else { alt (ty.struct(cx.fcx.lcx.ccx.tcx, e_ty)) { case (ty.ty_str) { - auto v = vp2i(sub.bcx, sub.val); - trans_upcall(sub.bcx, - "upcall_log_str", - vec(C_int(lvl), v), - false).bcx.build.Br(after_cx.llbb); + auto v = vp2i(log_bcx, sub.val); + log_bcx = trans_upcall(log_bcx, + "upcall_log_str", + vec(C_int(lvl), v), + false).bcx; } case (_) { auto v = vec(C_int(lvl), sub.val); - trans_upcall(sub.bcx, - "upcall_log_int", - v, false).bcx.build.Br(after_cx.llbb); + log_bcx = trans_upcall(log_bcx, + "upcall_log_int", + 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()); } |