Skip to content

Commit f25341a

Browse files
upsuperfitzgen
authored andcommitted
Ignore builtin template when parsing.
This should fix rust-lang#584.
1 parent ad01eb2 commit f25341a

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

src/ir/template.rs

+6-2
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

+4-1
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,10 @@ impl Type {
988988
(ty.template_args().is_some() &&
989989
ty_kind != CXType_Typedef) {
990990
// This is a template instantiation.
991-
let inst = TemplateInstantiation::from_ty(&ty, ctx);
991+
let inst = match TemplateInstantiation::from_ty(&ty, ctx) {
992+
Some(inst) => inst,
993+
None => return Err(ParseError::Continue),
994+
};
992995
TypeKind::TemplateInstantiation(inst)
993996
} else {
994997
match ty_kind {
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

+6
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)