Skip to content

Commit d4a6648

Browse files
author
bors-servo
authored
Auto merge of #293 - fitzgen:type-referenced-by-whitelisted-function, r=emilio
Trace function signature types This extends the `TypeCollector` trait implementation for `Item` to consider items of kind `Function` and to collect the types found in the function's signature. Fixes #291 r? @emilio
2 parents ec9852a + bd29a7a commit d4a6648

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

libbindgen/src/ir/item.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ impl TypeCollector for Item {
142142
ty.collect_types(ctx, types, self);
143143
}
144144
}
145+
ItemKind::Function(ref fun) => {
146+
if !self.is_opaque(ctx) {
147+
types.insert(fun.signature());
148+
}
149+
}
145150
_ => {} // FIXME.
146151
}
147152
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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 dl_phdr_info {
10+
pub x: ::std::os::raw::c_int,
11+
}
12+
#[test]
13+
fn bindgen_test_layout_dl_phdr_info() {
14+
assert_eq!(::std::mem::size_of::<dl_phdr_info>() , 4usize);
15+
assert_eq!(::std::mem::align_of::<dl_phdr_info>() , 4usize);
16+
}
17+
impl Clone for dl_phdr_info {
18+
fn clone(&self) -> Self { *self }
19+
}
20+
extern "C" {
21+
pub fn dl_iterate_phdr(arg1: *mut dl_phdr_info) -> ::std::os::raw::c_int;
22+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// bindgen-flags: --whitelist-function dl_iterate_phdr
2+
3+
struct dl_phdr_info {
4+
int x;
5+
};
6+
7+
int dl_iterate_phdr(struct dl_phdr_info *);

0 commit comments

Comments
 (0)