diff options
author | Anders Carlsson <andersca@mac.com> | 2010-04-11 20:04:11 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-04-11 20:04:11 +0000 |
commit | af6ddf20711ccc6824545a5ac901d4fe3e462c3d (patch) | |
tree | 250f34ed6b0781262df8f076d617a394e81bfd8e /lib/CodeGen/CGVTables.cpp | |
parent | 86ed3a326342fa2a8c9d9b5d1d7280c9bad2b007 (diff) |
Fix a bug where we were adding too many vcall offsets in some cases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100985 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGVTables.cpp')
-rw-r--r-- | lib/CodeGen/CGVTables.cpp | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp index 26ae777c58..0d9c3ad4ae 100644 --- a/lib/CodeGen/CGVTables.cpp +++ b/lib/CodeGen/CGVTables.cpp @@ -982,30 +982,17 @@ void VCallAndVBaseOffsetBuilder::AddVCallOffsets(BaseSubobject Base, const CXXRecordDecl *PrimaryBase = Layout.getPrimaryBase(); // Handle the primary base first. - if (PrimaryBase) { - uint64_t PrimaryBaseOffset; - + // We only want to add vcall offsets if the base is non-virtual; a virtual + // primary base will have its vcall and vbase offsets emitted already. + if (PrimaryBase && !Layout.getPrimaryBaseWasVirtual()) { // Get the base offset of the primary base. - if (Layout.getPrimaryBaseWasVirtual()) { - assert(Layout.getVBaseClassOffset(PrimaryBase) == 0 && - "Primary vbase should have a zero offset!"); - - const ASTRecordLayout &MostDerivedClassLayout = - Context.getASTRecordLayout(MostDerivedClass); - - PrimaryBaseOffset = - MostDerivedClassLayout.getVBaseClassOffset(PrimaryBase); - } else { - assert(Layout.getBaseClassOffset(PrimaryBase) == 0 && - "Primary base should have a zero offset!"); + assert(Layout.getBaseClassOffset(PrimaryBase) == 0 && + "Primary base should have a zero offset!"); - PrimaryBaseOffset = Base.getBaseOffset(); - } - - AddVCallOffsets(BaseSubobject(PrimaryBase, PrimaryBaseOffset), + AddVCallOffsets(BaseSubobject(PrimaryBase, Base.getBaseOffset()), VBaseOffset); } - + // Add the vcall offsets. for (CXXRecordDecl::method_iterator I = RD->method_begin(), E = RD->method_end(); I != E; ++I) { |