diff options
author | kohanis <kohanis@ya.ru> | 2022-11-09 17:24:27 +0300 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2022-11-09 16:04:01 +0100 |
commit | ed3aa90cd4c4e1e59d15942414a6dbc586ac1ed4 (patch) | |
tree | e0feada4289146f049d8534ce1dc65d93c1efb51 | |
parent | c03b37697a1e117995ea76203e5c0ce7d6696c4e (diff) |
Fix inline function identification
-rw-r--r-- | bindgen-tests/tests/expectations/tests/public-dtor.rs | 88 | ||||
-rw-r--r-- | bindgen-tests/tests/headers/constructor-tp.hpp | 3 | ||||
-rw-r--r-- | bindgen-tests/tests/headers/public-dtor.hpp | 21 | ||||
-rw-r--r-- | bindgen/ir/function.rs | 6 |
4 files changed, 71 insertions, 47 deletions
diff --git a/bindgen-tests/tests/expectations/tests/public-dtor.rs b/bindgen-tests/tests/expectations/tests/public-dtor.rs index f9559a08..1d095b8d 100644 --- a/bindgen-tests/tests/expectations/tests/public-dtor.rs +++ b/bindgen-tests/tests/expectations/tests/public-dtor.rs @@ -1,35 +1,53 @@ -#![allow( - dead_code, - non_snake_case, - non_camel_case_types, - non_upper_case_globals -)] - -#[repr(C)] -#[derive(Debug, Default)] -pub struct cv_String { - pub _address: u8, -} -#[test] -fn bindgen_test_layout_cv_String() { - assert_eq!( - ::std::mem::size_of::<cv_String>(), - 1usize, - concat!("Size of: ", stringify!(cv_String)) - ); - assert_eq!( - ::std::mem::align_of::<cv_String>(), - 1usize, - concat!("Alignment of ", stringify!(cv_String)) - ); -} -extern "C" { - #[link_name = "\u{1}_ZN2cv6StringD1Ev"] - pub fn cv_String_String_destructor(this: *mut cv_String); -} -impl cv_String { - #[inline] - pub unsafe fn destruct(&mut self) { - unsafe { cv_String_String_destructor(self) } - } -} +#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+#[repr(C)]
+#[derive(Debug, Default)]
+pub struct cv_Foo {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_cv_Foo() {
+ assert_eq!(
+ ::std::mem::size_of::<cv_Foo>(),
+ 1usize,
+ concat!("Size of: ", stringify!(cv_Foo))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<cv_Foo>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(cv_Foo))
+ );
+}
+extern "C" {
+ #[link_name = "\u{1}_ZN2cv3FooD1Ev"]
+ pub fn cv_Foo_Foo_destructor(this: *mut cv_Foo);
+}
+impl cv_Foo {
+ #[inline]
+ pub unsafe fn destruct(&mut self) {
+ unsafe { cv_Foo_Foo_destructor(self) }
+ }
+}
+#[repr(C)]
+#[derive(Debug, Default)]
+pub struct cv_Bar {
+ pub _address: u8,
+}
+#[test]
+fn bindgen_test_layout_cv_Bar() {
+ assert_eq!(
+ ::std::mem::size_of::<cv_Bar>(),
+ 1usize,
+ concat!("Size of: ", stringify!(cv_Bar))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<cv_Bar>(),
+ 1usize,
+ concat!("Alignment of ", stringify!(cv_Bar))
+ );
+}
diff --git a/bindgen-tests/tests/headers/constructor-tp.hpp b/bindgen-tests/tests/headers/constructor-tp.hpp index 6e55ea78..3b5d5407 100644 --- a/bindgen-tests/tests/headers/constructor-tp.hpp +++ b/bindgen-tests/tests/headers/constructor-tp.hpp @@ -8,7 +8,7 @@ public: }; template<typename T> -inline void +void Foo<T>::doBaz() { } @@ -21,6 +21,5 @@ template<typename T> Foo<T>::Foo() { } -inline Bar::Bar() { } diff --git a/bindgen-tests/tests/headers/public-dtor.hpp b/bindgen-tests/tests/headers/public-dtor.hpp index 5d4fb592..60d69d79 100644 --- a/bindgen-tests/tests/headers/public-dtor.hpp +++ b/bindgen-tests/tests/headers/public-dtor.hpp @@ -1,15 +1,18 @@ - namespace cv { -class String { -public: - ~String(); -}; + class Foo { + public: + ~Foo(); + }; + Foo::~Foo() {} -inline -String::~String() -{ -} + class Bar { + public: + ~Bar(); + }; + + inline + Bar::~Bar() {} } diff --git a/bindgen/ir/function.rs b/bindgen/ir/function.rs index 52346f6c..7dbbb8f8 100644 --- a/bindgen/ir/function.rs +++ b/bindgen/ir/function.rs @@ -675,7 +675,11 @@ impl ClangSubItemParser for Function { return Err(ParseError::Continue); } - if cursor.is_inlined_function() { + if cursor.is_inlined_function() || + cursor + .definition() + .map_or(false, |x| x.is_inlined_function()) + { if !context.options().generate_inline_functions { return Err(ParseError::Continue); } |