diff options
-rw-r--r-- | src/clang.rs | 7 | ||||
-rw-r--r-- | src/ir/function.rs | 9 | ||||
-rw-r--r-- | tests/expectations/tests/noreturn.rs | 10 | ||||
-rw-r--r-- | tests/headers/noreturn.hpp (renamed from tests/headers/noreturn.h) | 1 |
4 files changed, 23 insertions, 4 deletions
diff --git a/src/clang.rs b/src/clang.rs index fddb261c..ea505c87 100644 --- a/src/clang.rs +++ b/src/clang.rs @@ -37,6 +37,13 @@ impl Attribute { kind: None, token_kind: CXToken_Keyword, }; + + /// A `[[noreturn]]` attribute. + pub const NO_RETURN_CPP: Self = Self { + name: b"noreturn", + kind: None, + token_kind: CXToken_Identifier, + }; } /// A cursor into the Clang AST, pointing to an AST node. diff --git a/src/ir/function.rs b/src/ir/function.rs index 6ed3a503..a967954e 100644 --- a/src/ir/function.rs +++ b/src/ir/function.rs @@ -450,9 +450,14 @@ impl FunctionSig { } }; - let [must_use, is_divergent] = + let (must_use, is_divergent) = if ctx.options().enable_function_attribute_detection { - cursor.has_attrs(&[Attribute::MUST_USE, Attribute::NO_RETURN]) + let [must_use, no_return, no_return_cpp] = cursor.has_attrs(&[ + Attribute::MUST_USE, + Attribute::NO_RETURN, + Attribute::NO_RETURN_CPP, + ]); + (must_use, no_return || no_return_cpp) } else { Default::default() }; diff --git a/tests/expectations/tests/noreturn.rs b/tests/expectations/tests/noreturn.rs index fa81ee76..1ffce9c0 100644 --- a/tests/expectations/tests/noreturn.rs +++ b/tests/expectations/tests/noreturn.rs @@ -6,8 +6,14 @@ )] extern "C" { - pub fn f() -> !; + #[link_name = "\u{1}_Z1fv"] + pub fn f() -> !; } extern "C" { - pub fn g(); + #[link_name = "\u{1}_Z1gv"] + pub fn g(); +} +extern "C" { + #[link_name = "\u{1}_Z1hv"] + pub fn h() -> !; } diff --git a/tests/headers/noreturn.h b/tests/headers/noreturn.hpp index 0e4819e2..deaa3b1a 100644 --- a/tests/headers/noreturn.h +++ b/tests/headers/noreturn.hpp @@ -2,3 +2,4 @@ _Noreturn void f(void); // TODO (pvdrz): figure out how to handle this case. __attribute__((noreturn)) void g(void); +[[noreturn]] void h(void); |