Skip to content

Commit

Permalink
ir: Ignore constructors with bogus spellings.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Feb 3, 2019
1 parent 892e2ec commit 3975ed4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/ir/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,22 @@ impl FunctionSig {
return Err(ParseError::Continue);
}

let kind = cursor.kind();

// Constructors of non-type template parameter classes for some reason
// include the template parameter in their name. Just skip them, since
// we don't handle well non-type template parameters anyway.
if kind == CXCursor_Constructor && spelling.contains('<') {
return Err(ParseError::Continue);
}

let cursor = if cursor.is_valid() {
*cursor
} else {
ty.declaration()
};

let mut args: Vec<_> = match cursor.kind() {
let mut args: Vec<_> = match kind {
CXCursor_FunctionDecl |
CXCursor_Constructor |
CXCursor_CXXMethod |
Expand Down
8 changes: 8 additions & 0 deletions tests/expectations/tests/issue-1464.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* automatically generated by rust-bindgen */

#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
6 changes: 6 additions & 0 deletions tests/headers/issue-1464.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

// Should not crash.
template <int Foo> class Bar {
public:
Bar();
};
2 changes: 1 addition & 1 deletion tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ fn compare_generated_header(
expectation_file.write_all(actual.as_bytes())?;
}

Err(Error::new(ErrorKind::Other, "Header and binding differ!"))
Err(Error::new(ErrorKind::Other, "Header and binding differ! Run with BINDGEN_OVERWRITE_EXPECTED=1 in the environment to automatically overwrite the expectation."))
}

fn create_bindgen_builder(header: &PathBuf) -> Result<Option<Builder>, Error> {
Expand Down

0 comments on commit 3975ed4

Please sign in to comment.