Skip to content

Commit

Permalink
ir: Don't crash with built-in unexposed types from libclang.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
emilio committed Nov 9, 2022
1 parent 0631a27 commit c03b376
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions bindgen/ir/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1145,8 +1145,7 @@ impl Type {
location,
None,
ctx,
)
.expect("Not able to resolve vector element?");
)?;
TypeKind::Vector(inner, ty.num_elements().unwrap())
}
CXType_ConstantArray => {
Expand Down
8 changes: 4 additions & 4 deletions bindgen/ir/var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,11 @@ impl ClangSubItemParser for Var {
let ty = match Item::from_ty(&ty, cursor, None, ctx) {
Ok(ty) => ty,
Err(e) => {
assert_eq!(
ty.kind(),
CXType_Auto,
assert!(
matches!(ty.kind(), CXType_Auto | CXType_Unexposed),
"Couldn't resolve constant type, and it \
wasn't an nondeductible auto type!"
wasn't an nondeductible auto type or unexposed \
type!"
);
return Err(e);
}
Expand Down

0 comments on commit c03b376

Please sign in to comment.