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 @@ -647,11 +647,19 @@ impl Type {
647
647
648
648
/// Given that this type is a pointer type, return the type that it points
649
649
/// to.
650
- pub fn pointee_type ( & self ) -> Type {
651
- unsafe {
652
- Type {
653
- x : clang_getPointeeType ( self . x ) ,
650
+ pub fn pointee_type ( & self ) -> Option < Type > {
651
+ match self . kind ( ) {
652
+ CXType_Pointer |
653
+ CXType_RValueReference |
654
+ CXType_LValueReference |
655
+ CXType_MemberPointer => {
656
+ let ret = Type {
657
+ x : unsafe { clang_getPointeeType ( self . x ) } ,
658
+ } ;
659
+ debug_assert ! ( ret. kind( ) != CXType_Invalid ) ;
660
+ Some ( ret)
654
661
}
662
+ _ => None ,
655
663
}
656
664
}
657
665
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