handle c++ [[noreturn]] attribute

This commit is contained in:
Christian Poveda
2022-09-01 15:59:37 -05:00
committed by Emilio Cobos Álvarez
parent 3133fe4792
commit 305652fc15
4 changed files with 23 additions and 4 deletions
+7
View File
@@ -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.
+7 -2
View File
@@ -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()
};
+8 -2
View File
@@ -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() -> !;
}
@@ -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);