Skip to content

Commit 3975ed4

Browse files
committed
ir: Ignore constructors with bogus spellings.
1 parent 892e2ec commit 3975ed4

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

src/ir/function.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,22 @@ impl FunctionSig {
347347
return Err(ParseError::Continue);
348348
}
349349

350+
let kind = cursor.kind();
351+
352+
// Constructors of non-type template parameter classes for some reason
353+
// include the template parameter in their name. Just skip them, since
354+
// we don't handle well non-type template parameters anyway.
355+
if kind == CXCursor_Constructor && spelling.contains('<') {
356+
return Err(ParseError::Continue);
357+
}
358+
350359
let cursor = if cursor.is_valid() {
351360
*cursor
352361
} else {
353362
ty.declaration()
354363
};
355364

356-
let mut args: Vec<_> = match cursor.kind() {
365+
let mut args: Vec<_> = match kind {
357366
CXCursor_FunctionDecl |
358367
CXCursor_Constructor |
359368
CXCursor_CXXMethod |
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
#![allow(
4+
dead_code,
5+
non_snake_case,
6+
non_camel_case_types,
7+
non_upper_case_globals
8+
)]

tests/headers/issue-1464.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
// Should not crash.
3+
template <int Foo> class Bar {
4+
public:
5+
Bar();
6+
};

tests/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ fn compare_generated_header(
207207
expectation_file.write_all(actual.as_bytes())?;
208208
}
209209

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

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

0 commit comments

Comments
 (0)