[cfe-commits] r96590 - in /cfe/trunk: lib/CodeGen/CGVtable.cpp test/CodeGenCXX/vtable-layout-abi-examples.cpp
Anders Carlsson
andersca at mac.com
Thu Feb 18 09:32:33 PST 2010
Author: andersca
Date: Thu Feb 18 11:32:33 2010
New Revision: 96590
URL: http://llvm.org/viewvc/llvm-project?rev=96590&view=rev
Log:
Fix another bug and add another class.
Modified:
cfe/trunk/lib/CodeGen/CGVtable.cpp
cfe/trunk/test/CodeGenCXX/vtable-layout-abi-examples.cpp
Modified: cfe/trunk/lib/CodeGen/CGVtable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVtable.cpp?rev=96590&r1=96589&r2=96590&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVtable.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVtable.cpp Thu Feb 18 11:32:33 2010
@@ -1138,9 +1138,17 @@
const ASTRecordLayout &MostDerivedClassLayout =
Context.getASTRecordLayout(MostDerivedClass);
- // FIXME: We should not use / 8 here.
+ FinalOverriders::OverriderInfo Overrider =
+ Overriders.getOverrider(Base, MD);
+
Offset =
- -(int64_t)MostDerivedClassLayout.getVBaseClassOffset(VBaseDecl) / 8;
+ -(int64_t)MostDerivedClassLayout.getVBaseClassOffset(VBaseDecl);
+
+ // The base offset should be relative to the final overrider.
+ Offset += Overrider.BaseOffset;
+
+ // FIXME: We should not use / 8 here.
+ Offset = Offset / 8;
}
VCallAndVBaseOffsets.push_back(VtableComponent::MakeVCallOffset(Offset));
Modified: cfe/trunk/test/CodeGenCXX/vtable-layout-abi-examples.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/vtable-layout-abi-examples.cpp?rev=96590&r1=96589&r2=96590&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/vtable-layout-abi-examples.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/vtable-layout-abi-examples.cpp Thu Feb 18 11:32:33 2010
@@ -71,4 +71,38 @@
int ic;
};
void C::g() {}
+
+// CHECK: Vtable for 'Test1::D' (18 entries).
+// CHECK-NEXT: 0 | vbase_offset (32)
+// CHECK-NEXT: 1 | offset_to_top (0)
+// CHECK-NEXT: 2 | Test1::D RTTI
+// CHECK-NEXT: -- (Test1::B, 0) vtable address --
+// CHECK-NEXT: -- (Test1::D, 0) vtable address --
+// CHECK-NEXT: 3 | void Test1::B::f()
+// CHECK-NEXT: 4 | void Test1::D::h()
+// CHECK-NEXT: 5 | vbase_offset (16)
+// CHECK-NEXT: 6 | offset_to_top (-16)
+// CHECK-NEXT: 7 | Test1::D RTTI
+// CHECK-NEXT: -- (Test1::C, 16) vtable address --
+// CHECK-NEXT: 8 | void Test1::C::g()
+// CHECK-NEXT: 9 | void Test1::D::h()
+// CHECK-NEXT: [this adjustment: -16 non-virtual]
+// CHECK-NEXT: 10 | vcall_offset (-32)
+// CHECK-NEXT: 11 | vcall_offset (-16)
+// CHECK-NEXT: 12 | vcall_offset (-32)
+// CHECK-NEXT: 13 | offset_to_top (-32)
+// CHECK-NEXT: 14 | Test1::D RTTI
+// CHECK-NEXT: -- (Test1::A, 32) vtable address --
+// CHECK-NEXT: 15 | void Test1::B::f()
+// CHECK-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
+// CHECK-NEXT: 16 | void Test1::C::g()
+// CHECK-NEXT: [this adjustment: 0 non-virtual, -32 vcall offset offset]
+// CHECK-NEXT: 17 | void Test1::D::h()
+// CHECK-NEXT: [this adjustment: 0 non-virtual, -40 vcall offset offset]
+struct D: public B, public C {
+ void h ();
+ int id;
+};
+void D::h() { }
+
}
More information about the cfe-commits
mailing list