summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Boehme <mboehme@google.com>2021-04-29 09:10:31 +0200
committerEmilio Cobos Álvarez <emilio@crisal.io>2021-04-30 11:02:20 +0200
commit910d2be897bacd41a683c4055bc0fbae1b088dbc (patch)
tree38e966e903dad4d9c484103064bc58a62915f680 /src
parentf26d57d8f7febe2f7d62f39f7d9f2cbda8067bd2 (diff)
Don't generate bindings for deleted member functions. (#2044)
Closes #2044 Fixes #2043 See https://github.com/rust-lang/rust-bindgen/issues/2043 for details.
Diffstat (limited to 'src')
-rw-r--r--src/clang.rs21
-rw-r--r--src/ir/function.rs11
2 files changed, 28 insertions, 4 deletions
diff --git a/src/clang.rs b/src/clang.rs
index 66125089..96f77254 100644
--- a/src/clang.rs
+++ b/src/clang.rs
@@ -469,6 +469,27 @@ impl Cursor {
unsafe { clang_Cursor_isFunctionInlined(self.x) != 0 }
}
+ /// Is the referent a defaulted function?
+ pub fn is_defaulted_function(&self) -> bool {
+ unsafe { clang_CXXMethod_isDefaulted(self.x) != 0 }
+ }
+
+ /// Is the referent a deleted function?
+ pub fn is_deleted_function(&self) -> bool {
+ // Unfortunately, libclang doesn't yet have an API for checking if a
+ // member function is deleted, but the following should be a good
+ // enough approximation.
+ // Deleted functions are implicitly inline according to paragraph 4 of
+ // [dcl.fct.def.delete] in the C++ standard. Normal inline functions
+ // have a definition in the same translation unit, so if this is an
+ // inline function without a definition, and it's not a defaulted
+ // function, we can reasonably safely conclude that it's a deleted
+ // function.
+ self.is_inlined_function() &&
+ self.definition().is_none() &&
+ !self.is_defaulted_function()
+ }
+
/// Get the width of this cursor's referent bit field, or `None` if the
/// referent is not a bit field.
pub fn bit_width(&self) -> Option<u32> {
diff --git a/src/ir/function.rs b/src/ir/function.rs
index c0938b65..661ee593 100644
--- a/src/ir/function.rs
+++ b/src/ir/function.rs
@@ -597,10 +597,13 @@ impl ClangSubItemParser for Function {
return Err(ParseError::Continue);
}
- if !context.options().generate_inline_functions &&
- cursor.is_inlined_function()
- {
- return Err(ParseError::Continue);
+ if cursor.is_inlined_function() {
+ if !context.options().generate_inline_functions {
+ return Err(ParseError::Continue);
+ }
+ if cursor.is_deleted_function() {
+ return Err(ParseError::Continue);
+ }
}
let linkage = cursor.linkage();