diff options
-rwxr-xr-x | src/clang.rs | 25 | ||||
-rw-r--r-- | src/ir/ty.rs | 14 |
2 files changed, 19 insertions, 20 deletions
diff --git a/src/clang.rs b/src/clang.rs index 94e74d87..bfe0cfd3 100755 --- a/src/clang.rs +++ b/src/clang.rs @@ -10,7 +10,7 @@ use std::ffi::{CStr, CString}; use std::fmt; use std::hash::Hash; use std::hash::Hasher; -use std::os::raw::{c_char, c_int, c_longlong, c_uint, c_ulong}; +use std::os::raw::{c_char, c_int, c_uint, c_ulong}; /// A cursor into the Clang AST, pointing to an AST node. /// @@ -453,13 +453,6 @@ impl Cursor { pub fn template_arg_kind(&self, i: c_int) -> CXTemplateArgumentKind { unsafe { clang_Cursor_getTemplateArgumentKind(self.x, i as c_uint) } } - - /// Given that this cursor's referent is a template specialization, and that - /// the `i`th template argument is an integral, get the `i`th template - /// argument value. - pub fn template_arg_value(&self, i: c_int) -> c_longlong { - unsafe { clang_Cursor_getTemplateArgumentValue(self.x, i as c_uint) } - } } extern "C" fn visit_children<Visitor>(cur: CXCursor, @@ -639,11 +632,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 |