Remove spurious by-ref argument to destructors
Destructors were internally declared with an extra (hidden) nil-typed argument that was passed in by-ref mode. This was causing spurious mode warnings. Deleted it. Also some misc. cleanup because I couldn't help myself.
This commit is contained in:
parent
656cbead49
commit
996ec62cbf
@ -398,10 +398,8 @@ fn operator_prec(op: ast::binop) -> uint {
|
||||
|
||||
fn dtor_dec() -> fn_decl {
|
||||
let nil_t = @{id: 0, node: ty_nil, span: dummy_sp()};
|
||||
// dtor has one argument, of type ()
|
||||
{inputs: ~[{mode: ast::expl(ast::by_ref),
|
||||
ty: nil_t, ident: parse::token::special_idents::underscore,
|
||||
id: 0}],
|
||||
// dtor has no args
|
||||
{inputs: ~[],
|
||||
output: nil_t, cf: return_val}
|
||||
}
|
||||
|
||||
|
@ -383,7 +383,7 @@ fn get_res_dtor(ccx: @crate_ctxt, did: ast::def_id,
|
||||
parent_id: ast::def_id, substs: ~[ty::t])
|
||||
-> ValueRef {
|
||||
let _icx = ccx.insn_ctxt("trans_res_dtor");
|
||||
if (substs.len() > 0u) {
|
||||
if (substs.is_not_empty()) {
|
||||
let did = if did.crate != ast::local_crate {
|
||||
inline::maybe_instantiate_inline(ccx, did)
|
||||
} else { did };
|
||||
@ -1496,7 +1496,7 @@ fn copy_args_to_allocas(fcx: fn_ctxt,
|
||||
|
||||
// For certain mode/type combinations, the raw llarg values are passed
|
||||
// by value. However, within the fn body itself, we want to always
|
||||
// have all locals and argumenst be by-ref so that we can cancel the
|
||||
// have all locals and arguments be by-ref so that we can cancel the
|
||||
// cleanup and for better interaction with LLVM's debug info. So, if
|
||||
// the argument would be passed by value, we store it into an alloca.
|
||||
// This alloca should be optimized away by LLVM's mem-to-reg pass in
|
||||
@ -1767,9 +1767,7 @@ fn trans_class_dtor(ccx: @crate_ctxt, path: path,
|
||||
|
||||
/* The dtor takes a (null) output pointer, and a self argument,
|
||||
and returns () */
|
||||
let lldty = T_fn(~[T_ptr(type_of(ccx, ty::mk_nil(tcx))),
|
||||
T_ptr(type_of(ccx, class_ty))],
|
||||
llvm::LLVMVoidType());
|
||||
let lldty = type_of_dtor(ccx, class_ty);
|
||||
|
||||
let s = get_dtor_symbol(ccx, path, dtor_id, psubsts);
|
||||
|
||||
@ -1833,7 +1831,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
|
||||
*path,
|
||||
~[path_name(item.ident)]),
|
||||
decl, body, llfndecl, item.id);
|
||||
} else if tps.len() == 0u {
|
||||
} else if tps.is_empty() {
|
||||
let llfndecl = get_item_val(ccx, item.id);
|
||||
trans_fn(ccx,
|
||||
vec::append(*path, ~[path_name(item.ident)]),
|
||||
|
@ -204,7 +204,7 @@ fn appropriate_mode(ty: ty::t) -> DatumMode {
|
||||
*
|
||||
* Indicates the "appropriate" mode for this value,
|
||||
* which is either by ref or by value, depending
|
||||
* on whether type is iimmediate or what. */
|
||||
* on whether type is immediate or not. */
|
||||
|
||||
if ty::type_is_nil(ty) || ty::type_is_bot(ty) {
|
||||
ByValue
|
||||
|
@ -426,8 +426,8 @@ fn trans_class_drop(bcx: block,
|
||||
// Class dtors have no explicit args, so the params should
|
||||
// just consist of the output pointer and the environment
|
||||
// (self)
|
||||
assert(params.len() == 2u);
|
||||
let self_arg = PointerCast(bcx, v0, params[1u]);
|
||||
assert(params.len() == 2);
|
||||
let self_arg = PointerCast(bcx, v0, params[1]);
|
||||
let args = ~[bcx.fcx.llretptr, self_arg];
|
||||
Call(bcx, dtor_addr, args);
|
||||
|
||||
@ -440,7 +440,7 @@ fn trans_class_drop(bcx: block,
|
||||
bcx = drop_ty(bcx, llfld_a, fld.mt.ty);
|
||||
}
|
||||
|
||||
Store(bcx, C_u8(0u), drop_flag);
|
||||
Store(bcx, C_u8(0), drop_flag);
|
||||
bcx
|
||||
}
|
||||
}
|
||||
|
@ -103,11 +103,11 @@ fn monomorphic_fn(ccx: @crate_ctxt,
|
||||
// Random cut-off -- code that needs to instantiate the same function
|
||||
// recursively more than ten times can probably safely be assumed to be
|
||||
// causing an infinite expansion.
|
||||
if depth > 10u {
|
||||
if depth > 10 {
|
||||
ccx.sess.span_fatal(
|
||||
span, ~"overly deep expansion of inlined function");
|
||||
}
|
||||
ccx.monomorphizing.insert(fn_id, depth + 1u);
|
||||
ccx.monomorphizing.insert(fn_id, depth + 1);
|
||||
|
||||
let pt = vec::append(*pt,
|
||||
~[path_name(ccx.names(ccx.sess.str_of(name)))]);
|
||||
|
@ -254,8 +254,8 @@ fn llvm_type_name(cx: @crate_ctxt,
|
||||
}
|
||||
|
||||
fn type_of_dtor(ccx: @crate_ctxt, self_ty: ty::t) -> TypeRef {
|
||||
T_fn(~[T_ptr(type_of(ccx, ty::mk_nil(ccx.tcx))),
|
||||
T_ptr(type_of(ccx, self_ty))],
|
||||
T_fn(~[T_ptr(type_of(ccx, ty::mk_nil(ccx.tcx))), // output pointer
|
||||
T_ptr(type_of(ccx, self_ty))], // self arg
|
||||
llvm::LLVMVoidType())
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user