Skip to content

Commit

Permalink
Use new symbol names for items of various kinds.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Feb 15, 2016
1 parent b474c10 commit 13a5ea0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/librustc_trans/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ pub use self::ValueOrigin::*;
use super::CrateTranslation;
use super::ModuleTranslation;

use back::link::mangle_exported_name;
use back::{link, abi};
use back::{link, abi, symbol_names};
use lint;
use llvm::{BasicBlockRef, Linkage, ValueRef, Vector, get_param};
use llvm;
Expand Down Expand Up @@ -2730,16 +2729,17 @@ fn exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
// Use provided name
Some(name) => name.to_string(),
_ => {
let path = ccx.tcx().map.def_path_from_id(id);
if attr::contains_name(attrs, "no_mangle") {
// Don't mangle
let path = ccx.tcx().map.def_path_from_id(id);
path.last().unwrap().data.to_string()
} else {
match weak_lang_items::link_name(attrs) {
Some(name) => name.to_string(),
None => {
// Usual name mangling
mangle_exported_name(ccx, path, ty, id)
let def_id = ccx.tcx().map.local_def_id(id);
symbol_names::exported_name(ccx, def_id, &[ty])
}
}
}
Expand All @@ -2763,7 +2763,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
debug!("get_item_val: id={} item={:?}", id, item);
let val = match item {
hir_map::NodeItem(i) => {
let ty = ccx.tcx().node_id_to_type(i.id);
let ty = ccx.tcx().erase_regions(&ccx.tcx().node_id_to_type(i.id));
let sym = || exported_name(ccx, id, ty, &i.attrs);

let v = match i.node {
Expand Down Expand Up @@ -2835,7 +2835,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
match ni.node {
hir::ForeignItemFn(..) => {
let abi = ccx.tcx().map.get_foreign_abi(id);
let ty = ccx.tcx().node_id_to_type(ni.id);
let ty = ccx.tcx().erase_regions(&ccx.tcx().node_id_to_type(ni.id));
let name = foreign::link_name(&ni);
foreign::register_foreign_item_fn(ccx, abi, ty, &name, &ni.attrs)
}
Expand All @@ -2853,7 +2853,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
v.node.data.fields()
};
assert!(!fields.is_empty());
let ty = ccx.tcx().node_id_to_type(id);
let ty = ccx.tcx().erase_regions(&ccx.tcx().node_id_to_type(id));
let parent = ccx.tcx().map.get_parent(id);
let enm = ccx.tcx().map.expect_item(parent);
let sym = exported_name(ccx, id, ty, &enm.attrs);
Expand All @@ -2877,7 +2877,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
};
let parent = ccx.tcx().map.get_parent(id);
let struct_item = ccx.tcx().map.expect_item(parent);
let ty = ccx.tcx().node_id_to_type(ctor_id);
let ty = ccx.tcx().erase_regions(&ccx.tcx().node_id_to_type(ctor_id));
let sym = exported_name(ccx, id, ty, &struct_item.attrs);
let llfn = register_fn(ccx, struct_item.span, sym, ctor_id, ty);
attributes::inline(llfn, attributes::InlineAttr::Hint);
Expand Down Expand Up @@ -2907,7 +2907,7 @@ fn register_method(ccx: &CrateContext,
attrs: &[ast::Attribute],
span: Span)
-> ValueRef {
let mty = ccx.tcx().node_id_to_type(id);
let mty = ccx.tcx().erase_regions(&ccx.tcx().node_id_to_type(id));

let sym = exported_name(ccx, id, mty, &attrs);

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/test/run-pass/issue-17718.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// aux-build:issue-17718.rs
// aux-build:issue-17718-aux.rs


#![feature(core)]
#![feature(const_fn)]

extern crate issue_17718 as other;
extern crate issue_17718_aux as other;

use std::sync::atomic::{AtomicUsize, Ordering};

Expand Down

0 comments on commit 13a5ea0

Please sign in to comment.