summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ir/context.rs6
-rw-r--r--src/ir/item.rs9
-rw-r--r--src/ir/ty.rs14
3 files changed, 21 insertions, 8 deletions
diff --git a/src/ir/context.rs b/src/ir/context.rs
index fe079ef0..32ee5bd0 100644
--- a/src/ir/context.rs
+++ b/src/ir/context.rs
@@ -424,7 +424,11 @@ impl<'ctx> BindgenContext<'ctx> {
for (id, ty, loc, parent_id) in typerefs {
let _resolved = {
let resolved = Item::from_ty(&ty, loc, parent_id, self)
- .expect("What happened?");
+ .unwrap_or_else(|_| {
+ warn!("Could not resolve type reference, falling back \
+ to opaque blob");
+ Item::new_opaque_type(self.next_item_id(), &ty, self)
+ });
let mut item = self.items.get_mut(&id).unwrap();
*item.kind_mut().as_type_mut().unwrap().kind_mut() =
diff --git a/src/ir/item.rs b/src/ir/item.rs
index 89422e87..5477dee9 100644
--- a/src/ir/item.rs
+++ b/src/ir/item.rs
@@ -433,10 +433,11 @@ impl Item {
}
}
- fn new_opaque_type(with_id: ItemId,
- ty: &clang::Type,
- ctx: &mut BindgenContext)
- -> ItemId {
+ /// Construct a new opaque item type.
+ pub fn new_opaque_type(with_id: ItemId,
+ ty: &clang::Type,
+ ctx: &mut BindgenContext)
+ -> ItemId {
let ty = Opaque::from_clang_ty(ty);
let kind = ItemKind::Type(ty);
let parent = ctx.root_module();
diff --git a/src/ir/ty.rs b/src/ir/ty.rs
index 60d750ed..594e4c03 100644
--- a/src/ir/ty.rs
+++ b/src/ir/ty.rs
@@ -1096,9 +1096,17 @@ impl Type {
let complex = CompInfo::from_ty(potential_id,
ty,
Some(location),
- ctx)
- .expect("C'mon");
- TypeKind::Comp(complex)
+ ctx);
+ match complex {
+ Ok(complex) => TypeKind::Comp(complex),
+ Err(_) => {
+ warn!("Could not create complex type \
+ from class template or base \
+ specifier, using opaque blob");
+ let opaque = Opaque::from_clang_ty(ty);
+ return Ok(ParseResult::New(opaque, None));
+ }
+ }
}
CXCursor_TypeAliasTemplateDecl => {
debug!("TypeAliasTemplateDecl");