Skip to content

Commit 0b284fb

Browse files
committed
---
yaml --- r: 10613 b: refs/heads/snap-stage3 c: 6db7843 h: refs/heads/master i: 10611: 6d13765 v: v3
1 parent c48e080 commit 0b284fb

File tree

2 files changed

+42
-22
lines changed

2 files changed

+42
-22
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 2898dcc5d97da9427ac367542382b6239d9c0bbf
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 1b4dcbecac824796bf7cd49a1fbadc20e63c99ea
4+
refs/heads/snap-stage3: 6db7843f46afd5cd905b2e3a4266a23c4bb41ef1
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/snap-stage3/src/rustc/middle/trans/base.rs

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2304,14 +2304,14 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t],
23042304
}
23052305
}
23062306
ast_map::node_dtor(_, dtor, _, pt) {
2307-
let parent_id = alt ty::ty_to_def_id(ty::node_id_to_type(ccx.tcx,
2308-
dtor.node.self_id)) {
2309-
some(did) { did }
2310-
none { ccx.sess.span_bug(dtor.span, "Bad self ty in \
2307+
let parent_id = alt ty::ty_to_def_id(ty::node_id_to_type(ccx.tcx,
2308+
dtor.node.self_id)) {
2309+
some(did) { did }
2310+
none { ccx.sess.span_bug(dtor.span, "Bad self ty in \
23112311
dtor"); }
2312-
};
2313-
trans_class_dtor(ccx, *pt, dtor.node.body,
2314-
dtor.node.id, psubsts, some(hash_id), parent_id)
2312+
};
2313+
trans_class_dtor(ccx, *pt, dtor.node.body,
2314+
dtor.node.id, psubsts, some(hash_id), parent_id)
23152315
}
23162316
// Ugh -- but this ensures any new variants won't be forgotten
23172317
ast_map::node_expr(*) { ccx.tcx.sess.bug("Can't monomorphize an expr") }
@@ -4930,15 +4930,15 @@ fn trans_class_ctor(ccx: @crate_ctxt, path: path, decl: ast::fn_decl,
49304930
}
49314931

49324932
fn trans_class_dtor(ccx: @crate_ctxt, path: path,
4933-
body: ast::blk,
4934-
dtor_id: ast::node_id, substs: option<param_substs>,
4935-
hash_id: option<mono_id>, parent_id: ast::def_id)
4933+
body: ast::blk, dtor_id: ast::node_id,
4934+
psubsts: option<param_substs>,
4935+
hash_id: option<mono_id>, parent_id: ast::def_id)
49364936
-> ValueRef {
49374937
let tcx = ccx.tcx;
49384938
/* Look up the parent class's def_id */
49394939
let mut class_ty = ty::lookup_item_type(tcx, parent_id).ty;
49404940
/* Substitute in the class type if necessary */
4941-
option::iter(substs) {|ss|
4941+
option::iter(psubsts) {|ss|
49424942
class_ty = ty::subst_tps(tcx, ss.tys, class_ty);
49434943
}
49444944

@@ -4947,7 +4947,9 @@ fn trans_class_dtor(ccx: @crate_ctxt, path: path,
49474947
let lldty = T_fn([T_ptr(type_of(ccx, ty::mk_nil(tcx))),
49484948
T_ptr(type_of(ccx, class_ty))],
49494949
llvm::LLVMVoidType());
4950-
let s = get_dtor_symbol(ccx, path, dtor_id);
4950+
4951+
let s = get_dtor_symbol(ccx, path, dtor_id, psubsts);
4952+
49514953
/* Register the dtor as a function. It has external linkage */
49524954
let lldecl = decl_internal_cdecl_fn(ccx.llmod, s, lldty);
49534955
lib::llvm::SetLinkage(lldecl, lib::llvm::ExternalLinkage);
@@ -4959,7 +4961,7 @@ fn trans_class_dtor(ccx: @crate_ctxt, path: path,
49594961
}
49604962
/* Translate the dtor body */
49614963
trans_fn(ccx, path, ast_util::dtor_dec(),
4962-
body, lldecl, impl_self(class_ty), substs, dtor_id);
4964+
body, lldecl, impl_self(class_ty), psubsts, dtor_id);
49634965
lldecl
49644966
}
49654967

@@ -5196,16 +5198,34 @@ fn item_path(ccx: @crate_ctxt, i: @ast::item) -> path {
51965198
} + [path_name(i.ident)]
51975199
}
51985200

5199-
/* If there's already a symbol for the dtor with <id>, return it;
5200-
otherwise, create one and register it, returning it as well */
5201-
fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id) -> str {
5201+
/* If there's already a symbol for the dtor with <id> and substs <substs>,
5202+
return it; otherwise, create one and register it, returning it as well */
5203+
fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id,
5204+
substs: option<param_substs>) -> str {
5205+
let t = ty::node_id_to_type(ccx.tcx, id);
52025206
alt ccx.item_symbols.find(id) {
52035207
some(s) { s }
5208+
none if is_none(substs) {
5209+
let s = mangle_exported_name(ccx,
5210+
path + [path_name(@ccx.names("dtor"))],
5211+
t);
5212+
ccx.item_symbols.insert(id, s);
5213+
s
5214+
}
52045215
none {
5205-
let s = mangle_exported_name(ccx, path +
5206-
[path_name(@ccx.names("dtor"))], ty::node_id_to_type(ccx.tcx, id));
5207-
ccx.item_symbols.insert(id, s);
5208-
s
5216+
// Monomorphizing, so just make a symbol, don't add
5217+
// this to item_symbols
5218+
alt substs {
5219+
some(ss) {
5220+
let mono_ty = ty::subst_tps(ccx.tcx, ss.tys, t);
5221+
mangle_exported_name(ccx, path +
5222+
[path_name(@ccx.names("dtor"))], mono_ty)
5223+
}
5224+
none {
5225+
ccx.sess.bug(#fmt("get_dtor_symbol: not monomorphizing and \
5226+
couldn't find a symbol for dtor %?", path));
5227+
}
5228+
}
52095229
}
52105230
}
52115231
}
@@ -5289,7 +5309,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
52895309
let lldty = T_fn([T_ptr(type_of(ccx, ty::mk_nil(tcx))),
52905310
T_ptr(type_of(ccx, class_ty))],
52915311
llvm::LLVMVoidType());
5292-
let s = get_dtor_symbol(ccx, *pt, dt.node.id);
5312+
let s = get_dtor_symbol(ccx, *pt, dt.node.id, none);
52935313

52945314
/* Make the declaration for the dtor */
52955315
let llfn = decl_internal_cdecl_fn(ccx.llmod, s, lldty);

0 commit comments

Comments
 (0)