diff options
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | src/ir/item.rs | 20 | ||||
-rw-r--r-- | src/ir/ty.rs | 19 | ||||
-rwxr-xr-x | src/lib.rs | 1 | ||||
-rw-r--r-- | tests/tests.rs | 11 |
5 files changed, 44 insertions, 9 deletions
diff --git a/.travis.yml b/.travis.yml index 031c61ff..5d3395e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,6 +41,8 @@ before_script: script: - cargo build --verbose --features llvm_stable - cargo test --features llvm_stable + - cargo build --release --verbose --features llvm_stable + - cargo test --release --features llvm_stable - git add -A - git diff @ - git diff-index --quiet HEAD diff --git a/src/ir/item.rs b/src/ir/item.rs index b262b825..a6d15cd7 100644 --- a/src/ir/item.rs +++ b/src/ir/item.rs @@ -12,7 +12,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. /// @@ -671,6 +670,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); @@ -732,11 +732,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 b2f20dde..fa37dd03 100644 --- a/src/ir/ty.rs +++ b/src/ir/ty.rs @@ -603,7 +603,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); } } @@ -614,7 +625,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); } } @@ -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. diff --git a/tests/tests.rs b/tests/tests.rs index 003c0f1a..addaa5ad 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -64,7 +64,11 @@ fn run_bindgen_tests() { let mut bindgen = PathBuf::from(&crate_root); bindgen.push("target"); - bindgen.push("debug"); + if cfg!(debug_assertions) { + bindgen.push("debug"); + } else { + bindgen.push("release"); + } bindgen.push("bindgen"); if !bindgen.is_file() { panic!("{} is not a file! Build bindgen before running tests.", @@ -92,8 +96,9 @@ fn run_bindgen_tests() { .and_then(|x| x.parse::<usize>().ok()) .unwrap_or(TEST_BATCH_DEFAULT_SIZE); - // Spawn batch_size child to run in parallel - // and wait on all of them before processing the next batch + // Spawn `batch_size` children to run in parallel and wait on all of them + // before processing the next batch. This puts a limit on the resources + // consumed when testing, so that we don't overload the system. let children = tests.chunks(batch_size).map(|x| { x.iter().map(|entry| { |