Disable the optimization that skips emission of complete, non-virtual

destructors of abstract classes. It's undefined behavior to actually
call the destructor (e.g., via delete), but the presence of code that
calls this destructor doesn't make the program
ill-formed. Fixes <rdar://problem/9819242>.

llvm-svn: 136180
This commit is contained in:
Douglas Gregor 2011-07-26 23:18:30 +00:00
parent ebc113d1d3
commit 8771796493
2 changed files with 2 additions and 6 deletions

View File

@ -236,11 +236,7 @@ void CodeGenModule::EmitCXXDestructors(const CXXDestructorDecl *D) {
// The destructor used for destructing this as a most-derived class;
// call the base destructor and then destructs any virtual bases.
if (!D->getParent()->isAbstract() || D->isVirtual()) {
// We don't need to emit the complete ctor if the class is abstract,
// unless the destructor is virtual and needs to be in the vtable.
EmitGlobal(GlobalDecl(D, Dtor_Complete));
}
EmitGlobal(GlobalDecl(D, Dtor_Complete));
// The destructor used for destructing this as a base class; ignores
// virtual bases.

View File

@ -9,7 +9,7 @@ struct A {
// CHECK-NOT: define void @_ZN1AC1Ev
// CHECK: define void @_ZN1AC2Ev
// CHECK-NOT: define void @_ZN1AD1Ev
// CHECK: define void @_ZN1AD1Ev
// CHECK: define void @_ZN1AD2Ev
A::A() { }