Skip to content

Commit

Permalink
Add an attribute to mark function as unwinding
Browse files Browse the repository at this point in the history
  • Loading branch information
dotdash committed Sep 13, 2015
1 parent 90c48be commit e4e67bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/librustc_trans/trans/attributes.rs
Expand Up @@ -59,7 +59,6 @@ pub fn emit_uwtable(val: ValueRef, emit: bool) {

/// Tell LLVM whether the function can or cannot unwind.
#[inline]
#[allow(dead_code)] // possibly useful function
pub fn unwind(val: ValueRef, can_unwind: bool) {
if can_unwind {
unsafe {
Expand Down Expand Up @@ -118,6 +117,8 @@ pub fn from_fn_attrs(ccx: &CrateContext, attrs: &[hir::Attribute], llfn: ValueRe
}
} else if attr.check_name("allocator") {
llvm::Attribute::NoAlias.apply_llfn(llvm::ReturnIndex as c_uint, llfn);
} else if attr.check_name("unwind") {
unwind(llfn, true);
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/libsyntax/feature_gate.rs
Expand Up @@ -188,6 +188,9 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Option<u32>, Status

// allow `extern "platform-intrinsic" { ... }`
("platform_intrinsics", "1.4.0", Some(27731), Active),

// allow `#[unwind]`
("unwind_attributes", "1.4.0", None, Active),
];
// (changing above list without updating src/doc/reference.md makes @cmr sad)

Expand Down Expand Up @@ -316,6 +319,7 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeGat
("unsafe_no_drop_flag", Whitelisted, Gated("unsafe_no_drop_flag",
"unsafe_no_drop_flag has unstable semantics \
and may be removed in the future")),
("unwind", Whitelisted, Gated("unwind_attributes", "#[unwind] is experimental")),

// used in resolve
("prelude_import", Whitelisted, Gated("prelude_import",
Expand Down

0 comments on commit e4e67bd

Please sign in to comment.