[clang] clang: Handle deleting pointers to incomplete array types (PR #150359)
Harald van Dijk via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 24 10:11:49 PDT 2025
================
@@ -2146,30 +2146,12 @@ void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) {
return;
}
- // We might be deleting a pointer to array. If so, GEP down to the
- // first non-array element.
- // (this assumes that A(*)[3][7] is converted to [3 x [7 x %A]]*)
- if (DeleteTy->isConstantArrayType()) {
- llvm::Value *Zero = Builder.getInt32(0);
- SmallVector<llvm::Value*,8> GEP;
-
- GEP.push_back(Zero); // point at the outermost array
-
- // For each layer of array type we're pointing at:
- while (const ConstantArrayType *Arr
- = getContext().getAsConstantArrayType(DeleteTy)) {
- // 1. Unpeel the array type.
- DeleteTy = Arr->getElementType();
-
- // 2. GEP to the first element of the array.
- GEP.push_back(Zero);
- }
-
- Ptr = Builder.CreateInBoundsGEP(Ptr, GEP, ConvertTypeForMem(DeleteTy),
- Ptr.getAlignment(), "del.first");
+ // We might be deleting a pointer to array.
+ while (const ArrayType *Arr = getContext().getAsArrayType(DeleteTy)) {
+ // Unpeel the array type.
+ DeleteTy = Arr->getElementType();
----------------
hvdijk wrote:
Tests continue to pass just fine with that change, so done.
https://github.com/llvm/llvm-project/pull/150359
More information about the cfe-commits
mailing list