diff options
| author | Anders Carlsson <andersca@mac.com> | 2010-02-14 17:05:59 +0000 |
|---|---|---|
| committer | Anders Carlsson <andersca@mac.com> | 2010-02-14 17:05:59 +0000 |
| commit | 033d48697f19a6f4fe72db9df168c694bc4dfa7a (patch) | |
| tree | 6e902f17895a5ffa0d4e57ccfa54fb07c6f07b94 /clang/lib/CodeGen/CGVtable.cpp | |
| parent | ce77ce30727f2b28e9e4e9b7a402d67c3d9513d1 (diff) | |
| download | bcm5719-llvm-033d48697f19a6f4fe72db9df168c694bc4dfa7a.tar.gz bcm5719-llvm-033d48697f19a6f4fe72db9df168c694bc4dfa7a.zip | |
Don't compute final overriders or build vtables for bases that don't need a vtable.
llvm-svn: 96171
Diffstat (limited to 'clang/lib/CodeGen/CGVtable.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGVtable.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGVtable.cpp b/clang/lib/CodeGen/CGVtable.cpp index 878e563d847..2f952c54b6e 100644 --- a/clang/lib/CodeGen/CGVtable.cpp +++ b/clang/lib/CodeGen/CGVtable.cpp @@ -498,6 +498,10 @@ void FinalOverriders::ComputeFinalOverriders(BaseSubobject Base, const CXXRecordDecl *BaseDecl = cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl()); + // Ignore bases that don't have any virtual member functions. + if (!BaseDecl->isPolymorphic()) + continue; + uint64_t BaseOffset; if (I->isVirtual()) { BaseOffset = MostDerivedClassLayout.getVBaseClassOffset(BaseDecl); @@ -528,6 +532,10 @@ void FinalOverriders::dump(llvm::raw_ostream &Out, BaseSubobject Base) { const CXXRecordDecl *BaseDecl = cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl()); + // Ignore bases that don't have any virtual member functions. + if (!BaseDecl->isPolymorphic()) + continue; + uint64_t BaseOffset; if (I->isVirtual()) { if (!VisitedVirtualBases.insert(BaseDecl)) { @@ -949,7 +957,9 @@ VtableBuilder::AddMethods(BaseSubobject Base, PrimaryBasesSetTy &PrimaryBases) { void VtableBuilder::layoutVtable(BaseSubobject Base) { const CXXRecordDecl *RD = Base.getBase(); - + + assert(RD->isDynamicClass() && "class does not have a vtable!"); + // First, add the offset to top. // FIXME: This is not going to be right for construction vtables. // FIXME: We should not use / 8 here. @@ -987,11 +997,15 @@ void VtableBuilder::layoutVtable(BaseSubobject Base) { E = RD->bases_end(); I != E; ++I) { const CXXRecordDecl *BaseDecl = cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl()); - + // Ignore the primary base. if (BaseDecl == PrimaryBase) continue; - + + // Ignore bases that don't have a vtable. + if (!BaseDecl->isDynamicClass()) + continue; + assert(!I->isVirtual() && "FIXME: Handle virtual bases"); // Get the base offset of this base. |

