Skip to content

Commit 984b44f

Browse files
committed
clang: Fix most of the clang 5.0 regressions in our tests.
Still a lot to be sorted out though.
1 parent 1781776 commit 984b44f

File tree

2 files changed

+30
-34
lines changed

2 files changed

+30
-34
lines changed

src/clang.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,14 @@ impl Type {
729729

730730
/// Get a raw display name for this type.
731731
pub fn spelling(&self) -> String {
732-
unsafe { cxstring_into_string(clang_getTypeSpelling(self.x)) }
732+
let s = unsafe { cxstring_into_string(clang_getTypeSpelling(self.x)) };
733+
// Clang 5.0 introduced changes in the spelling API so it returned the
734+
// full qualified name. Let's undo that here.
735+
if let Some(s) = s.split("::").last() {
736+
return s.to_owned();
737+
}
738+
739+
s
733740
}
734741

735742
/// Is this type const qualified?

tests/expectations/tests/struct_typedef_ns.rs

+22-33
Original file line numberDiff line numberDiff line change
@@ -13,68 +13,57 @@ pub mod root {
1313
use self::super::super::root;
1414
#[repr(C)]
1515
#[derive(Debug, Default, Copy)]
16-
pub struct _bindgen_ty_1 {
16+
pub struct typedef_struct {
1717
pub foo: ::std::os::raw::c_int,
1818
}
1919
#[test]
20-
fn bindgen_test_layout__bindgen_ty_1() {
21-
assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 4usize ,
22-
concat ! ( "Size of: " , stringify ! ( _bindgen_ty_1 )
20+
fn bindgen_test_layout_typedef_struct() {
21+
assert_eq!(::std::mem::size_of::<typedef_struct>() , 4usize ,
22+
concat ! ( "Size of: " , stringify ! ( typedef_struct )
2323
));
24-
assert_eq! (::std::mem::align_of::<_bindgen_ty_1>() , 4usize ,
24+
assert_eq! (::std::mem::align_of::<typedef_struct>() , 4usize ,
2525
concat ! (
26-
"Alignment of " , stringify ! ( _bindgen_ty_1 ) ));
26+
"Alignment of " , stringify ! ( typedef_struct ) ));
2727
assert_eq! (unsafe {
28-
& ( * ( 0 as * const _bindgen_ty_1 ) ) . foo as *
28+
& ( * ( 0 as * const typedef_struct ) ) . foo as *
2929
const _ as usize } , 0usize , concat ! (
30-
"Alignment of field: " , stringify ! ( _bindgen_ty_1 )
31-
, "::" , stringify ! ( foo ) ));
30+
"Alignment of field: " , stringify ! ( typedef_struct
31+
) , "::" , stringify ! ( foo ) ));
3232
}
33-
impl Clone for _bindgen_ty_1 {
33+
impl Clone for typedef_struct {
3434
fn clone(&self) -> Self { *self }
3535
}
36-
pub type typedef_struct = root::whatever::_bindgen_ty_1;
37-
pub const whatever_BAR: root::whatever::_bindgen_ty_2 =
38-
_bindgen_ty_2::BAR;
3936
#[repr(u32)]
4037
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
41-
pub enum _bindgen_ty_2 { BAR = 1, }
42-
pub use self::super::super::root::whatever::_bindgen_ty_2 as
43-
typedef_enum;
38+
pub enum typedef_enum { BAR = 1, }
4439
}
4540
pub mod _bindgen_mod_id_12 {
4641
#[allow(unused_imports)]
4742
use self::super::super::root;
4843
#[repr(C)]
4944
#[derive(Debug, Default, Copy)]
50-
pub struct _bindgen_ty_1 {
45+
pub struct typedef_struct {
5146
pub foo: ::std::os::raw::c_int,
5247
}
5348
#[test]
54-
fn bindgen_test_layout__bindgen_ty_1() {
55-
assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 4usize ,
56-
concat ! ( "Size of: " , stringify ! ( _bindgen_ty_1 )
49+
fn bindgen_test_layout_typedef_struct() {
50+
assert_eq!(::std::mem::size_of::<typedef_struct>() , 4usize ,
51+
concat ! ( "Size of: " , stringify ! ( typedef_struct )
5752
));
58-
assert_eq! (::std::mem::align_of::<_bindgen_ty_1>() , 4usize ,
53+
assert_eq! (::std::mem::align_of::<typedef_struct>() , 4usize ,
5954
concat ! (
60-
"Alignment of " , stringify ! ( _bindgen_ty_1 ) ));
55+
"Alignment of " , stringify ! ( typedef_struct ) ));
6156
assert_eq! (unsafe {
62-
& ( * ( 0 as * const _bindgen_ty_1 ) ) . foo as *
57+
& ( * ( 0 as * const typedef_struct ) ) . foo as *
6358
const _ as usize } , 0usize , concat ! (
64-
"Alignment of field: " , stringify ! ( _bindgen_ty_1 )
65-
, "::" , stringify ! ( foo ) ));
59+
"Alignment of field: " , stringify ! ( typedef_struct
60+
) , "::" , stringify ! ( foo ) ));
6661
}
67-
impl Clone for _bindgen_ty_1 {
62+
impl Clone for typedef_struct {
6863
fn clone(&self) -> Self { *self }
6964
}
70-
pub type typedef_struct = root::_bindgen_mod_id_12::_bindgen_ty_1;
71-
pub const _bindgen_mod_id_12_BAR:
72-
root::_bindgen_mod_id_12::_bindgen_ty_2 =
73-
_bindgen_ty_2::BAR;
7465
#[repr(u32)]
7566
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
76-
pub enum _bindgen_ty_2 { BAR = 1, }
77-
pub use self::super::super::root::_bindgen_mod_id_12::_bindgen_ty_2 as
78-
typedef_enum;
67+
pub enum typedef_enum { BAR = 1, }
7968
}
8069
}

0 commit comments

Comments
 (0)