File tree 2 files changed +8
-8
lines changed 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -402,12 +402,12 @@ impl Cursor {
402
402
403
403
/// Given that this cursor's referent is a `typedef`, get the `Type` that is
404
404
/// being aliased.
405
- pub fn typedef_type ( & self ) -> Type {
406
- unsafe {
407
- Type {
408
- x : clang_getTypedefDeclUnderlyingType ( self . x ) ,
409
- }
410
- }
405
+ pub fn typedef_type ( & self ) -> Option < Type > {
406
+ let inner = Type {
407
+ x : unsafe { clang_getTypedefDeclUnderlyingType ( self . x ) }
408
+ } ;
409
+
410
+ if inner . is_valid ( ) { Some ( inner ) } else { None }
411
411
}
412
412
413
413
/// Get the linkage kind for this cursor's referent.
Original file line number Diff line number Diff line change @@ -660,7 +660,7 @@ impl Type {
660
660
661
661
name = current. spelling ( ) ;
662
662
663
- let inner_ty = cur. typedef_type ( ) ;
663
+ let inner_ty = cur. typedef_type ( ) . expect ( "Not valid Type?" ) ;
664
664
inner = Item :: from_ty (
665
665
& inner_ty,
666
666
Some ( cur) ,
@@ -825,7 +825,7 @@ impl Type {
825
825
TypeKind :: Function ( signature)
826
826
}
827
827
CXType_Typedef => {
828
- let inner = cursor. typedef_type ( ) ;
828
+ let inner = cursor. typedef_type ( ) . expect ( "Not valid Type?" ) ;
829
829
let inner =
830
830
Item :: from_ty_or_ref ( inner, location, parent_id, ctx) ;
831
831
TypeKind :: Alias ( ty. spelling ( ) , inner)
You can’t perform that action at this time.
0 commit comments