File tree 4 files changed +35
-3
lines changed
4 files changed +35
-3
lines changed Original file line number Diff line number Diff line change 6
6
7
7
use cexpr;
8
8
use clang_sys:: * ;
9
+ use regex;
9
10
use std:: { mem, ptr, slice} ;
10
11
use std:: ffi:: { CStr , CString } ;
11
12
use std:: fmt;
@@ -913,6 +914,30 @@ impl Type {
913
914
_ => true ,
914
915
}
915
916
}
917
+
918
+ /// Is this type an associated template type? Eg `T::Associated` in
919
+ /// this example:
920
+ ///
921
+ /// ```c++
922
+ /// template <typename T>
923
+ /// class Foo {
924
+ /// typename T::Associated member;
925
+ /// };
926
+ /// ```
927
+ pub fn is_associated_type ( & self ) -> bool {
928
+ // This is terrible :(
929
+ fn hacky_parse_associated_type < S : AsRef < str > > ( spelling : S ) -> bool {
930
+ lazy_static ! {
931
+ static ref ASSOC_TYPE_RE : regex:: Regex =
932
+ regex:: Regex :: new( r"typename type\-parameter\-\d+\-\d+::.+" ) . unwrap( ) ;
933
+ }
934
+ ASSOC_TYPE_RE . is_match ( spelling. as_ref ( ) )
935
+ }
936
+
937
+ self . kind ( ) == CXType_Unexposed &&
938
+ ( hacky_parse_associated_type ( self . spelling ( ) ) ||
939
+ hacky_parse_associated_type ( self . canonical_type ( ) . spelling ( ) ) )
940
+ }
916
941
}
917
942
918
943
/// The `CanonicalTypeDeclaration` type exists as proof-by-construction that its
Original file line number Diff line number Diff line change @@ -552,6 +552,7 @@ impl CompInfo {
552
552
}
553
553
CXCursor_EnumDecl |
554
554
CXCursor_TypeAliasDecl |
555
+ CXCursor_TypeAliasTemplateDecl |
555
556
CXCursor_TypedefDecl |
556
557
CXCursor_StructDecl |
557
558
CXCursor_UnionDecl |
@@ -713,7 +714,7 @@ impl CompInfo {
713
714
_ => {
714
715
warn ! ( "unhandled comp member `{}` (kind {:?}) in `{}` ({})" ,
715
716
cur. spelling( ) ,
716
- cur. kind( ) ,
717
+ clang :: kind_to_str ( cur. kind( ) ) ,
717
718
cursor. spelling( ) ,
718
719
cur. location( ) ) ;
719
720
}
Original file line number Diff line number Diff line change @@ -1111,6 +1111,11 @@ impl ClangItemParser for Item {
1111
1111
1112
1112
if ty. kind ( ) == clang_sys:: CXType_Unexposed ||
1113
1113
location. cur_type ( ) . kind ( ) == clang_sys:: CXType_Unexposed {
1114
+
1115
+ if ty. is_associated_type ( ) || location. cur_type ( ) . is_associated_type ( ) {
1116
+ return Ok ( Item :: new_opaque_type ( id, ty, ctx) ) ;
1117
+ }
1118
+
1114
1119
if let Some ( id) = Item :: named_type ( Some ( id) , location, ctx) {
1115
1120
return Ok ( id) ;
1116
1121
}
Original file line number Diff line number Diff line change 5
5
6
6
7
7
#[ repr( C ) ]
8
- #[ derive( Debug , Copy , Clone ) ]
9
8
pub struct Foo {
10
- pub member : Foo ,
9
+ pub member : Foo_SecondAlias ,
11
10
}
11
+ pub type Foo_FirstAlias = [ u8 ; 0usize ] ;
12
+ pub type Foo_SecondAlias = [ u8 ; 0usize ] ;
12
13
impl Default for Foo {
13
14
fn default ( ) -> Self { unsafe { :: std:: mem:: zeroed ( ) } }
14
15
}
You can’t perform that action at this time.
0 commit comments