Skip to content

Commit 02dc02b

Browse files
committed
Remove CompInfo::needs_explicit_vtable and use HasVtable::has_vtable_ptr instead
1 parent b59ffb8 commit 02dc02b

File tree

2 files changed

+2
-23
lines changed

2 files changed

+2
-23
lines changed

src/codegen/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,7 @@ impl CodeGenerator for CompInfo {
14241424
//
14251425
// FIXME: Once we generate proper vtables, we need to codegen the
14261426
// vtable, but *not* generate a field for it in the case that
1427-
// needs_explicit_vtable is false but has_vtable is true.
1427+
// HasVtable::has_vtable_ptr is false but HasVtable::has_vtable is true.
14281428
//
14291429
// Also, we need to generate the vtable in such a way it "inherits" from
14301430
// the parent too.
@@ -1434,7 +1434,7 @@ impl CodeGenerator for CompInfo {
14341434
StructLayoutTracker::new(ctx, self, &canonical_name);
14351435

14361436
if !is_opaque {
1437-
if self.needs_explicit_vtable(ctx, item) {
1437+
if item.has_vtable_ptr(ctx) {
14381438
let vtable =
14391439
Vtable::new(item.id(), self.methods(), self.base_members());
14401440
vtable.codegen(ctx, result, item);

src/ir/comp.rs

-21
Original file line numberDiff line numberDiff line change
@@ -1451,27 +1451,6 @@ impl CompInfo {
14511451
self.packed
14521452
}
14531453

1454-
/// Returns whether this type needs an explicit vtable because it has
1455-
/// virtual methods and none of its base classes has already a vtable.
1456-
pub fn needs_explicit_vtable(
1457-
&self,
1458-
ctx: &BindgenContext,
1459-
item: &Item,
1460-
) -> bool {
1461-
item.has_vtable(ctx) && !self.base_members.iter().any(|base| {
1462-
// NB: Ideally, we could rely in all these types being `comp`, and
1463-
// life would be beautiful.
1464-
//
1465-
// Unfortunately, given the way we implement --match-pat, and also
1466-
// that you can inherit from templated types, we need to handle
1467-
// other cases here too.
1468-
ctx.resolve_type(base.ty)
1469-
.canonical_type(ctx)
1470-
.as_comp()
1471-
.map_or(false, |_| base.ty.has_vtable(ctx))
1472-
})
1473-
}
1474-
14751454
/// Returns true if compound type has been forward declared
14761455
pub fn is_forward_declaration(&self) -> bool {
14771456
self.is_forward_declaration

0 commit comments

Comments
 (0)