summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ir/item.rs24
-rw-r--r--src/ir/ty.rs19
-rwxr-xr-xsrc/lib.rs1
3 files changed, 36 insertions, 8 deletions
diff --git a/src/ir/item.rs b/src/ir/item.rs
index 0d409f04..8e30a1e5 100644
--- a/src/ir/item.rs
+++ b/src/ir/item.rs
@@ -11,7 +11,6 @@ use std::cell::{Cell, RefCell};
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
use parse::{ClangItemParser, ClangSubItemParser, ParseError, ParseResult};
use clang;
-use clangll;
/// A trait to get the canonical name from an item.
///
@@ -566,12 +565,12 @@ impl Item {
static ref RE_ENDS_WITH_BINDGEN_TY: Regex = Regex::new(r"_bindgen_ty(_\d+)+$").unwrap();
static ref RE_ENDS_WITH_BINDGEN_MOD: Regex = Regex::new(r"_bindgen_mod(_\d+)+$").unwrap();
}
-
+
let (re, kind) = match *self.kind() {
ItemKind::Module(..) => (&*RE_ENDS_WITH_BINDGEN_MOD, "mod"),
_ => (&*RE_ENDS_WITH_BINDGEN_TY, "ty"),
};
-
+
let parent_name = parent_name.and_then(|n| if n.is_empty() { None } else { Some(n) });
match (parent_name, base_name) {
(Some(parent), Some(base)) => format!("{}_{}", parent, base),
@@ -636,6 +635,7 @@ impl ClangItemParser for Item {
use ir::function::Function;
use ir::module::Module;
use ir::var::Var;
+ use clangll::*;
if !cursor.is_valid() {
return Err(ParseError::Continue);
@@ -697,11 +697,23 @@ impl ClangItemParser for Item {
}
// Guess how does clang treat extern "C" blocks?
- if cursor.kind() == clangll::CXCursor_UnexposedDecl {
+ if cursor.kind() == CXCursor_UnexposedDecl {
Err(ParseError::Recurse)
} else {
- error!("Unhandled cursor kind: {} ({})",
- ::clang::kind_to_str(cursor.kind()), cursor.kind());
+ // We whitelist cursors here known to be unhandled, to prevent being
+ // too noisy about this.
+ match cursor.kind() {
+ CXCursor_MacroDefinition |
+ CXCursor_InclusionDirective => {
+ debug!("Unhandled cursor kind {:?}: {:?}",
+ cursor.kind(), cursor);
+ },
+ _ =>{
+ error!("Unhandled cursor kind {:?}: {:?}",
+ cursor.kind(), cursor);
+ }
+ }
+
Err(ParseError::Continue)
}
}
diff --git a/src/ir/ty.rs b/src/ir/ty.rs
index b9816f6e..9881c653 100644
--- a/src/ir/ty.rs
+++ b/src/ir/ty.rs
@@ -602,7 +602,18 @@ impl Type {
return Err(ParseError::Recurse);
}
- error!("invalid type {:?}", ty);
+ // If the type name is empty we're probably
+ // over-recursing to find a template parameter name
+ // or something like that, so just don't be too
+ // noisy with it since it causes confusion, see for
+ // example the discussion in:
+ //
+ // https://github.com/jamesmunns/teensy3-rs/issues/9
+ if !ty.spelling().is_empty() {
+ error!("invalid type {:?}", ty);
+ } else {
+ warn!("invalid type {:?}", ty);
+ }
return Err(ParseError::Continue);
}
}
@@ -613,7 +624,11 @@ impl Type {
return Err(ParseError::Recurse);
}
- error!("invalid type `{}`", ty.spelling());
+ if !ty.spelling().is_empty() {
+ error!("invalid type {:?}", ty);
+ } else {
+ warn!("invalid type {:?}", ty);
+ }
return Err(ParseError::Continue);
}
}
diff --git a/src/lib.rs b/src/lib.rs
index 79385dc1..19ecb6c9 100755
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -12,6 +12,7 @@
#![cfg_attr(feature = "clippy", plugin(clippy))]
#![deny(missing_docs)]
+#![deny(warnings)]
// We internally use the deprecated BindgenOptions all over the place. Once we
// remove its `pub` declaration, we can un-deprecate it and remove this pragma.