@@ -11,7 +11,6 @@ use std::cell::{Cell, RefCell};
11
11
use std:: sync:: atomic:: { AtomicUsize , ATOMIC_USIZE_INIT , Ordering } ;
12
12
use parse:: { ClangItemParser , ClangSubItemParser , ParseError , ParseResult } ;
13
13
use clang;
14
- use clangll;
15
14
16
15
/// A trait to get the canonical name from an item.
17
16
///
@@ -566,12 +565,12 @@ impl Item {
566
565
static ref RE_ENDS_WITH_BINDGEN_TY : Regex = Regex :: new( r"_bindgen_ty(_\d+)+$" ) . unwrap( ) ;
567
566
static ref RE_ENDS_WITH_BINDGEN_MOD : Regex = Regex :: new( r"_bindgen_mod(_\d+)+$" ) . unwrap( ) ;
568
567
}
569
-
568
+
570
569
let ( re, kind) = match * self . kind ( ) {
571
570
ItemKind :: Module ( ..) => ( & * RE_ENDS_WITH_BINDGEN_MOD , "mod" ) ,
572
571
_ => ( & * RE_ENDS_WITH_BINDGEN_TY , "ty" ) ,
573
572
} ;
574
-
573
+
575
574
let parent_name = parent_name. and_then ( |n| if n. is_empty ( ) { None } else { Some ( n) } ) ;
576
575
match ( parent_name, base_name) {
577
576
( Some ( parent) , Some ( base) ) => format ! ( "{}_{}" , parent, base) ,
@@ -636,6 +635,7 @@ impl ClangItemParser for Item {
636
635
use ir:: function:: Function ;
637
636
use ir:: module:: Module ;
638
637
use ir:: var:: Var ;
638
+ use clangll:: * ;
639
639
640
640
if !cursor. is_valid ( ) {
641
641
return Err ( ParseError :: Continue ) ;
@@ -697,11 +697,23 @@ impl ClangItemParser for Item {
697
697
}
698
698
699
699
// Guess how does clang treat extern "C" blocks?
700
- if cursor. kind ( ) == clangll :: CXCursor_UnexposedDecl {
700
+ if cursor. kind ( ) == CXCursor_UnexposedDecl {
701
701
Err ( ParseError :: Recurse )
702
702
} else {
703
- error ! ( "Unhandled cursor kind: {} ({})" ,
704
- :: clang:: kind_to_str( cursor. kind( ) ) , cursor. kind( ) ) ;
703
+ // We whitelist cursors here known to be unhandled, to prevent being
704
+ // too noisy about this.
705
+ match cursor. kind ( ) {
706
+ CXCursor_MacroDefinition |
707
+ CXCursor_InclusionDirective => {
708
+ debug ! ( "Unhandled cursor kind {:?}: {:?}" ,
709
+ cursor. kind( ) , cursor) ;
710
+ } ,
711
+ _ =>{
712
+ error ! ( "Unhandled cursor kind {:?}: {:?}" ,
713
+ cursor. kind( ) , cursor) ;
714
+ }
715
+ }
716
+
705
717
Err ( ParseError :: Continue )
706
718
}
707
719
}
0 commit comments