]> granicus.if.org Git - clang/commitdiff
Fix more i1/i8 pointer madness. Here, an overactive assertion
authorDouglas Gregor <dgregor@apple.com>
Thu, 2 Sep 2010 15:34:35 +0000 (15:34 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 2 Sep 2010 15:34:35 +0000 (15:34 +0000)
complains when the element type of a C++ "delete" expression is
different from what we would expect from the pointer type. When
deleting a bool*, we end up with an i1 on one side (where we compute
the LLVM type from the Clang bool type) and i8 on the other (where we
grab the LLVM type from the LLVM pointer type). I've weakened the
assertion appropriately, and the Boost Parallel Graph Library now
passes its regression tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112821 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprCXX.cpp
test/CodeGenCXX/delete.cpp

index 5e417605b1e4d081ef6c51f554ea1251098aa750..e0c8280e6b737c0a676b0326c686a1bc955f314c 100644 (file)
@@ -1018,8 +1018,9 @@ void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) {
     Ptr = Builder.CreateInBoundsGEP(Ptr, GEP.begin(), GEP.end(), "del.first");
   }
 
-  assert(ConvertType(DeleteTy) ==
-         cast<llvm::PointerType>(Ptr->getType())->getElementType());
+  assert(DeleteTy->isBooleanType() || 
+         (ConvertType(DeleteTy) ==
+          cast<llvm::PointerType>(Ptr->getType())->getElementType()));
 
   if (E->isArrayForm()) {
     EmitArrayDelete(*this, E->getOperatorDelete(), Ptr, DeleteTy);
index ec13d0cc0f80e6a6431a0cffc160b8acffd50416..1f52a783e6285bbc519485cbcdec57a4b2db6e40 100644 (file)
@@ -95,3 +95,13 @@ namespace test1 {
     // CHECK:      call void @_ZdaPv(i8* [[ALLOC]])
   }
 }
+
+namespace test2 {
+  // CHECK: define void @_ZN5test21fEPb
+  void f(bool *b) {
+    // CHECK: call void @_ZdlPv(i8*
+    delete b;
+    // CHECK: call void @_ZdaPv(i8*
+    delete [] b;
+  }
+}