summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXidorn Quan <me@upsuper.org>2017-03-20 17:18:34 +1100
committerNick Fitzgerald <fitzgen@gmail.com>2017-04-04 13:30:52 -0700
commit9d8c338dcfcab0402d0b10fc0c929ef909ee8164 (patch)
tree08eccbd111b8ad0f738d281224071b6800a4fc68
parent642b69580e6b3f368870c966152924a721590c28 (diff)
Ignore builtin template when parsing.
This should fix #584.
-rw-r--r--src/ir/template.rs8
-rw-r--r--src/ir/ty.rs5
-rw-r--r--tests/expectations/tests/builtin-template.rs7
-rw-r--r--tests/headers/builtin-template.hpp6
4 files changed, 23 insertions, 3 deletions
diff --git a/src/ir/template.rs b/src/ir/template.rs
index 627ac225..4022b366 100644
--- a/src/ir/template.rs
+++ b/src/ir/template.rs
@@ -88,7 +88,7 @@ impl TemplateInstantiation {
/// Parse a `TemplateInstantiation` from a clang `Type`.
pub fn from_ty(ty: &clang::Type,
ctx: &mut BindgenContext)
- -> TemplateInstantiation {
+ -> Option<TemplateInstantiation> {
use clang_sys::*;
let template_args = ty.template_args()
@@ -100,6 +100,10 @@ impl TemplateInstantiation {
.collect()
});
+ if ty.declaration().is_builtin() {
+ return None;
+ }
+
let definition = ty.declaration()
.specialized()
.or_else(|| {
@@ -124,7 +128,7 @@ impl TemplateInstantiation {
let template_definition =
Item::from_ty_or_ref(definition.cur_type(), definition, None, ctx);
- TemplateInstantiation::new(template_definition, template_args)
+ Some(TemplateInstantiation::new(template_definition, template_args))
}
/// Does this instantiation have a vtable?
diff --git a/src/ir/ty.rs b/src/ir/ty.rs
index 60d750ed..f1485638 100644
--- a/src/ir/ty.rs
+++ b/src/ir/ty.rs
@@ -988,7 +988,10 @@ impl Type {
(ty.template_args().is_some() &&
ty_kind != CXType_Typedef) {
// This is a template instantiation.
- let inst = TemplateInstantiation::from_ty(&ty, ctx);
+ let inst = match TemplateInstantiation::from_ty(&ty, ctx) {
+ Some(inst) => inst,
+ None => return Err(ParseError::Continue),
+ };
TypeKind::TemplateInstantiation(inst)
} else {
match ty_kind {
diff --git a/tests/expectations/tests/builtin-template.rs b/tests/expectations/tests/builtin-template.rs
new file mode 100644
index 00000000..1215f9da
--- /dev/null
+++ b/tests/expectations/tests/builtin-template.rs
@@ -0,0 +1,7 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+pub type std_make_integer_sequence<T> = T;
diff --git a/tests/headers/builtin-template.hpp b/tests/headers/builtin-template.hpp
new file mode 100644
index 00000000..4e64ebc7
--- /dev/null
+++ b/tests/headers/builtin-template.hpp
@@ -0,0 +1,6 @@
+namespace std {
+template<class T, T... Ints>
+class integer_sequence;
+template<class T, T N>
+using make_integer_sequence = __make_integer_seq<integer_sequence, T, N>;
+}