Skip to content

Commit aa04308

Browse files
committed
Tidy up handling of char
1 parent 1d3d17f commit aa04308

File tree

1 file changed

+4
-32
lines changed

1 file changed

+4
-32
lines changed

src/ir/context.rs

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,38 +1090,10 @@ impl<'ctx> BindgenContext<'ctx> {
10901090
CXType_Bool => TypeKind::Int(IntKind::Bool),
10911091
CXType_Int => TypeKind::Int(IntKind::Int),
10921092
CXType_UInt => TypeKind::Int(IntKind::UInt),
1093-
CXType_SChar | CXType_Char_S |
1094-
CXType_UChar | CXType_Char_U => {
1095-
let spelling = ty.spelling();
1096-
1097-
debug_assert!(spelling.contains("char"),
1098-
"This is the canonical type, so no aliases or \
1099-
typedefs!");
1100-
1101-
let signed = match ty.kind() {
1102-
CXType_SChar | CXType_Char_S => true,
1103-
_ => false,
1104-
};
1105-
1106-
// Clang only gives us the signedness of the target platform.
1107-
//
1108-
// Match the spelling for common cases we can handle
1109-
// cross-platform.
1110-
match &*spelling {
1111-
"char" | "const char" => {
1112-
TypeKind::Int(IntKind::Char {
1113-
is_signed: signed,
1114-
})
1115-
},
1116-
_ => {
1117-
if signed {
1118-
TypeKind::Int(IntKind::SChar)
1119-
} else {
1120-
TypeKind::Int(IntKind::UChar)
1121-
}
1122-
},
1123-
}
1124-
}
1093+
CXType_Char_S => TypeKind::Int(IntKind::Char { is_signed: true }),
1094+
CXType_Char_U => TypeKind::Int(IntKind::Char { is_signed: false }),
1095+
CXType_SChar => TypeKind::Int(IntKind::SChar),
1096+
CXType_UChar => TypeKind::Int(IntKind::UChar),
11251097
CXType_Short => TypeKind::Int(IntKind::Short),
11261098
CXType_UShort => TypeKind::Int(IntKind::UShort),
11271099
CXType_WChar | CXType_Char16 => TypeKind::Int(IntKind::U16),

0 commit comments

Comments
 (0)