[cfe-commits] r136241 - in /cfe/trunk: lib/AST/Type.cpp lib/CodeGen/ItaniumCXXABI.cpp test/CodeGenCXX/delete.cpp

Eli Friedman eli.friedman at gmail.com
Wed Jul 27 11:54:57 PDT 2011


Author: efriedma
Date: Wed Jul 27 13:54:57 2011
New Revision: 136241

URL: http://llvm.org/viewvc/llvm-project?rev=136241&view=rev
Log:
Make CodeGen for array delete involving incomplete class work without crashing.  Should fix regression on g++.dg/init/delete1.C.


Modified:
    cfe/trunk/lib/AST/Type.cpp
    cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
    cfe/trunk/test/CodeGenCXX/delete.cpp

Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=136241&r1=136240&r2=136241&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Wed Jul 27 13:54:57 2011
@@ -2239,7 +2239,7 @@
   /// with non-trivial destructors.
   const CXXRecordDecl *record =
     type->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();
-  if (record && !record->hasTrivialDestructor())
+  if (record && record->hasDefinition() && !record->hasTrivialDestructor())
     return DK_cxx_destructor;
 
   return DK_none;

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=136241&r1=136240&r2=136241&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Wed Jul 27 13:54:57 2011
@@ -829,27 +829,7 @@
   if (expr->doesUsualArrayDeleteWantSize())
     return true;
 
-  // Automatic Reference Counting:
-  //   We need an array cookie for pointers with strong or weak lifetime.
-  if (getContext().getLangOptions().ObjCAutoRefCount &&
-      elementType->isObjCLifetimeType()) {
-    switch (elementType.getObjCLifetime()) {
-    case Qualifiers::OCL_None:
-    case Qualifiers::OCL_ExplicitNone:
-    case Qualifiers::OCL_Autoreleasing:
-      return false;
-
-    case Qualifiers::OCL_Strong:
-    case Qualifiers::OCL_Weak:
-      return true;
-    }
-  }
-  
-  // Otherwise, if the class has a non-trivial destructor, it always
-  // needs a cookie.
-  const CXXRecordDecl *record =
-    elementType->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();
-  return (record && !record->hasTrivialDestructor());
+  return elementType.isDestructedType();
 }
 
 CharUnits ItaniumCXXABI::GetArrayCookieSize(const CXXNewExpr *expr) {

Modified: cfe/trunk/test/CodeGenCXX/delete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/delete.cpp?rev=136241&r1=136240&r2=136241&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/delete.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/delete.cpp Wed Jul 27 13:54:57 2011
@@ -122,3 +122,12 @@
     ::delete xp;
   }
 }
+
+namespace test5 {
+  struct Incomplete;
+  // CHECK: define void @_ZN5test523array_delete_incompleteEPNS_10IncompleteE
+  void array_delete_incomplete(Incomplete *p) {
+    // CHECK: call void @_ZdlPv
+    delete [] p;
+  }
+}





More information about the cfe-commits mailing list