Skip to content

Commit c03b376

Browse files
committed
ir: Don't crash with built-in unexposed types from libclang.
This fixes #2325. The issue is that `__bf16` is not exposed at all by libclang, which causes us to crash. It's a bit of a shame libclang doesn't expose it but there's no rust equivalent I think, so this should be ok for now. Unfortunately no test because the header crashes older clang versions.
1 parent 0631a27 commit c03b376

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

bindgen/ir/ty.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,8 +1145,7 @@ impl Type {
11451145
location,
11461146
None,
11471147
ctx,
1148-
)
1149-
.expect("Not able to resolve vector element?");
1148+
)?;
11501149
TypeKind::Vector(inner, ty.num_elements().unwrap())
11511150
}
11521151
CXType_ConstantArray => {

bindgen/ir/var.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,11 @@ impl ClangSubItemParser for Var {
293293
let ty = match Item::from_ty(&ty, cursor, None, ctx) {
294294
Ok(ty) => ty,
295295
Err(e) => {
296-
assert_eq!(
297-
ty.kind(),
298-
CXType_Auto,
296+
assert!(
297+
matches!(ty.kind(), CXType_Auto | CXType_Unexposed),
299298
"Couldn't resolve constant type, and it \
300-
wasn't an nondeductible auto type!"
299+
wasn't an nondeductible auto type or unexposed \
300+
type!"
301301
);
302302
return Err(e);
303303
}

0 commit comments

Comments
 (0)