summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Poveda <christian.poveda@ferrous-systems.com>2022-09-01 15:59:37 -0500
committerEmilio Cobos Álvarez <emilio@crisal.io>2022-09-22 20:25:33 -1000
commit2ffc8d8946a44f2a695a0c148ad24e7e0e9637d2 (patch)
tree91f9406fd1234273ee8eaed37ae1a0b2d8322736 /src
parente503476a96636df41532b988f8f8f0c318fff24a (diff)
handle c++ `[[noreturn]]` attribute
Diffstat (limited to 'src')
-rw-r--r--src/clang.rs7
-rw-r--r--src/ir/function.rs9
2 files changed, 14 insertions, 2 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()
};