summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-01-23 10:16:23 -0800
committerGitHub <noreply@github.com>2017-01-23 10:16:23 -0800
commit7b1480db80c8c0f9a539771b579efaaa34a9195f (patch)
treee16cf6c4b49486ae60fe459a75198fc3f06640d4
parentf83fe389de3945d5dd2ed6f3a128b614bbe80ddd (diff)
parent93dd68f682933a825aa2c3c9396d61e93da40b64 (diff)
Auto merge of #411 - fitzgen:js-value-and-js-why-magic, r=emilio
Trace methods in CompInfo's TypeCollector impl Fixes #410 r? @emilio
-rw-r--r--src/ir/comp.rs4
-rw-r--r--src/ir/item.rs7
-rw-r--r--src/ir/ty.rs23
-rw-r--r--tests/expectations/tests/16-byte-alignment.rs (renamed from libbindgen/tests/expectations/tests/16-byte-alignment.rs)0
-rw-r--r--tests/expectations/tests/issue-410.rs41
-rw-r--r--tests/headers/16-byte-alignment.h (renamed from libbindgen/tests/headers/16-byte-alignment.h)0
-rw-r--r--tests/headers/issue-410.hpp12
7 files changed, 79 insertions, 8 deletions
diff --git a/src/ir/comp.rs b/src/ir/comp.rs
index 968bf879..ac68b672 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 df8fd222..ac2d122e 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 c1ed5b64..1e87beb4 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!("<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 => {}
}
}
}
diff --git a/libbindgen/tests/expectations/tests/16-byte-alignment.rs b/tests/expectations/tests/16-byte-alignment.rs
index b28c0537..b28c0537 100644
--- a/libbindgen/tests/expectations/tests/16-byte-alignment.rs
+++ b/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 00000000..a5d94960
--- /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::<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 { }
+}
diff --git a/libbindgen/tests/headers/16-byte-alignment.h b/tests/headers/16-byte-alignment.h
index 7a7f7548..7a7f7548 100644
--- a/libbindgen/tests/headers/16-byte-alignment.h
+++ b/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 00000000..a7a834cf
--- /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);
+};
+}