Skip to content

Be less noisy about known to be unimportant errors. #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions src/ir/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
}
}
Expand Down
19 changes: 17 additions & 2 deletions src/ir/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down