diff options
Diffstat (limited to 'src/clang.rs')
-rwxr-xr-x | src/clang.rs | 16 |
1 files changed, 12 insertions, 4 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, } } |