Skip to content

Commit 331ecab

Browse files
committed
ir: Cut the parenthood chain in pointers, references and arrays.
1 parent fc7a5e4 commit 331ecab

File tree

4 files changed

+36
-10
lines changed

4 files changed

+36
-10
lines changed

src/ir/ty.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -1026,9 +1026,7 @@ impl Type {
10261026
CXType_MemberPointer |
10271027
CXType_Pointer => {
10281028
let inner = Item::from_ty_or_ref(ty.pointee_type().unwrap(),
1029-
location,
1030-
parent_id,
1031-
ctx);
1029+
location, None, ctx);
10321030
TypeKind::Pointer(inner)
10331031
}
10341032
CXType_BlockPointer => TypeKind::BlockPointer,
@@ -1038,7 +1036,7 @@ impl Type {
10381036
CXType_LValueReference => {
10391037
let inner = Item::from_ty_or_ref(ty.pointee_type().unwrap(),
10401038
location,
1041-
parent_id,
1039+
None,
10421040
ctx);
10431041
TypeKind::Reference(inner)
10441042
}
@@ -1047,15 +1045,15 @@ impl Type {
10471045
CXType_DependentSizedArray => {
10481046
let inner = Item::from_ty(ty.elem_type().as_ref().unwrap(),
10491047
location,
1050-
parent_id,
1048+
None,
10511049
ctx)
10521050
.expect("Not able to resolve array element?");
10531051
TypeKind::Pointer(inner)
10541052
}
10551053
CXType_IncompleteArray => {
10561054
let inner = Item::from_ty(ty.elem_type().as_ref().unwrap(),
10571055
location,
1058-
parent_id,
1056+
None,
10591057
ctx)
10601058
.expect("Not able to resolve array element?");
10611059
TypeKind::Array(inner, 0)
@@ -1070,7 +1068,7 @@ impl Type {
10701068
CXType_Typedef => {
10711069
let inner = cursor.typedef_type().expect("Not valid Type?");
10721070
let inner =
1073-
Item::from_ty_or_ref(inner, location, parent_id, ctx);
1071+
Item::from_ty_or_ref(inner, location, None, ctx);
10741072
TypeKind::Alias(inner)
10751073
}
10761074
CXType_Enum => {
@@ -1092,7 +1090,7 @@ impl Type {
10921090
CXType_ConstantArray => {
10931091
let inner = Item::from_ty(ty.elem_type().as_ref().unwrap(),
10941092
location,
1095-
parent_id,
1093+
None,
10961094
ctx)
10971095
.expect("Not able to resolve array element?");
10981096
TypeKind::Array(inner, ty.num_elements().unwrap())

tests/expectations/tests/layout_array.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ pub struct malloc_heap {
200200
#[repr(C)]
201201
#[derive(Debug, Copy)]
202202
pub struct malloc_heap__bindgen_ty_1 {
203-
pub lh_first: *mut malloc_heap__bindgen_ty_1_malloc_elem,
203+
pub lh_first: *mut malloc_elem,
204204
}
205205
#[test]
206206
fn bindgen_test_layout_malloc_heap__bindgen_ty_1() {
@@ -255,3 +255,11 @@ impl Clone for malloc_heap {
255255
impl Default for malloc_heap {
256256
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
257257
}
258+
#[repr(C)]
259+
#[derive(Debug, Default, Copy)]
260+
pub struct malloc_elem {
261+
pub _address: u8,
262+
}
263+
impl Clone for malloc_elem {
264+
fn clone(&self) -> Self { *self }
265+
}

tests/expectations/tests/layout_mbuf.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub struct rte_mbuf {
9898
pub cacheline1: MARKER,
9999
pub __bindgen_anon_3: rte_mbuf__bindgen_ty_4,
100100
/**< Pool from which mbuf was allocated. */
101-
pub pool: *mut rte_mbuf_rte_mempool,
101+
pub pool: *mut rte_mempool,
102102
/**< Next segment of scattered packet. */
103103
pub next: *mut rte_mbuf,
104104
pub __bindgen_anon_4: rte_mbuf__bindgen_ty_5,
@@ -731,3 +731,12 @@ impl Clone for rte_mbuf {
731731
impl Default for rte_mbuf {
732732
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
733733
}
734+
/**< Pool from which mbuf was allocated. */
735+
#[repr(C)]
736+
#[derive(Debug, Default, Copy)]
737+
pub struct rte_mempool {
738+
pub _address: u8,
739+
}
740+
impl Clone for rte_mempool {
741+
fn clone(&self) -> Self { *self }
742+
}

tests/expectations/tests/template.rs

+11
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,17 @@ fn __bindgen_test_layout_template_1() {
258258
}
259259
#[test]
260260
fn __bindgen_test_layout_template_2() {
261+
assert_eq!(::std::mem::size_of::<Rooted<*mut ::std::os::raw::c_void>>() ,
262+
24usize , concat ! (
263+
"Size of template specialization: " , stringify ! (
264+
Rooted<*mut ::std::os::raw::c_void> ) ));
265+
assert_eq!(::std::mem::align_of::<Rooted<*mut ::std::os::raw::c_void>>() ,
266+
8usize , concat ! (
267+
"Alignment of template specialization: " , stringify ! (
268+
Rooted<*mut ::std::os::raw::c_void> ) ));
269+
}
270+
#[test]
271+
fn __bindgen_test_layout_template_3() {
261272
assert_eq!(::std::mem::size_of::<WithDtor<::std::os::raw::c_int>>() ,
262273
4usize , concat ! (
263274
"Size of template specialization: " , stringify ! (

0 commit comments

Comments
 (0)