[cfe-commits] r136180 - in /cfe/trunk: lib/CodeGen/CGCXX.cpp test/CodeGenCXX/abstract-class-ctors-dtors.cpp

Douglas Gregor dgregor at apple.com
Tue Jul 26 16:18:31 PDT 2011


Author: dgregor
Date: Tue Jul 26 18:18:30 2011
New Revision: 136180

URL: http://llvm.org/viewvc/llvm-project?rev=136180&view=rev
Log:
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>.

Modified:
    cfe/trunk/lib/CodeGen/CGCXX.cpp
    cfe/trunk/test/CodeGenCXX/abstract-class-ctors-dtors.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=136180&r1=136179&r2=136180&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Tue Jul 26 18:18:30 2011
@@ -236,11 +236,7 @@
 
   // 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.

Modified: cfe/trunk/test/CodeGenCXX/abstract-class-ctors-dtors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/abstract-class-ctors-dtors.cpp?rev=136180&r1=136179&r2=136180&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/abstract-class-ctors-dtors.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/abstract-class-ctors-dtors.cpp Tue Jul 26 18:18:30 2011
@@ -9,7 +9,7 @@
 
 // CHECK-NOT: define void @_ZN1AC1Ev
 // CHECK: define void @_ZN1AC2Ev
-// CHECK-NOT: define void @_ZN1AD1Ev
+// CHECK: define void @_ZN1AD1Ev
 // CHECK: define void @_ZN1AD2Ev
 A::A() { }
 





More information about the cfe-commits mailing list