diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-07-26 23:18:30 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-07-26 23:18:30 +0000 |
commit | 3e23d68e2e642db107b78aac2bb27585ed0ef337 (patch) | |
tree | 01f2962d4b4fe8336f71c8080f03e988c688e05b | |
parent | b056db932942200b407a24f1c6fe8428f8ff9490 (diff) |
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>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136180 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGCXX.cpp | 6 | ||||
-rw-r--r-- | test/CodeGenCXX/abstract-class-ctors-dtors.cpp | 2 |
2 files changed, 2 insertions, 6 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index f7f8a1271c..e1463e98ec 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -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. diff --git a/test/CodeGenCXX/abstract-class-ctors-dtors.cpp b/test/CodeGenCXX/abstract-class-ctors-dtors.cpp index e1c1a75e47..012c223155 100644 --- a/test/CodeGenCXX/abstract-class-ctors-dtors.cpp +++ b/test/CodeGenCXX/abstract-class-ctors-dtors.cpp @@ -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() { } |