Skip to content

Commit 5591a10

Browse files
committed
Update test expectations for libclang 9.0.
1 parent 601baa2 commit 5591a10

8 files changed

+2329
-7
lines changed

tests/expectations/tests/libclang-9/class.rs

Lines changed: 636 additions & 0 deletions
Large diffs are not rendered by default.

tests/expectations/tests/libclang-9/class_1_0.rs

Lines changed: 694 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
#![allow(
4+
dead_code,
5+
non_snake_case,
6+
non_camel_case_types,
7+
non_upper_case_globals
8+
)]
9+
10+
#[repr(C)]
11+
#[derive(Default)]
12+
pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]);
13+
impl<T> __IncompleteArrayField<T> {
14+
#[inline]
15+
pub const fn new() -> Self {
16+
__IncompleteArrayField(::std::marker::PhantomData, [])
17+
}
18+
#[inline]
19+
pub unsafe fn as_ptr(&self) -> *const T {
20+
::std::mem::transmute(self)
21+
}
22+
#[inline]
23+
pub unsafe fn as_mut_ptr(&mut self) -> *mut T {
24+
::std::mem::transmute(self)
25+
}
26+
#[inline]
27+
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
28+
::std::slice::from_raw_parts(self.as_ptr(), len)
29+
}
30+
#[inline]
31+
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
32+
::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
33+
}
34+
}
35+
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
36+
fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
37+
fmt.write_str("__IncompleteArrayField")
38+
}
39+
}
40+
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
41+
#[inline]
42+
fn clone(&self) -> Self {
43+
Self::new()
44+
}
45+
}
46+
#[repr(C)]
47+
#[derive(Debug, Default)]
48+
pub struct test {
49+
pub a: ::std::os::raw::c_int,
50+
pub zero_length_array: __IncompleteArrayField<::std::os::raw::c_char>,
51+
}
52+
#[test]
53+
fn bindgen_test_layout_test() {
54+
assert_eq!(
55+
::std::mem::size_of::<test>(),
56+
4usize,
57+
concat!("Size of: ", stringify!(test))
58+
);
59+
assert_eq!(
60+
::std::mem::align_of::<test>(),
61+
4usize,
62+
concat!("Alignment of ", stringify!(test))
63+
);
64+
assert_eq!(
65+
unsafe { &(*(::std::ptr::null::<test>())).a as *const _ as usize },
66+
0usize,
67+
concat!("Offset of field: ", stringify!(test), "::", stringify!(a))
68+
);
69+
assert_eq!(
70+
unsafe { &(*(::std::ptr::null::<test>())).zero_length_array as *const _ as usize },
71+
4usize,
72+
concat!(
73+
"Offset of field: ",
74+
stringify!(test),
75+
"::",
76+
stringify!(zero_length_array)
77+
)
78+
);
79+
}
80+
#[repr(C)]
81+
#[derive(Debug, Default)]
82+
pub struct test2 {
83+
pub a: ::std::os::raw::c_int,
84+
pub incomplete_array: __IncompleteArrayField<::std::os::raw::c_char>,
85+
}
86+
#[test]
87+
fn bindgen_test_layout_test2() {
88+
assert_eq!(
89+
::std::mem::size_of::<test2>(),
90+
4usize,
91+
concat!("Size of: ", stringify!(test2))
92+
);
93+
assert_eq!(
94+
::std::mem::align_of::<test2>(),
95+
4usize,
96+
concat!("Alignment of ", stringify!(test2))
97+
);
98+
assert_eq!(
99+
unsafe { &(*(::std::ptr::null::<test2>())).a as *const _ as usize },
100+
0usize,
101+
concat!("Offset of field: ", stringify!(test2), "::", stringify!(a))
102+
);
103+
assert_eq!(
104+
unsafe { &(*(::std::ptr::null::<test2>())).incomplete_array as *const _ as usize },
105+
4usize,
106+
concat!(
107+
"Offset of field: ",
108+
stringify!(test2),
109+
"::",
110+
stringify!(incomplete_array)
111+
)
112+
);
113+
}
114+
#[repr(C)]
115+
#[derive(Debug, Default)]
116+
pub struct test3 {
117+
pub a: ::std::os::raw::c_int,
118+
pub zero_length_array: __IncompleteArrayField<::std::os::raw::c_char>,
119+
pub incomplete_array: __IncompleteArrayField<::std::os::raw::c_char>,
120+
}
121+
#[test]
122+
fn bindgen_test_layout_test3() {
123+
assert_eq!(
124+
::std::mem::size_of::<test3>(),
125+
4usize,
126+
concat!("Size of: ", stringify!(test3))
127+
);
128+
assert_eq!(
129+
::std::mem::align_of::<test3>(),
130+
4usize,
131+
concat!("Alignment of ", stringify!(test3))
132+
);
133+
assert_eq!(
134+
unsafe { &(*(::std::ptr::null::<test3>())).a as *const _ as usize },
135+
0usize,
136+
concat!("Offset of field: ", stringify!(test3), "::", stringify!(a))
137+
);
138+
assert_eq!(
139+
unsafe { &(*(::std::ptr::null::<test3>())).zero_length_array as *const _ as usize },
140+
4usize,
141+
concat!(
142+
"Offset of field: ",
143+
stringify!(test3),
144+
"::",
145+
stringify!(zero_length_array)
146+
)
147+
);
148+
assert_eq!(
149+
unsafe { &(*(::std::ptr::null::<test3>())).incomplete_array as *const _ as usize },
150+
4usize,
151+
concat!(
152+
"Offset of field: ",
153+
stringify!(test3),
154+
"::",
155+
stringify!(incomplete_array)
156+
)
157+
);
158+
}
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
#![allow(
4+
dead_code,
5+
non_snake_case,
6+
non_camel_case_types,
7+
non_upper_case_globals
8+
)]
9+
10+
#[repr(C)]
11+
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
12+
pub struct __BindgenBitfieldUnit<Storage, Align> {
13+
storage: Storage,
14+
align: [Align; 0],
15+
}
16+
impl<Storage, Align> __BindgenBitfieldUnit<Storage, Align> {
17+
#[inline]
18+
pub const fn new(storage: Storage) -> Self {
19+
Self { storage, align: [] }
20+
}
21+
}
22+
impl<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
23+
where
24+
Storage: AsRef<[u8]> + AsMut<[u8]>,
25+
{
26+
#[inline]
27+
pub fn get_bit(&self, index: usize) -> bool {
28+
debug_assert!(index / 8 < self.storage.as_ref().len());
29+
let byte_index = index / 8;
30+
let byte = self.storage.as_ref()[byte_index];
31+
let bit_index = if cfg!(target_endian = "big") {
32+
7 - (index % 8)
33+
} else {
34+
index % 8
35+
};
36+
let mask = 1 << bit_index;
37+
byte & mask == mask
38+
}
39+
#[inline]
40+
pub fn set_bit(&mut self, index: usize, val: bool) {
41+
debug_assert!(index / 8 < self.storage.as_ref().len());
42+
let byte_index = index / 8;
43+
let byte = &mut self.storage.as_mut()[byte_index];
44+
let bit_index = if cfg!(target_endian = "big") {
45+
7 - (index % 8)
46+
} else {
47+
index % 8
48+
};
49+
let mask = 1 << bit_index;
50+
if val {
51+
*byte |= mask;
52+
} else {
53+
*byte &= !mask;
54+
}
55+
}
56+
#[inline]
57+
pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 {
58+
debug_assert!(bit_width <= 64);
59+
debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
60+
debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len());
61+
let mut val = 0;
62+
for i in 0..(bit_width as usize) {
63+
if self.get_bit(i + bit_offset) {
64+
let index = if cfg!(target_endian = "big") {
65+
bit_width as usize - 1 - i
66+
} else {
67+
i
68+
};
69+
val |= 1 << index;
70+
}
71+
}
72+
val
73+
}
74+
#[inline]
75+
pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) {
76+
debug_assert!(bit_width <= 64);
77+
debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
78+
debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len());
79+
for i in 0..(bit_width as usize) {
80+
let mask = 1 << i;
81+
let val_bit_is_set = val & mask == mask;
82+
let index = if cfg!(target_endian = "big") {
83+
bit_width as usize - 1 - i
84+
} else {
85+
i
86+
};
87+
self.set_bit(index + bit_offset, val_bit_is_set);
88+
}
89+
}
90+
}
91+
#[repr(C)]
92+
#[derive(Default)]
93+
pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]);
94+
impl<T> __IncompleteArrayField<T> {
95+
#[inline]
96+
pub const fn new() -> Self {
97+
__IncompleteArrayField(::std::marker::PhantomData, [])
98+
}
99+
#[inline]
100+
pub unsafe fn as_ptr(&self) -> *const T {
101+
::std::mem::transmute(self)
102+
}
103+
#[inline]
104+
pub unsafe fn as_mut_ptr(&mut self) -> *mut T {
105+
::std::mem::transmute(self)
106+
}
107+
#[inline]
108+
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
109+
::std::slice::from_raw_parts(self.as_ptr(), len)
110+
}
111+
#[inline]
112+
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
113+
::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
114+
}
115+
}
116+
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
117+
fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
118+
fmt.write_str("__IncompleteArrayField")
119+
}
120+
}
121+
impl<T> ::std::clone::Clone for __IncompleteArrayField<T> {
122+
#[inline]
123+
fn clone(&self) -> Self {
124+
Self::new()
125+
}
126+
}
127+
#[repr(C)]
128+
#[derive(Debug)]
129+
pub struct foo {
130+
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>,
131+
pub b: __IncompleteArrayField<*mut ::std::os::raw::c_void>,
132+
}
133+
#[test]
134+
fn bindgen_test_layout_foo() {
135+
assert_eq!(
136+
::std::mem::size_of::<foo>(),
137+
8usize,
138+
concat!("Size of: ", stringify!(foo))
139+
);
140+
assert_eq!(
141+
::std::mem::align_of::<foo>(),
142+
8usize,
143+
concat!("Alignment of ", stringify!(foo))
144+
);
145+
assert_eq!(
146+
unsafe { &(*(::std::ptr::null::<foo>())).b as *const _ as usize },
147+
8usize,
148+
concat!("Offset of field: ", stringify!(foo), "::", stringify!(b))
149+
);
150+
}
151+
impl Default for foo {
152+
fn default() -> Self {
153+
unsafe { ::std::mem::zeroed() }
154+
}
155+
}
156+
impl foo {
157+
#[inline]
158+
pub fn a(&self) -> ::std::os::raw::c_char {
159+
unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) }
160+
}
161+
#[inline]
162+
pub fn set_a(&mut self, val: ::std::os::raw::c_char) {
163+
unsafe {
164+
let val: u8 = ::std::mem::transmute(val);
165+
self._bitfield_1.set(0usize, 1u8, val as u64)
166+
}
167+
}
168+
#[inline]
169+
pub fn new_bitfield_1(a: ::std::os::raw::c_char) -> __BindgenBitfieldUnit<[u8; 1usize], u8> {
170+
let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> =
171+
Default::default();
172+
__bindgen_bitfield_unit.set(0usize, 1u8, {
173+
let a: u8 = unsafe { ::std::mem::transmute(a) };
174+
a as u64
175+
});
176+
__bindgen_bitfield_unit
177+
}
178+
}

0 commit comments

Comments
 (0)