File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ impl Cursor {
56
56
}
57
57
58
58
pub fn mangling ( & self ) -> String {
59
- unsafe {
59
+ unsafe {
60
60
String_ { x : clang_Cursor_getMangling ( self . x ) } . to_string ( )
61
61
}
62
62
}
@@ -136,6 +136,19 @@ impl Cursor {
136
136
self . specialized ( ) . is_valid ( )
137
137
}
138
138
139
+ pub fn is_fully_specialized_template ( & self ) -> bool {
140
+ self . is_template ( ) && self . num_template_args ( ) > 0
141
+ }
142
+
143
+ pub fn is_in_non_fully_specialized_template ( & self ) -> bool {
144
+ if self . is_toplevel ( ) {
145
+ return false ;
146
+ }
147
+ let parent = self . semantic_parent ( ) ;
148
+ ( parent. is_template ( ) && !parent. is_fully_specialized_template ( ) ) ||
149
+ parent. is_in_non_fully_specialized_template ( )
150
+ }
151
+
139
152
pub fn is_valid ( & self ) -> bool {
140
153
unsafe {
141
154
clang_isInvalid ( self . kind ( ) ) == 0
Original file line number Diff line number Diff line change @@ -75,6 +75,13 @@ fn get_abi(cc: Enum_CXCallingConv) -> abi::Abi {
75
75
}
76
76
77
77
pub fn cursor_mangling ( cursor : & clang:: Cursor ) -> Option < String > {
78
+ // We early return here because libclang may crash in some case
79
+ // if we pass in a variable inside a partial specialized template.
80
+ // See servo/rust-bindgen#67.
81
+ if cursor. is_in_non_fully_specialized_template ( ) {
82
+ return None ;
83
+ }
84
+
78
85
let mut mangling = cursor. mangling ( ) ;
79
86
80
87
// Try to undo backend linkage munging (prepended _, generally)
You can’t perform that action at this time.
0 commit comments