mirror of
https://github.com/openharmony/third_party_rust_bindgen.git
synced 2026-07-20 22:56:53 -04:00
handle c++ [[noreturn]] attribute
This commit is contained in:
committed by
Emilio Cobos Álvarez
parent
3133fe4792
commit
305652fc15
@@ -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
@@ -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()
|
||||
};
|
||||
|
||||
Generated
+8
-2
@@ -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);
|
||||
Reference in New Issue
Block a user