From de27c177f04f445a91c4ee5f0a83c0428abc6bc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 31 Oct 2016 15:24:39 +0100 Subject: [PATCH 1/2] Be less noisy about known to be unimportant errors. --- src/ir/item.rs | 24 ++++++++++++++++++------ src/ir/ty.rs | 19 +++++++++++++++++-- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/ir/item.rs b/src/ir/item.rs index 0d409f0401..8e30a1e577 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 0905952800..c373828adb 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 sine 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); } } From efb05d55eaddc42dfe47ca540c99a10942e0b69b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 31 Oct 2016 15:27:44 +0100 Subject: [PATCH 2/2] Make the build deny(warnings). --- src/ir/ty.rs | 2 +- src/lib.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ir/ty.rs b/src/ir/ty.rs index c373828adb..2cb4762cfe 100644 --- a/src/ir/ty.rs +++ b/src/ir/ty.rs @@ -605,7 +605,7 @@ impl Type { // 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 sine it causes confusion, see for + // noisy with it since it causes confusion, see for // example the discussion in: // // https://github.com/jamesmunns/teensy3-rs/issues/9 diff --git a/src/lib.rs b/src/lib.rs index 79385dc13d..19ecb6c9a3 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.