File tree 2 files changed +18
-12
lines changed
2 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -639,11 +639,19 @@ impl Type {
639
639
640
640
/// Given that this type is a pointer type, return the type that it points
641
641
/// to.
642
- pub fn pointee_type ( & self ) -> Type {
643
- unsafe {
644
- Type {
645
- x : clang_getPointeeType ( self . x ) ,
642
+ pub fn pointee_type ( & self ) -> Option < Type > {
643
+ match self . kind ( ) {
644
+ CXType_Pointer |
645
+ CXType_RValueReference |
646
+ CXType_LValueReference |
647
+ CXType_MemberPointer => {
648
+ let ret = Type {
649
+ x : unsafe { clang_getPointeeType ( self . x ) } ,
650
+ } ;
651
+ debug_assert ! ( ret. kind( ) != CXType_Invalid ) ;
652
+ Some ( ret)
646
653
}
654
+ _ => None ,
647
655
}
648
656
}
649
657
Original file line number Diff line number Diff line change @@ -677,21 +677,19 @@ impl Type {
677
677
// process of resolving them.
678
678
CXType_MemberPointer |
679
679
CXType_Pointer => {
680
- let inner = Item :: from_ty_or_ref ( ty. pointee_type ( ) ,
681
- location,
682
- parent_id,
683
- ctx) ;
680
+ let inner =
681
+ Item :: from_ty_or_ref ( ty. pointee_type ( ) . unwrap ( ) , location,
682
+ parent_id, ctx) ;
684
683
TypeKind :: Pointer ( inner)
685
684
}
686
685
CXType_BlockPointer => TypeKind :: BlockPointer ,
687
686
// XXX: RValueReference is most likely wrong, but I don't think we
688
687
// can even add bindings for that, so huh.
689
688
CXType_RValueReference |
690
689
CXType_LValueReference => {
691
- let inner = Item :: from_ty_or_ref ( ty. pointee_type ( ) ,
692
- location,
693
- parent_id,
694
- ctx) ;
690
+ let inner =
691
+ Item :: from_ty_or_ref ( ty. pointee_type ( ) . unwrap ( ) , location,
692
+ parent_id, ctx) ;
695
693
TypeKind :: Reference ( inner)
696
694
}
697
695
// XXX DependentSizedArray is wrong
You can’t perform that action at this time.
0 commit comments