diff options
-rw-r--r-- | libbindgen/src/clang.rs | 7 | ||||
-rw-r--r-- | libbindgen/src/ir/enum_ty.rs | 5 |
2 files changed, 7 insertions, 5 deletions
diff --git a/libbindgen/src/clang.rs b/libbindgen/src/clang.rs index a11903aa..72069644 100644 --- a/libbindgen/src/clang.rs +++ b/libbindgen/src/clang.rs @@ -362,11 +362,12 @@ impl Cursor { /// Get the integer representation type used to hold this cursor's referent /// enum type. - pub fn enum_type(&self) -> Type { + pub fn enum_type(&self) -> Option<Type> { unsafe { - Type { + let t = Type { x: clang_getEnumDeclIntegerType(self.x), - } + }; + if t.is_valid() { Some(t) } else { None } } } diff --git a/libbindgen/src/ir/enum_ty.rs b/libbindgen/src/ir/enum_ty.rs index 6085833d..f728b22a 100644 --- a/libbindgen/src/ir/enum_ty.rs +++ b/libbindgen/src/ir/enum_ty.rs @@ -49,8 +49,9 @@ impl Enum { } let declaration = ty.declaration().canonical(); - let repr = Item::from_ty(&declaration.enum_type(), None, None, ctx) - .ok(); + let repr = declaration.enum_type().and_then(|et| { + Item::from_ty(&et, None, None, ctx).ok() + }); let mut variants = vec![]; let is_signed = match repr { |