[cfe-commits] r96120 - in /cfe/trunk: lib/CodeGen/CGVtable.cpp test/CodeGenCXX/vtable-layout.cpp
Anders Carlsson
andersca at mac.com
Sat Feb 13 13:16:54 PST 2010
Author: andersca
Date: Sat Feb 13 15:16:54 2010
New Revision: 96120
URL: http://llvm.org/viewvc/llvm-project?rev=96120&view=rev
Log:
Don't make return adjustments for pure virtual member functions.
Modified:
cfe/trunk/lib/CodeGen/CGVtable.cpp
cfe/trunk/test/CodeGenCXX/vtable-layout.cpp
Modified: cfe/trunk/lib/CodeGen/CGVtable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVtable.cpp?rev=96120&r1=96119&r2=96120&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVtable.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVtable.cpp Sat Feb 13 15:16:54 2010
@@ -426,11 +426,14 @@
assert(Overrider.Method && "Did not find existing overrider!");
// Get the return adjustment base offset.
- BaseOffset ReturnBaseOffset =
- ComputeReturnTypeBaseOffset(Context, NewMD, OverriddenMD);
- if (!ReturnBaseOffset.isEmpty()) {
- // Store the return adjustment base offset.
- ReturnAdjustments[SubobjectAndMethod] = ReturnBaseOffset;
+ // (We don't want to do this for pure virtual member functions).
+ if (!NewMD->isPure()) {
+ BaseOffset ReturnBaseOffset =
+ ComputeReturnTypeBaseOffset(Context, NewMD, OverriddenMD);
+ if (!ReturnBaseOffset.isEmpty()) {
+ // Store the return adjustment base offset.
+ ReturnAdjustments[SubobjectAndMethod] = ReturnBaseOffset;
+ }
}
// Set the new overrider.
Modified: cfe/trunk/test/CodeGenCXX/vtable-layout.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/vtable-layout.cpp?rev=96120&r1=96119&r2=96120&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/vtable-layout.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/vtable-layout.cpp Sat Feb 13 15:16:54 2010
@@ -182,6 +182,23 @@
};
V3 *E::f() { return 0;}
+// Test that a pure virtual member doesn't get a thunk.
+
+// CHECK: Vtable for 'Test4::F' (5 entries).
+// CHECK-NEXT: 0 | offset_to_top (0)
+// CHECK-NEXT: 1 | Test4::F RTTI
+// CHECK-NEXT: -- (Test4::A, 0) vtable address --
+// CHECK-NEXT: -- (Test4::F, 0) vtable address --
+// CHECK-NEXT: 2 | Test4::R3 *Test4::F::f() [pure]
+// CHECK-NEXT: 3 | void Test4::F::g()
+// CHECK-NEXT: 4 | Test4::R3 *Test4::F::f() [pure]
+struct F : A {
+ virtual void g();
+ virtual R3 *f() = 0;
+};
+
+void F::g() { }
+
}
// For now, just verify this doesn't crash.
More information about the cfe-commits
mailing list