Don't make return adjustments for pure virtual member functions.

llvm-svn: 96120
This commit is contained in:
Anders Carlsson 2010-02-13 21:16:54 +00:00
parent cf5a882da1
commit c1290adab7
2 changed files with 25 additions and 5 deletions

View File

@ -426,11 +426,14 @@ void FinalOverriders::PropagateOverrider(const CXXMethodDecl *OldMD,
assert(Overrider.Method && "Did not find existing overrider!"); assert(Overrider.Method && "Did not find existing overrider!");
// Get the return adjustment base offset. // Get the return adjustment base offset.
BaseOffset ReturnBaseOffset = // (We don't want to do this for pure virtual member functions).
ComputeReturnTypeBaseOffset(Context, NewMD, OverriddenMD); if (!NewMD->isPure()) {
if (!ReturnBaseOffset.isEmpty()) { BaseOffset ReturnBaseOffset =
// Store the return adjustment base offset. ComputeReturnTypeBaseOffset(Context, NewMD, OverriddenMD);
ReturnAdjustments[SubobjectAndMethod] = ReturnBaseOffset; if (!ReturnBaseOffset.isEmpty()) {
// Store the return adjustment base offset.
ReturnAdjustments[SubobjectAndMethod] = ReturnBaseOffset;
}
} }
// Set the new overrider. // Set the new overrider.

View File

@ -182,6 +182,23 @@ struct E : A {
}; };
V3 *E::f() { return 0;} 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. // For now, just verify this doesn't crash.