|
14 | 14 | //! and methods are represented as just a fn ptr and not a full
|
15 | 15 | //! closure.
|
16 | 16 |
|
17 |
| -use llvm::{self, ValueRef}; |
18 |
| -use rustc::hir::def_id::DefId; |
19 |
| -use rustc::ty::subst::Substs; |
20 | 17 | use attributes;
|
21 | 18 | use common::{self, CrateContext};
|
22 |
| -use monomorphize; |
23 | 19 | use consts;
|
24 | 20 | use declare;
|
25 |
| -use monomorphize::Instance; |
| 21 | +use llvm::{self, ValueRef}; |
| 22 | +use monomorphize::{self, Instance}; |
| 23 | +use rustc::hir::def_id::DefId; |
| 24 | +use rustc::ty::{self, TypeFoldable}; |
| 25 | +use rustc::ty::subst::Substs; |
| 26 | +use syntax_pos::DUMMY_SP; |
26 | 27 | use trans_item::TransItem;
|
27 | 28 | use type_of;
|
28 |
| -use rustc::ty::TypeFoldable; |
29 | 29 |
|
30 | 30 | /// Translates a reference to a fn/method item, monomorphizing and
|
31 | 31 | /// inlining as it goes.
|
@@ -102,15 +102,17 @@ pub fn get_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
102 | 102 | let attrs = instance.def.attrs(ccx.tcx());
|
103 | 103 | attributes::from_fn_attrs(ccx, &attrs, llfn);
|
104 | 104 |
|
105 |
| - let is_local_def = ccx.shared().translation_items().borrow() |
106 |
| - .contains(&TransItem::Fn(instance)); |
107 |
| - if is_local_def { |
108 |
| - // FIXME(eddyb) Doubt all extern fn should allow unwinding. |
| 105 | + // Perhaps questionable, but we assume that anything defined |
| 106 | + // *in Rust code* may unwind. Foreign items like `extern "C" { |
| 107 | + // fn foo(); }` are assumed not to unwind **unless** they have |
| 108 | + // a `#[unwind]` attribute. |
| 109 | + if !ty::queries::is_foreign_item::get(tcx, DUMMY_SP, instance.def_id()) { |
109 | 110 | attributes::unwind(llfn, true);
|
110 | 111 | unsafe {
|
111 | 112 | llvm::LLVMRustSetLinkage(llfn, llvm::Linkage::ExternalLinkage);
|
112 | 113 | }
|
113 | 114 | }
|
| 115 | + |
114 | 116 | if ccx.use_dll_storage_attrs() &&
|
115 | 117 | ccx.sess().cstore.is_dllimport_foreign_item(instance.def_id())
|
116 | 118 | {
|
|
0 commit comments