Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Type::detect_has_vtable_cycle. #787

Merged
merged 1 commit into from
Jul 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions src/ir/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use super::template::{AsTemplateParam, TemplateInstantiation, TemplateParameters
use super::traversal::{EdgeKind, Trace, Tracer};
use clang::{self, Cursor};
use parse::{ClangItemParser, ParseError, ParseResult};
use std::cell::Cell;
use std::io;
use std::mem;

Expand All @@ -33,9 +32,6 @@ pub struct Type {
kind: TypeKind,
/// Whether this type is const-qualified.
is_const: bool,
/// Don't go into an infinite loop when detecting if we have a vtable or
/// not.
detect_has_vtable_cycle: Cell<bool>,
}

/// The maximum number of items in an array for which Rust implements common
Expand Down Expand Up @@ -75,7 +71,6 @@ impl Type {
layout: layout,
kind: kind,
is_const: is_const,
detect_has_vtable_cycle: Cell::new(false),
}
}

Expand Down Expand Up @@ -244,25 +239,15 @@ impl Type {

/// Whether this type has a vtable.
pub fn has_vtable(&self, ctx: &BindgenContext) -> bool {
if self.detect_has_vtable_cycle.get() {
return false;
}

self.detect_has_vtable_cycle.set(true);

// FIXME: Can we do something about template parameters? Huh...
let result = match self.kind {
match self.kind {
TypeKind::TemplateAlias(t, _) |
TypeKind::Alias(t) |
TypeKind::ResolvedTypeRef(t) => ctx.resolve_type(t).has_vtable(ctx),
TypeKind::Comp(ref info) => info.has_vtable(ctx),
TypeKind::TemplateInstantiation(ref inst) => inst.has_vtable(ctx),
_ => false,
};

self.detect_has_vtable_cycle.set(false);

result
}
}

/// Returns whether this type has a destructor.
Expand Down