Skip to content

Commit 8e83f73

Browse files
committed
Ignore builtin template when parsing.
This should fix rust-lang#584.
1 parent 15a18fa commit 8e83f73

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

src/ir/template.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl TemplateInstantiation {
8888
/// Parse a `TemplateInstantiation` from a clang `Type`.
8989
pub fn from_ty(ty: &clang::Type,
9090
ctx: &mut BindgenContext)
91-
-> TemplateInstantiation {
91+
-> Option<TemplateInstantiation> {
9292
use clang_sys::*;
9393

9494
let template_args = ty.template_args()
@@ -100,6 +100,10 @@ impl TemplateInstantiation {
100100
.collect()
101101
});
102102

103+
if ty.declaration().is_builtin() {
104+
return None;
105+
}
106+
103107
let definition = ty.declaration()
104108
.specialized()
105109
.or_else(|| {
@@ -124,7 +128,7 @@ impl TemplateInstantiation {
124128
let template_definition =
125129
Item::from_ty_or_ref(definition.cur_type(), definition, None, ctx);
126130

127-
TemplateInstantiation::new(template_definition, template_args)
131+
Some(TemplateInstantiation::new(template_definition, template_args))
128132
}
129133

130134
/// Does this instantiation have a vtable?

src/ir/ty.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,10 @@ impl Type {
993993
(ty.template_args().is_some() &&
994994
ty_kind != CXType_Typedef) {
995995
// This is a template instantiation.
996-
let inst = TemplateInstantiation::from_ty(&ty, ctx);
996+
let inst = match TemplateInstantiation::from_ty(&ty, ctx) {
997+
Some(inst) => inst,
998+
None => return Err(ParseError::Continue),
999+
};
9971000
TypeKind::TemplateInstantiation(inst)
9981001
} else {
9991002
match ty_kind {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
4+
#![allow(non_snake_case)]
5+
6+
7+
pub type std_make_integer_sequence<T> = T;

tests/headers/builtin-template.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace std {
2+
template<class T, T... Ints>
3+
class integer_sequence;
4+
template<class T, T N>
5+
using make_integer_sequence = __make_integer_seq<integer_sequence, T, N>;
6+
}

0 commit comments

Comments
 (0)