From f9cce31a1c71e2949cd5f47616a5624f5fedd84d Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 2 Sep 2010 15:34:35 +0000 Subject: [PATCH] Fix more i1/i8 pointer madness. Here, an overactive assertion 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 | 5 +++-- test/CodeGenCXX/delete.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp index 5e417605b1..e0c8280e6b 100644 --- a/lib/CodeGen/CGExprCXX.cpp +++ b/lib/CodeGen/CGExprCXX.cpp @@ -1018,8 +1018,9 @@ void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) { Ptr = Builder.CreateInBoundsGEP(Ptr, GEP.begin(), GEP.end(), "del.first"); } - assert(ConvertType(DeleteTy) == - cast(Ptr->getType())->getElementType()); + assert(DeleteTy->isBooleanType() || + (ConvertType(DeleteTy) == + cast(Ptr->getType())->getElementType())); if (E->isArrayForm()) { EmitArrayDelete(*this, E->getOperatorDelete(), Ptr, DeleteTy); diff --git a/test/CodeGenCXX/delete.cpp b/test/CodeGenCXX/delete.cpp index ec13d0cc0f..1f52a783e6 100644 --- a/test/CodeGenCXX/delete.cpp +++ b/test/CodeGenCXX/delete.cpp @@ -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; + } +} -- 2.40.0