Skip to content

Trace methods in CompInfo's TypeCollector impl #411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/ir/comp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,8 @@ impl TypeCollector for CompInfo {
types.insert(var);
}

// FIXME(emilio): Methods, VTable?
for method in self.methods() {
types.insert(method.signature);
}
}
}
7 changes: 6 additions & 1 deletion src/ir/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
}
}
}
Expand Down
23 changes: 17 additions & 6 deletions src/ir/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!("<Type as TypeCollector>::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 => {}
}
}
}
41 changes: 41 additions & 0 deletions tests/expectations/tests/issue-410.rs
Original file line number Diff line number Diff line change
@@ -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::<Value>() , 1usize);
assert_eq!(::std::mem::align_of::<Value>() , 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 { }
}
12 changes: 12 additions & 0 deletions tests/headers/issue-410.hpp
Original file line number Diff line number Diff line change
@@ -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);
};
}