diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/clang.rs | 16 | ||||
-rw-r--r-- | src/ir/ty.rs | 14 |
2 files changed, 18 insertions, 12 deletions
diff --git a/src/clang.rs b/src/clang.rs index b335a585..11fe51d0 100755 --- a/src/clang.rs +++ b/src/clang.rs @@ -647,11 +647,19 @@ impl Type { /// Given that this type is a pointer type, return the type that it points /// to. - pub fn pointee_type(&self) -> Type { - unsafe { - Type { - x: clang_getPointeeType(self.x), + pub fn pointee_type(&self) -> Option<Type> { + match self.kind() { + CXType_Pointer | + CXType_RValueReference | + CXType_LValueReference | + CXType_MemberPointer => { + let ret = Type { + x: unsafe { clang_getPointeeType(self.x) }, + }; + debug_assert!(ret.kind() != CXType_Invalid); + Some(ret) } + _ => None, } } diff --git a/src/ir/ty.rs b/src/ir/ty.rs index 81212029..be749268 100644 --- a/src/ir/ty.rs +++ b/src/ir/ty.rs @@ -677,10 +677,9 @@ impl Type { // process of resolving them. CXType_MemberPointer | CXType_Pointer => { - let inner = Item::from_ty_or_ref(ty.pointee_type(), - location, - parent_id, - ctx); + let inner = + Item::from_ty_or_ref(ty.pointee_type().unwrap(), location, + parent_id, ctx); TypeKind::Pointer(inner) } CXType_BlockPointer => TypeKind::BlockPointer, @@ -688,10 +687,9 @@ impl Type { // can even add bindings for that, so huh. CXType_RValueReference | CXType_LValueReference => { - let inner = Item::from_ty_or_ref(ty.pointee_type(), - location, - parent_id, - ctx); + let inner = + Item::from_ty_or_ref(ty.pointee_type().unwrap(), location, + parent_id, ctx); TypeKind::Reference(inner) } // XXX DependentSizedArray is wrong |