[SIL] NFC: Make SILVTable follow C++ and LLVM best practices

1) Convert the `Entry` type to a class with getters/setters
2) Use llvm::TrailingObjects
3) Use llvm::PointerIntPair
This commit is contained in:
David Zarzycki
2020-06-10 08:57:41 -04:00
parent cdc38dab31
commit e077b6ffd9
11 changed files with 156 additions and 140 deletions

View File

@@ -29,31 +29,31 @@ class PruneVTables : public SILModuleTransform {
for (auto &entry : vtable->getMutableEntries()) {
// We don't need to worry about entries that are inherited, overridden,
// or have already been found to have no overrides.
if (entry.TheKind != SILVTable::Entry::Normal) {
if (entry.getKind() != SILVTable::Entry::Normal) {
continue;
}
// The destructor entry must remain.
if (entry.Method.kind == SILDeclRef::Kind::Deallocator) {
if (entry.getMethod().kind == SILDeclRef::Kind::Deallocator) {
continue;
}
auto methodDecl = entry.Method.getAbstractFunctionDecl();
auto methodDecl = entry.getMethod().getAbstractFunctionDecl();
if (!methodDecl)
continue;
// Is the method declared final?
if (!methodDecl->isFinal()) {
// Are callees of this entry statically knowable?
if (!calleesAreStaticallyKnowable(*M, entry.Method))
if (!calleesAreStaticallyKnowable(*M, entry.getMethod()))
continue;
// Does the method have any overrides in this module?
if (methodDecl->isOverridden())
continue;
}
entry.TheKind = SILVTable::Entry::NormalNonOverridden;
entry.setKind(SILVTable::Entry::NormalNonOverridden);
}
}