summaryrefslogtreecommitdiff
path: root/src/ir/comp.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ir/comp.rs')
-rw-r--r--src/ir/comp.rs31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/ir/comp.rs b/src/ir/comp.rs
index ce6ec25d..b97879f7 100644
--- a/src/ir/comp.rs
+++ b/src/ir/comp.rs
@@ -625,8 +625,19 @@ impl CompInfo {
// StructDecl to note incomplete structs that hasn't been
// forward-declared before, see:
//
+ // Also, clang seems to scope struct definitions inside
+ // unions to the whole translation unit. Since those are
+ // anonymous, let's just assume that if the cursor we've
+ // found is a definition it's a valid inner type.
+ //
+ // Note that doing this could be always ok, but let's just
+ // keep the union check for now.
+ //
// https://github.com/servo/rust-bindgen/issues/482
- if cur.semantic_parent() != cursor {
+ let is_inner_struct = cur.semantic_parent() == cursor ||
+ (kind == CompKind::Union &&
+ cur.is_definition());
+ if !is_inner_struct {
return CXChildVisit_Continue;
}
@@ -871,7 +882,7 @@ impl CompInfo {
}
impl TemplateDeclaration for CompInfo {
- fn template_params(&self, _ctx: &BindgenContext) -> Option<Vec<ItemId>> {
+ fn self_template_params(&self, _ctx: &BindgenContext) -> Option<Vec<ItemId>> {
if self.template_args.is_empty() {
None
} else {
@@ -1040,10 +1051,10 @@ impl Trace for CompInfo {
if let Some(template) = self.specialized_template() {
// This is an instantiation of a template declaration with concrete
// template type arguments.
- tracer.visit(template);
+ tracer.visit_kind(template, EdgeKind::TemplateDeclaration);
let args = item.applicable_template_args(context);
for a in args {
- tracer.visit(a);
+ tracer.visit_kind(a, EdgeKind::TemplateArgument);
}
} else {
let params = item.applicable_template_args(context);
@@ -1055,27 +1066,27 @@ impl Trace for CompInfo {
}
for base in self.base_members() {
- tracer.visit(base.ty);
+ tracer.visit_kind(base.ty, EdgeKind::BaseMember);
}
for field in self.fields() {
- tracer.visit(field.ty());
+ tracer.visit_kind(field.ty(), EdgeKind::Field);
}
for &ty in self.inner_types() {
- tracer.visit(ty);
+ tracer.visit_kind(ty, EdgeKind::InnerType);
}
for &var in self.inner_vars() {
- tracer.visit(var);
+ tracer.visit_kind(var, EdgeKind::InnerVar);
}
for method in self.methods() {
- tracer.visit(method.signature);
+ tracer.visit_kind(method.signature, EdgeKind::Method);
}
for &ctor in self.constructors() {
- tracer.visit(ctor);
+ tracer.visit_kind(ctor, EdgeKind::Constructor);
}
}
}