Skip to content

Commit 01cb681

Browse files
committed
ir: Trace types across vars.
1 parent b570ce8 commit 01cb681

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed

libbindgen/src/ir/comp.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,10 @@ impl TypeCollector for CompInfo {
971971
types.insert(ty);
972972
}
973973

974+
for &var in self.inner_vars() {
975+
types.insert(var);
976+
}
977+
974978
// FIXME(emilio): Methods, VTable?
975979
}
976980
}

libbindgen/src/ir/item.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ impl TypeCollector for Item {
202202
// be opaque, so we trace across it.
203203
types.insert(fun.signature());
204204
}
205+
ItemKind::Var(ref var) => {
206+
types.insert(var.ty());
207+
}
205208
_ => {} // FIXME.
206209
}
207210
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
4+
#![allow(non_snake_case)]
5+
6+
7+
#[repr(C)]
8+
#[derive(Debug, Copy)]
9+
pub struct Bar {
10+
pub m_baz: ::std::os::raw::c_int,
11+
}
12+
#[test]
13+
fn bindgen_test_layout_Bar() {
14+
assert_eq!(::std::mem::size_of::<Bar>() , 4usize);
15+
assert_eq!(::std::mem::align_of::<Bar>() , 4usize);
16+
}
17+
extern "C" {
18+
#[link_name = "_ZN3BarC1Ei"]
19+
pub fn Bar_Bar(this: *mut Bar, baz: ::std::os::raw::c_int);
20+
}
21+
impl Clone for Bar {
22+
fn clone(&self) -> Self { *self }
23+
}
24+
impl Bar {
25+
#[inline]
26+
pub unsafe fn new(baz: ::std::os::raw::c_int) -> Self {
27+
let mut __bindgen_tmp = ::std::mem::uninitialized();
28+
Bar_Bar(&mut __bindgen_tmp, baz);
29+
__bindgen_tmp
30+
}
31+
}
32+
#[repr(C)]
33+
#[derive(Debug, Copy)]
34+
pub struct Baz {
35+
pub _address: u8,
36+
}
37+
extern "C" {
38+
#[link_name = "_ZN3Baz3FOOE"]
39+
pub static mut Baz_FOO: *const Bar;
40+
}
41+
#[test]
42+
fn bindgen_test_layout_Baz() {
43+
assert_eq!(::std::mem::size_of::<Baz>() , 1usize);
44+
assert_eq!(::std::mem::align_of::<Baz>() , 1usize);
45+
}
46+
impl Clone for Baz {
47+
fn clone(&self) -> Self { *self }
48+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// bindgen-flags: --whitelist-type Baz
2+
3+
struct Bar {
4+
const int m_baz;
5+
Bar(int baz);
6+
};
7+
8+
class Baz {
9+
static const Bar FOO[];
10+
};

0 commit comments

Comments
 (0)