summaryrefslogtreecommitdiff
path: root/libbindgen/src
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <ecoal95@gmail.com>2016-11-24 22:02:53 +0100
committerEmilio Cobos Álvarez <ecoal95@gmail.com>2016-11-24 22:33:57 +0100
commitebef1423cde4afa8d1f97a6f91ad466642a41b1c (patch)
tree458a4c0ba34665dc50a563948778253132aa2411 /libbindgen/src
parent294c1b07e2ed10fb9d6afdd5a6aa234ebf0258d8 (diff)
Some fixes for libclang 4.0.
Diffstat (limited to 'libbindgen/src')
-rw-r--r--libbindgen/src/clang.rs13
-rw-r--r--libbindgen/src/ir/comp.rs18
-rw-r--r--libbindgen/src/ir/ty.rs2
3 files changed, 29 insertions, 4 deletions
diff --git a/libbindgen/src/clang.rs b/libbindgen/src/clang.rs
index 72069644..7c6d3199 100644
--- a/libbindgen/src/clang.rs
+++ b/libbindgen/src/clang.rs
@@ -760,6 +760,19 @@ impl Type {
pub fn is_valid_and_exposed(&self) -> bool {
self.is_valid() && self.kind() != CXType_Unexposed
}
+
+ /// Is this type a fully specialized template?
+ pub fn is_fully_specialized_template(&self) -> bool {
+ // Yep, the spelling of this containing type-parameter is extremely
+ // nasty... But can happen in <type_traits>. Unfortunately I couldn't
+ // reduce it enough :(
+ !self.spelling().contains("type-parameter") &&
+ self.template_args()
+ .map_or(false, |mut args| {
+ args.len() > 0 &&
+ !args.any(|t| t.spelling().contains("type-parameter"))
+ })
+ }
}
/// An iterator for a type's template arguments.
diff --git a/libbindgen/src/ir/comp.rs b/libbindgen/src/ir/comp.rs
index d19d1209..d2ace023 100644
--- a/libbindgen/src/ir/comp.rs
+++ b/libbindgen/src/ir/comp.rs
@@ -498,17 +498,29 @@ impl CompInfo {
None => vec![],
Some(arg_types) => {
let num_arg_types = arg_types.len();
+ let mut specialization = true;
let args = arg_types.filter(|t| t.kind() != CXType_Invalid)
- .map(|t| Item::from_ty_or_ref(t, None, None, ctx))
+ .filter_map(|t| {
+ if t.spelling().starts_with("type-parameter") {
+ specialization = false;
+ None
+ } else {
+ Some(Item::from_ty_or_ref(t, None, None, ctx))
+ }
+ })
.collect::<Vec<_>>();
- if args.len() != num_arg_types {
+ if specialization && args.len() != num_arg_types {
ci.has_non_type_template_params = true;
warn!("warning: Template parameter is not a type");
}
- args
+ if specialization {
+ args
+ } else {
+ vec![]
+ }
}
};
diff --git a/libbindgen/src/ir/ty.rs b/libbindgen/src/ir/ty.rs
index 7f01e388..33e20861 100644
--- a/libbindgen/src/ir/ty.rs
+++ b/libbindgen/src/ir/ty.rs
@@ -554,7 +554,7 @@ impl Type {
TypeKind::Function(signature)
// Same here, with template specialisations we can safely
// assume this is a Comp(..)
- } else if ty.template_args().map_or(false, |x| x.len() > 0) {
+ } else if ty.is_fully_specialized_template() {
debug!("Template specialization: {:?}", ty);
let complex =
CompInfo::from_ty(potential_id, ty, location, ctx)