Skip to content

Commit 41b9f69

Browse files
author
bors-servo
authored
Auto merge of #173 - emilio:errors, r=fitzgen
Be less noisy about known to be unimportant errors. r? @fitzgen
2 parents d199320 + efb05d5 commit 41b9f69

File tree

3 files changed

+36
-8
lines changed

3 files changed

+36
-8
lines changed

src/ir/item.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use std::cell::{Cell, RefCell};
1111
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
1212
use parse::{ClangItemParser, ClangSubItemParser, ParseError, ParseResult};
1313
use clang;
14-
use clangll;
1514

1615
/// A trait to get the canonical name from an item.
1716
///
@@ -566,12 +565,12 @@ impl Item {
566565
static ref RE_ENDS_WITH_BINDGEN_TY: Regex = Regex::new(r"_bindgen_ty(_\d+)+$").unwrap();
567566
static ref RE_ENDS_WITH_BINDGEN_MOD: Regex = Regex::new(r"_bindgen_mod(_\d+)+$").unwrap();
568567
}
569-
568+
570569
let (re, kind) = match *self.kind() {
571570
ItemKind::Module(..) => (&*RE_ENDS_WITH_BINDGEN_MOD, "mod"),
572571
_ => (&*RE_ENDS_WITH_BINDGEN_TY, "ty"),
573572
};
574-
573+
575574
let parent_name = parent_name.and_then(|n| if n.is_empty() { None } else { Some(n) });
576575
match (parent_name, base_name) {
577576
(Some(parent), Some(base)) => format!("{}_{}", parent, base),
@@ -636,6 +635,7 @@ impl ClangItemParser for Item {
636635
use ir::function::Function;
637636
use ir::module::Module;
638637
use ir::var::Var;
638+
use clangll::*;
639639

640640
if !cursor.is_valid() {
641641
return Err(ParseError::Continue);
@@ -697,11 +697,23 @@ impl ClangItemParser for Item {
697697
}
698698

699699
// Guess how does clang treat extern "C" blocks?
700-
if cursor.kind() == clangll::CXCursor_UnexposedDecl {
700+
if cursor.kind() == CXCursor_UnexposedDecl {
701701
Err(ParseError::Recurse)
702702
} 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+
705717
Err(ParseError::Continue)
706718
}
707719
}

src/ir/ty.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,18 @@ impl Type {
602602
return Err(ParseError::Recurse);
603603
}
604604

605-
error!("invalid type {:?}", ty);
605+
// If the type name is empty we're probably
606+
// over-recursing to find a template parameter name
607+
// or something like that, so just don't be too
608+
// noisy with it since it causes confusion, see for
609+
// example the discussion in:
610+
//
611+
// https://github.com/jamesmunns/teensy3-rs/issues/9
612+
if !ty.spelling().is_empty() {
613+
error!("invalid type {:?}", ty);
614+
} else {
615+
warn!("invalid type {:?}", ty);
616+
}
606617
return Err(ParseError::Continue);
607618
}
608619
}
@@ -613,7 +624,11 @@ impl Type {
613624
return Err(ParseError::Recurse);
614625
}
615626

616-
error!("invalid type `{}`", ty.spelling());
627+
if !ty.spelling().is_empty() {
628+
error!("invalid type {:?}", ty);
629+
} else {
630+
warn!("invalid type {:?}", ty);
631+
}
617632
return Err(ParseError::Continue);
618633
}
619634
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#![cfg_attr(feature = "clippy", plugin(clippy))]
1313

1414
#![deny(missing_docs)]
15+
#![deny(warnings)]
1516

1617
// We internally use the deprecated BindgenOptions all over the place. Once we
1718
// remove its `pub` declaration, we can un-deprecate it and remove this pragma.

0 commit comments

Comments
 (0)