diff options
| author | Björn Steinbrink <bsteinbr@gmail.com> | 2015-09-11 20:07:12 +0200 |
|---|---|---|
| committer | Björn Steinbrink <bsteinbr@gmail.com> | 2015-09-13 23:42:40 +0200 |
| commit | 90c48bed25751f4c171b1555f8114234ca0a81c4 (patch) | |
| tree | 773054606e8a177f80e88bf36fbd26feb8e60675 /src | |
| parent | fd230ff12481ebeba720fb1ac1f610d93bb74920 (diff) | |
| download | rust-90c48bed25751f4c171b1555f8114234ca0a81c4.tar.gz rust-90c48bed25751f4c171b1555f8114234ca0a81c4.zip | |
Centralise the handling of attributes on extern functions
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_trans/trans/base.rs | 9 | ||||
| -rw-r--r-- | src/librustc_trans/trans/foreign.rs | 7 |
2 files changed, 6 insertions, 10 deletions
diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index f8b60ebdea5..1359252e035 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -677,11 +677,8 @@ pub fn trans_external_path<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ccx.sess().bug("unexpected intrinsic in trans_external_path") } _ => { - let llfn = foreign::register_foreign_item_fn(ccx, fn_ty.abi, - t, &name); let attrs = csearch::get_item_attrs(&ccx.sess().cstore, did); - attributes::from_fn_attrs(ccx, &attrs, llfn); - llfn + foreign::register_foreign_item_fn(ccx, fn_ty.abi, t, &name, &attrs) } } } @@ -2418,9 +2415,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef { let abi = ccx.tcx().map.get_foreign_abi(id); let ty = ccx.tcx().node_id_to_type(ni.id); let name = foreign::link_name(&*ni); - let llfn = foreign::register_foreign_item_fn(ccx, abi, ty, &name); - attributes::from_fn_attrs(ccx, &ni.attrs, llfn); - llfn + foreign::register_foreign_item_fn(ccx, abi, ty, &name, &ni.attrs) } hir::ForeignItemStatic(..) => { foreign::register_static(ccx, &*ni) diff --git a/src/librustc_trans/trans/foreign.rs b/src/librustc_trans/trans/foreign.rs index 9781fd037d7..9a561249594 100644 --- a/src/librustc_trans/trans/foreign.rs +++ b/src/librustc_trans/trans/foreign.rs @@ -187,7 +187,8 @@ pub fn get_extern_fn(ccx: &CrateContext, /// Registers a foreign function found in a library. Just adds a LLVM global. pub fn register_foreign_item_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, abi: Abi, fty: Ty<'tcx>, - name: &str) -> ValueRef { + name: &str, + attrs: &[hir::Attribute])-> ValueRef { debug!("register_foreign_item_fn(abi={:?}, \ ty={:?}, \ name={})", @@ -211,6 +212,7 @@ pub fn register_foreign_item_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, let llfn = get_extern_fn(ccx, &mut *ccx.externs().borrow_mut(), name, cc, llfn_ty, fty); add_argument_attributes(&tys, llfn); + attributes::from_fn_attrs(ccx, attrs, llfn); llfn } @@ -489,8 +491,7 @@ pub fn trans_foreign_mod(ccx: &CrateContext, foreign_mod: &hir::ForeignMod) { "foreign fn's sty isn't a bare_fn_ty?") } - let llfn = register_foreign_item_fn(ccx, abi, ty, &lname); - attributes::from_fn_attrs(ccx, &foreign_item.attrs, llfn); + register_foreign_item_fn(ccx, abi, ty, &lname, &foreign_item.attrs); // Unlike for other items, we shouldn't call // `base::update_linkage` here. Foreign items have // special linkage requirements, which are handled |
