summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poveda <christian.poveda@ferrous-systems.com>2022-09-01 16:11:05 -0500
committerEmilio Cobos Álvarez <emilio@crisal.io>2022-09-22 20:25:33 -1000
commit953acc526a808dac53660cee79c68d15ac309a63 (patch)
treeaf64bc688dd7e74bcfb85fadd210bedb170641fb
parent2ffc8d8946a44f2a695a0c148ad24e7e0e9637d2 (diff)
handle `__attribute__((noreturn))` attribute
-rw-r--r--src/ir/function.rs7
-rw-r--r--tests/expectations/tests/noreturn.rs2
2 files changed, 7 insertions, 2 deletions
diff --git a/src/ir/function.rs b/src/ir/function.rs
index a967954e..928b5aad 100644
--- a/src/ir/function.rs
+++ b/src/ir/function.rs
@@ -450,7 +450,7 @@ impl FunctionSig {
}
};
- let (must_use, is_divergent) =
+ let (must_use, mut is_divergent) =
if ctx.options().enable_function_attribute_detection {
let [must_use, no_return, no_return_cpp] = cursor.has_attrs(&[
Attribute::MUST_USE,
@@ -462,6 +462,11 @@ impl FunctionSig {
Default::default()
};
+ // This looks easy to break but the clang parser keeps the type spelling clean even if
+ // other attributes are added.
+ is_divergent =
+ is_divergent || ty.spelling().contains("__attribute__((noreturn))");
+
let is_method = kind == CXCursor_CXXMethod;
let is_constructor = kind == CXCursor_Constructor;
let is_destructor = kind == CXCursor_Destructor;
diff --git a/tests/expectations/tests/noreturn.rs b/tests/expectations/tests/noreturn.rs
index 1ffce9c0..19457495 100644
--- a/tests/expectations/tests/noreturn.rs
+++ b/tests/expectations/tests/noreturn.rs
@@ -11,7 +11,7 @@ extern "C" {
}
extern "C" {
#[link_name = "\u{1}_Z1gv"]
- pub fn g();
+ pub fn g() -> !;
}
extern "C" {
#[link_name = "\u{1}_Z1hv"]