diff --git a/src/ir/comp.rs b/src/ir/comp.rs index 968bf87987..ac68b672b3 100644 --- a/src/ir/comp.rs +++ b/src/ir/comp.rs @@ -957,6 +957,8 @@ impl TypeCollector for CompInfo { types.insert(var); } - // FIXME(emilio): Methods, VTable? + for method in self.methods() { + types.insert(method.signature); + } } } diff --git a/src/ir/item.rs b/src/ir/item.rs index df8fd22280..ac2d122e4e 100644 --- a/src/ir/item.rs +++ b/src/ir/item.rs @@ -205,7 +205,12 @@ impl TypeCollector for Item { ItemKind::Var(ref var) => { types.insert(var.ty()); } - _ => {} // FIXME. + ItemKind::Module(_) => { + // Module -> children edges are "weak", and we do not want to + // trace them. If we did, then whitelisting wouldn't work as + // expected: everything in every module would end up + // whitelisted. + } } } } diff --git a/src/ir/ty.rs b/src/ir/ty.rs index c1ed5b6466..1e87beb466 100644 --- a/src/ir/ty.rs +++ b/src/ir/ty.rs @@ -914,13 +914,24 @@ impl TypeCollector for Type { TypeKind::Function(ref sig) => { sig.collect_types(context, types, item) } - TypeKind::Named(_) => {} - // FIXME: Pending types! - ref other @ _ => { - debug!("::collect_types: Ignoring: \ - {:?}", - other); + TypeKind::Enum(ref en) => { + if let Some(repr) = en.repr() { + types.insert(repr); + } + } + TypeKind::UnresolvedTypeRef(_, _, Some(id)) => { + types.insert(id); } + + // None of these variants have edges to other items and types. + TypeKind::UnresolvedTypeRef(_, _, None) | + TypeKind::Named(_) | + TypeKind::Void | + TypeKind::NullPtr | + TypeKind::Int(_) | + TypeKind::Float(_) | + TypeKind::Complex(_) | + TypeKind::BlockPointer => {} } } } diff --git a/libbindgen/tests/expectations/tests/16-byte-alignment.rs b/tests/expectations/tests/16-byte-alignment.rs similarity index 100% rename from libbindgen/tests/expectations/tests/16-byte-alignment.rs rename to tests/expectations/tests/16-byte-alignment.rs diff --git a/tests/expectations/tests/issue-410.rs b/tests/expectations/tests/issue-410.rs new file mode 100644 index 0000000000..a5d9496039 --- /dev/null +++ b/tests/expectations/tests/issue-410.rs @@ -0,0 +1,41 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +pub mod root { + #[allow(unused_imports)] + use self::super::root; + pub mod JS { + #[allow(unused_imports)] + use self::super::super::root; + pub use root::_bindgen_ty_1 as JSWhyMagic; + #[repr(C)] + #[derive(Debug, Copy)] + pub struct Value { + pub _address: u8, + } + #[test] + fn bindgen_test_layout_Value() { + assert_eq!(::std::mem::size_of::() , 1usize); + assert_eq!(::std::mem::align_of::() , 1usize); + } + extern "C" { + #[link_name = "_ZN2JS5Value1aE10JSWhyMagic"] + pub fn Value_a(this: *mut root::JS::Value, + arg1: root::JS::JSWhyMagic); + } + impl Clone for Value { + fn clone(&self) -> Self { *self } + } + impl Value { + #[inline] + pub unsafe fn a(&mut self, arg1: root::JS::JSWhyMagic) { + Value_a(&mut *self, arg1) + } + } + } + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub enum _bindgen_ty_1 { } +} diff --git a/libbindgen/tests/headers/16-byte-alignment.h b/tests/headers/16-byte-alignment.h similarity index 100% rename from libbindgen/tests/headers/16-byte-alignment.h rename to tests/headers/16-byte-alignment.h diff --git a/tests/headers/issue-410.hpp b/tests/headers/issue-410.hpp new file mode 100644 index 0000000000..a7a834cfc4 --- /dev/null +++ b/tests/headers/issue-410.hpp @@ -0,0 +1,12 @@ +// bindgen-flags: --enable-cxx-namespaces --whitelist-type JS::Value + +namespace JS { +class Value; +} +typedef enum {} JSWhyMagic; +namespace JS { +class Value { +public: + void a(JSWhyMagic); +}; +}