File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -911,6 +911,13 @@ impl Type {
911
911
/// Get the number of template arguments this type has, or `None` if it is
912
912
/// not some kind of template.
913
913
pub fn num_template_args ( & self ) -> Option < u32 > {
914
+ // If an old libclang is loaded, we have no hope of answering this
915
+ // question correctly. However, that's no reason to panic when
916
+ // generating bindings for simple C headers with an old libclang.
917
+ if !clang_Type_getNumTemplateArguments:: is_loaded ( ) {
918
+ return None
919
+ }
920
+
914
921
let n = unsafe { clang_Type_getNumTemplateArguments ( self . x ) } ;
915
922
if n >= 0 {
916
923
Some ( n as u32 )
@@ -1639,8 +1646,11 @@ pub fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
1639
1646
depth,
1640
1647
format ! ( " {}spelling = \" {}\" " , prefix, ty. spelling( ) ) ,
1641
1648
) ;
1642
- let num_template_args =
1643
- unsafe { clang_Type_getNumTemplateArguments ( ty. x ) } ;
1649
+ let num_template_args = if clang_Type_getNumTemplateArguments:: is_loaded ( ) {
1650
+ unsafe { clang_Type_getNumTemplateArguments ( ty. x ) }
1651
+ } else {
1652
+ -1
1653
+ } ;
1644
1654
if num_template_args >= 0 {
1645
1655
print_indent (
1646
1656
depth,
You can’t perform that action at this time.
0 commit comments