llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-modules

Author: Mariya Podchishchaeva (Fznamznon)

<details>
<summary>Changes</summary>

Finding operator delete[] is still problematic, without it the extension is a 
security hazard, so reverting until the problem with operator delete[] is 
figured out.

---

Patch is 86.63 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/135611.diff


41 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (-1) 
- (modified) clang/include/clang/AST/DeclCXX.h (-6) 
- (modified) clang/include/clang/AST/VTableBuilder.h (+2-4) 
- (modified) clang/include/clang/Basic/ABI.h (+4-5) 
- (modified) clang/include/clang/Sema/Sema.h (-1) 
- (modified) clang/lib/AST/DeclCXX.cpp (-6) 
- (modified) clang/lib/AST/Expr.cpp (-3) 
- (modified) clang/lib/AST/ItaniumMangle.cpp (-2) 
- (modified) clang/lib/AST/MicrosoftMangle.cpp (+9-13) 
- (modified) clang/lib/AST/VTableBuilder.cpp (+6-13) 
- (modified) clang/lib/CodeGen/CGCXX.cpp (+1-36) 
- (modified) clang/lib/CodeGen/CGCXXABI.cpp (-14) 
- (modified) clang/lib/CodeGen/CGCXXABI.h (-7) 
- (modified) clang/lib/CodeGen/CGClass.cpp (+4-73) 
- (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+1-2) 
- (modified) clang/lib/CodeGen/CGExprCXX.cpp (+4-38) 
- (modified) clang/lib/CodeGen/CGVTables.cpp (+1-2) 
- (modified) clang/lib/CodeGen/CodeGenModule.cpp (-48) 
- (modified) clang/lib/CodeGen/CodeGenModule.h (-6) 
- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+1-5) 
- (modified) clang/lib/CodeGen/MicrosoftCXXABI.cpp (+14-38) 
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+1-20) 
- (modified) clang/lib/Sema/SemaExprCXX.cpp (+5-18) 
- (modified) clang/test/CodeGenCXX/debug-info-windows-dtor.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/dllexport.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/microsoft-abi-extern-template.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/microsoft-abi-structors.cpp (+2-3) 
- (modified) clang/test/CodeGenCXX/microsoft-abi-thunks.cpp (+2-1) 
- (modified) clang/test/CodeGenCXX/microsoft-abi-vftables.cpp (+10-10) 
- (modified) clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp (+8-9) 
- (modified) 
clang/test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance-vdtors.cpp
 (+9-9) 
- (modified) clang/test/CodeGenCXX/microsoft-abi-vtables-return-thunks.cpp 
(+1-1) 
- (modified) clang/test/CodeGenCXX/microsoft-abi-vtables-single-inheritance.cpp 
(+10-10) 
- (modified) 
clang/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp 
(+15-15) 
- (modified) 
clang/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp (+9-9) 
- (modified) clang/test/CodeGenCXX/microsoft-no-rtti-data.cpp (+1-1) 
- (removed) clang/test/CodeGenCXX/microsoft-vector-deleting-dtors.cpp (-218) 
- (modified) clang/test/CodeGenCXX/vtable-consteval.cpp (+2-2) 
- (modified) clang/test/Modules/vtable-windows.cppm (+1-1) 
- (modified) clang/test/Profile/cxx-abc-deleting-dtor.cpp (+5-4) 
- (removed) clang/test/SemaCXX/gh134265.cpp (-60) 


``````````diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fd9b9a80e9938..840a52a693c7a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -530,7 +530,6 @@ Windows Support
 - Clang now can process the `i128` and `ui128` integeral suffixes when MSVC
   extensions are enabled. This allows for properly processing ``intsafe.h`` in
   the Windows SDK.
-- Clang now supports MSVC vector deleting destructors (GH19772).
 
 LoongArch Support
 ^^^^^^^^^^^^^^^^^
diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 49d48bf711f33..dd325815ee28d 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -2852,7 +2852,6 @@ class CXXDestructorDecl : public CXXMethodDecl {
   // FIXME: Don't allocate storage for these except in the first declaration
   // of a virtual destructor.
   FunctionDecl *OperatorDelete = nullptr;
-  FunctionDecl *OperatorArrayDelete = nullptr;
   Expr *OperatorDeleteThisArg = nullptr;
 
   CXXDestructorDecl(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc,
@@ -2878,16 +2877,11 @@ class CXXDestructorDecl : public CXXMethodDecl {
   static CXXDestructorDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
 
   void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg);
-  void setOperatorArrayDelete(FunctionDecl *OD);
 
   const FunctionDecl *getOperatorDelete() const {
     return getCanonicalDecl()->OperatorDelete;
   }
 
-  const FunctionDecl *getArrayOperatorDelete() const {
-    return getCanonicalDecl()->OperatorArrayDelete;
-  }
-
   Expr *getOperatorDeleteThisArg() const {
     return getCanonicalDecl()->OperatorDeleteThisArg;
   }
diff --git a/clang/include/clang/AST/VTableBuilder.h 
b/clang/include/clang/AST/VTableBuilder.h
index e1efe8cddcc5e..a5de41dbc22f1 100644
--- a/clang/include/clang/AST/VTableBuilder.h
+++ b/clang/include/clang/AST/VTableBuilder.h
@@ -150,7 +150,7 @@ class VTableComponent {
 
   bool isRTTIKind() const { return isRTTIKind(getKind()); }
 
-  GlobalDecl getGlobalDecl(bool HasVectorDeletingDtors) const {
+  GlobalDecl getGlobalDecl() const {
     assert(isUsedFunctionPointerKind() &&
            "GlobalDecl can be created only from virtual function");
 
@@ -161,9 +161,7 @@ class VTableComponent {
     case CK_CompleteDtorPointer:
       return GlobalDecl(DtorDecl, CXXDtorType::Dtor_Complete);
     case CK_DeletingDtorPointer:
-      return GlobalDecl(DtorDecl, (HasVectorDeletingDtors)
-                                      ? CXXDtorType::Dtor_VectorDeleting
-                                      : CXXDtorType::Dtor_Deleting);
+      return GlobalDecl(DtorDecl, CXXDtorType::Dtor_Deleting);
     case CK_VCallOffset:
     case CK_VBaseOffset:
     case CK_OffsetToTop:
diff --git a/clang/include/clang/Basic/ABI.h b/clang/include/clang/Basic/ABI.h
index 48969e4f295c3..231bad799a42c 100644
--- a/clang/include/clang/Basic/ABI.h
+++ b/clang/include/clang/Basic/ABI.h
@@ -31,11 +31,10 @@ enum CXXCtorType {
 
 /// C++ destructor types.
 enum CXXDtorType {
-  Dtor_Deleting,      ///< Deleting dtor
-  Dtor_Complete,      ///< Complete object dtor
-  Dtor_Base,          ///< Base object dtor
-  Dtor_Comdat,        ///< The COMDAT used for dtors
-  Dtor_VectorDeleting ///< Vector deleting dtor
+    Dtor_Deleting, ///< Deleting dtor
+    Dtor_Complete, ///< Complete object dtor
+    Dtor_Base,     ///< Base object dtor
+    Dtor_Comdat    ///< The COMDAT used for dtors
 };
 
 } // end namespace clang
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 0595e3dff3bb9..5ab0af8234e26 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -8366,7 +8366,6 @@ class Sema final : public SemaBase {
                                               DeclarationName Name);
   FunctionDecl *FindDeallocationFunctionForDestructor(SourceLocation StartLoc,
                                                       CXXRecordDecl *RD,
-                                                      DeclarationName Name,
                                                       bool Diagnose = true);
 
   /// ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index d11225285c578..36131d19cbcdf 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -3064,12 +3064,6 @@ void CXXDestructorDecl::setOperatorDelete(FunctionDecl 
*OD, Expr *ThisArg) {
   }
 }
 
-void CXXDestructorDecl::setOperatorArrayDelete(FunctionDecl *OD) {
-  auto *First = cast<CXXDestructorDecl>(getFirstDecl());
-  if (OD && !First->OperatorArrayDelete)
-    First->OperatorArrayDelete = OD;
-}
-
 bool CXXDestructorDecl::isCalledByDelete(const FunctionDecl *OpDel) const {
   // C++20 [expr.delete]p6: If the value of the operand of the delete-
   // expression is not a null pointer value and the selected deallocation
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 4deed08d693ac..5fab2c73f214b 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -71,9 +71,6 @@ const CXXRecordDecl *Expr::getBestDynamicClassType() const {
   if (const PointerType *PTy = DerivedType->getAs<PointerType>())
     DerivedType = PTy->getPointeeType();
 
-  while (const ArrayType *ATy = DerivedType->getAsArrayTypeUnsafe())
-    DerivedType = ATy->getElementType();
-
   if (DerivedType->isDependentType())
     return nullptr;
 
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index c73f040ba1cb7..140f29b431fc3 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -6047,8 +6047,6 @@ void CXXNameMangler::mangleCXXDtorType(CXXDtorType T) {
   case Dtor_Comdat:
     Out << "D5";
     break;
-  case Dtor_VectorDeleting:
-    llvm_unreachable("Itanium ABI does not use vector deleting dtors");
   }
 }
 
diff --git a/clang/lib/AST/MicrosoftMangle.cpp 
b/clang/lib/AST/MicrosoftMangle.cpp
index 4d14614fc1ec7..ba6dbd99e0e1e 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -1490,9 +1490,8 @@ void 
MicrosoftCXXNameMangler::mangleCXXDtorType(CXXDtorType T) {
   // <operator-name> ::= ?_G # scalar deleting destructor
   case Dtor_Deleting: Out << "?_G"; return;
   // <operator-name> ::= ?_E # vector deleting destructor
-  case Dtor_VectorDeleting:
-    Out << "?_E";
-    return;
+  // FIXME: Add a vector deleting dtor type.  It goes in the vtable, so we need
+  // it.
   case Dtor_Comdat:
     llvm_unreachable("not expecting a COMDAT");
   }
@@ -2893,12 +2892,9 @@ void MicrosoftCXXNameMangler::mangleFunctionType(const 
FunctionType *T,
   //               ::= @ # structors (they have no declared return type)
   if (IsStructor) {
     if (isa<CXXDestructorDecl>(D) && isStructorDecl(D)) {
-      // The deleting destructors take an extra argument of type int that
-      // indicates whether the storage for the object should be deleted and
-      // whether a single object or an array of objects is being destroyed. 
This
-      // extra argument is not reflected in the AST.
-      if (StructorType == Dtor_Deleting ||
-          StructorType == Dtor_VectorDeleting) {
+      // The scalar deleting destructor takes an extra int argument which is 
not
+      // reflected in the AST.
+      if (StructorType == Dtor_Deleting) {
         Out << (PointersAre64Bit ? "PEAXI@Z" : "PAXI@Z");
         return;
       }
@@ -3871,10 +3867,10 @@ void 
MicrosoftMangleContextImpl::mangleCXXDtorThunk(const CXXDestructorDecl *DD,
                                                     const ThunkInfo &Thunk,
                                                     bool /*ElideOverrideInfo*/,
                                                     raw_ostream &Out) {
-  // The dtor thunk should use vector deleting dtor mangling, however as an
-  // optimization we may end up emitting only scalar deleting dtor body, so 
just
-  // use the vector deleting dtor mangling manually.
-  assert(Type == Dtor_Deleting || Type == Dtor_VectorDeleting);
+  // FIXME: Actually, the dtor thunk should be emitted for vector deleting
+  // dtors rather than scalar deleting dtors. Just use the vector deleting dtor
+  // mangling manually until we support both deleting dtor types.
+  assert(Type == Dtor_Deleting);
   msvc_hashing_ostream MHO(Out);
   MicrosoftCXXNameMangler Mangler(*this, MHO, DD, Type);
   Mangler.getStream() << "??_E";
diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index 21f9d343c6ee7..6c97b8718c65e 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -1735,8 +1735,8 @@ void 
ItaniumVTableBuilder::LayoutPrimaryAndSecondaryVTables(
       const CXXMethodDecl *MD = I.first;
       const MethodInfo &MI = I.second;
       if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(MD)) {
-        MethodVTableIndices[GlobalDecl(DD, Dtor_Complete)] =
-            MI.VTableIndex - AddressPoint;
+        MethodVTableIndices[GlobalDecl(DD, Dtor_Complete)]
+            = MI.VTableIndex - AddressPoint;
         MethodVTableIndices[GlobalDecl(DD, Dtor_Deleting)]
             = MI.VTableIndex + 1 - AddressPoint;
       } else {
@@ -2657,11 +2657,7 @@ class VFTableBuilder {
       MethodVFTableLocation Loc(MI.VBTableIndex, WhichVFPtr.getVBaseWithVPtr(),
                                 WhichVFPtr.NonVirtualOffset, MI.VFTableIndex);
       if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(MD)) {
-        // In Microsoft ABI vftable always references vector deleting dtor.
-        CXXDtorType DtorTy = Context.getTargetInfo().getCXXABI().isMicrosoft()
-                                 ? Dtor_VectorDeleting
-                                 : Dtor_Deleting;
-        MethodVFTableLocations[GlobalDecl(DD, DtorTy)] = Loc;
+        MethodVFTableLocations[GlobalDecl(DD, Dtor_Deleting)] = Loc;
       } else {
         MethodVFTableLocations[MD] = Loc;
       }
@@ -3291,10 +3287,7 @@ void VFTableBuilder::dumpLayout(raw_ostream &Out) {
       const CXXDestructorDecl *DD = Component.getDestructorDecl();
 
       DD->printQualifiedName(Out);
-      if (Context.getTargetInfo().getCXXABI().isMicrosoft())
-        Out << "() [vector deleting]";
-      else
-        Out << "() [scalar deleting]";
+      Out << "() [scalar deleting]";
 
       if (DD->isPureVirtual())
         Out << " [pure]";
@@ -3764,7 +3757,7 @@ void MicrosoftVTableContext::dumpMethodLocations(
         PredefinedIdentKind::PrettyFunctionNoVirtual, MD);
 
     if (isa<CXXDestructorDecl>(MD)) {
-      IndicesMap[I.second] = MethodName + " [vector deleting]";
+      IndicesMap[I.second] = MethodName + " [scalar deleting]";
     } else {
       IndicesMap[I.second] = MethodName;
     }
@@ -3880,7 +3873,7 @@ 
MicrosoftVTableContext::getMethodVFTableLocation(GlobalDecl GD) {
   assert(hasVtableSlot(cast<CXXMethodDecl>(GD.getDecl())) &&
          "Only use this method for virtual methods or dtors");
   if (isa<CXXDestructorDecl>(GD.getDecl()))
-    assert(GD.getDtorType() == Dtor_VectorDeleting);
+    assert(GD.getDtorType() == Dtor_Deleting);
 
   GD = GD.getCanonicalDecl();
 
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index 6f47e24eed5b3..78a7b021855b7 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -175,6 +175,7 @@ bool CodeGenModule::TryEmitBaseDestructorAsAlias(const 
CXXDestructorDecl *D) {
   // requires explicit comdat support in the IL.
   if (llvm::GlobalValue::isWeakForLinker(TargetLinkage))
     return true;
+
   // Create the alias with no name.
   auto *Alias = llvm::GlobalAlias::create(AliasValueType, 0, Linkage, "",
                                           Aliasee, &getModule());
@@ -200,42 +201,6 @@ bool CodeGenModule::TryEmitBaseDestructorAsAlias(const 
CXXDestructorDecl *D) {
   return false;
 }
 
-/// Emit a definition as a global alias for another definition, 
unconditionally.
-void CodeGenModule::EmitDefinitionAsAlias(GlobalDecl AliasDecl,
-                                          GlobalDecl TargetDecl) {
-
-  llvm::Type *AliasValueType = getTypes().GetFunctionType(AliasDecl);
-
-  StringRef MangledName = getMangledName(AliasDecl);
-  llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
-  if (Entry && !Entry->isDeclaration())
-    return;
-  auto *Aliasee = cast<llvm::GlobalValue>(GetAddrOfGlobal(TargetDecl));
-
-  // Determine the linkage type for the alias.
-  llvm::GlobalValue::LinkageTypes Linkage = getFunctionLinkage(AliasDecl);
-
-  // Create the alias with no name.
-  auto *Alias = llvm::GlobalAlias::create(AliasValueType, 0, Linkage, "",
-                                          Aliasee, &getModule());
-  // Destructors are always unnamed_addr.
-  Alias->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
-
-  if (Entry) {
-    assert(Entry->getValueType() == AliasValueType &&
-           Entry->getAddressSpace() == Alias->getAddressSpace() &&
-           "declaration exists with different type");
-    Alias->takeName(Entry);
-    Entry->replaceAllUsesWith(Alias);
-    Entry->eraseFromParent();
-  } else {
-    Alias->setName(MangledName);
-  }
-
-  // Set any additional necessary attributes for the alias.
-  SetCommonAttributes(AliasDecl, Alias);
-}
-
 llvm::Function *CodeGenModule::codegenCXXStructor(GlobalDecl GD) {
   const CGFunctionInfo &FnInfo = getTypes().arrangeCXXStructorDeclaration(GD);
   auto *Fn = cast<llvm::Function>(
diff --git a/clang/lib/CodeGen/CGCXXABI.cpp b/clang/lib/CodeGen/CGCXXABI.cpp
index 93dc17bac95e0..d42e0bb814a88 100644
--- a/clang/lib/CodeGen/CGCXXABI.cpp
+++ b/clang/lib/CodeGen/CGCXXABI.cpp
@@ -271,20 +271,6 @@ void CGCXXABI::ReadArrayCookie(CodeGenFunction &CGF, 
Address ptr,
   numElements = readArrayCookieImpl(CGF, allocAddr, cookieSize);
 }
 
-void CGCXXABI::ReadArrayCookie(CodeGenFunction &CGF, Address ptr,
-                               QualType eltTy, llvm::Value *&numElements,
-                               llvm::Value *&allocPtr, CharUnits &cookieSize) {
-  assert(eltTy.isDestructedType());
-
-  // Derive a char* in the same address space as the pointer.
-  ptr = ptr.withElementType(CGF.Int8Ty);
-
-  cookieSize = getArrayCookieSizeImpl(eltTy);
-  Address allocAddr = CGF.Builder.CreateConstInBoundsByteGEP(ptr, -cookieSize);
-  allocPtr = allocAddr.emitRawPointer(CGF);
-  numElements = readArrayCookieImpl(CGF, allocAddr, cookieSize);
-}
-
 llvm::Value *CGCXXABI::readArrayCookieImpl(CodeGenFunction &CGF,
                                            Address ptr,
                                            CharUnits cookieSize) {
diff --git a/clang/lib/CodeGen/CGCXXABI.h b/clang/lib/CodeGen/CGCXXABI.h
index da2d367da7096..96fe04661944d 100644
--- a/clang/lib/CodeGen/CGCXXABI.h
+++ b/clang/lib/CodeGen/CGCXXABI.h
@@ -275,7 +275,6 @@ class CGCXXABI {
   virtual CatchTypeInfo getCatchAllTypeInfo();
 
   virtual bool shouldTypeidBeNullChecked(QualType SrcRecordTy) = 0;
-  virtual bool hasVectorDeletingDtors() = 0;
   virtual void EmitBadTypeidCall(CodeGenFunction &CGF) = 0;
   virtual llvm::Value *EmitTypeid(CodeGenFunction &CGF, QualType SrcRecordTy,
                                   Address ThisPtr,
@@ -576,12 +575,6 @@ class CGCXXABI {
                                QualType ElementType, llvm::Value *&NumElements,
                                llvm::Value *&AllocPtr, CharUnits &CookieSize);
 
-  /// Reads the array cookie associated with the given pointer,
-  /// that should have one.
-  void ReadArrayCookie(CodeGenFunction &CGF, Address Ptr, QualType ElementType,
-                       llvm::Value *&NumElements, llvm::Value *&AllocPtr,
-                       CharUnits &CookieSize);
-
   /// Return whether the given global decl needs a VTT parameter.
   virtual bool NeedsVTTParameter(GlobalDecl GD);
 
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index 0f2422a6a665a..1c73a5bf75f37 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -1429,70 +1429,6 @@ static bool 
CanSkipVTablePointerInitialization(CodeGenFunction &CGF,
   return true;
 }
 
-static void EmitConditionalArrayDtorCall(const CXXDestructorDecl *DD,
-                                         CodeGenFunction &CGF,
-                                         llvm::Value *ShouldDeleteCondition) {
-  Address ThisPtr = CGF.LoadCXXThisAddress();
-  llvm::BasicBlock *ScalarBB = CGF.createBasicBlock("dtor.scalar");
-  llvm::BasicBlock *callDeleteBB =
-      CGF.createBasicBlock("dtor.call_delete_after_array_destroy");
-  llvm::BasicBlock *VectorBB = CGF.createBasicBlock("dtor.vector");
-  auto *CondTy = cast<llvm::IntegerType>(ShouldDeleteCondition->getType());
-  llvm::Value *CheckTheBitForArrayDestroy = CGF.Builder.CreateAnd(
-      ShouldDeleteCondition, llvm::ConstantInt::get(CondTy, 2));
-  llvm::Value *ShouldDestroyArray =
-      CGF.Builder.CreateIsNull(CheckTheBitForArrayDestroy);
-  CGF.Builder.CreateCondBr(ShouldDestroyArray, ScalarBB, VectorBB);
-
-  CGF.EmitBlock(VectorBB);
-
-  llvm::Value *numElements = nullptr;
-  llvm::Value *allocatedPtr = nullptr;
-  CharUnits cookieSize;
-  QualType EltTy = DD->getThisType()->getPointeeType();
-  CGF.CGM.getCXXABI().ReadArrayCookie(CGF, ThisPtr, EltTy, numElements,
-                                      allocatedPtr, cookieSize);
-
-  // Destroy the elements.
-  QualType::DestructionKind dtorKind = EltTy.isDestructedType();
-
-  assert(dtorKind);
-  assert(numElements && "no element count for a type with a destructor!");
-
-  CharUnits elementSize = CGF.getContext().getTypeSizeInChars(EltTy);
-  CharUnits elementAlign =
-      ThisPtr.getAlignment().alignmentOfArrayElement(elementSize);
-
-  llvm::Value *arrayBegin = ThisPtr.emitRawPointer(CGF);
-  llvm::Value *arrayEnd = CGF.Builder.CreateInBoundsGEP(
-      ThisPtr.getElementType(), arrayBegin, numElements, "delete.end");
-
-  // We already checked that the array is not 0-length before entering vector
-  // deleting dtor.
-  CGF.emitArrayDestroy(arrayBegin, arrayEnd, EltTy, elementAlign,
-                       CGF.getDestroyer(dtorKind),
-                       /*checkZeroLength*/ false, 
CGF.needsEHCleanup(dtorKind));
-
-  llvm::BasicBlock *VectorBBCont = CGF.createBasicBlock("dtor.vector.cont");
-  CGF.EmitBlock(VectorBBCont);
-
-  llvm::Value *CheckTheBitForDeleteCall = CGF.Builder.CreateAnd(
-      ShouldDeleteCondition, llvm::ConstantInt::get(CondTy, 1));
-
-  llvm::Value *ShouldCallDelete =
-      CGF.Builder.CreateIsNull(CheckTheBitForDeleteCall);
-  CGF.Builder.CreateCondBr(ShouldCallDelete, CGF.ReturnBlock.getBlock(),
-                           callDeleteBB);
-  CGF.EmitBlock(callDeleteBB);
-  const CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(CGF.CurCodeDecl);
-  const CXXRecordDecl *ClassDecl = Dtor->getParent();
-  CGF.EmitDeleteCall(Dtor->getArrayOperatorDelete(), allocatedPtr,
-                     CGF.getContext().getTagDeclType(ClassDecl));
-
-  CGF.EmitBranchThroughCleanup(CGF.ReturnBlock);
-  CGF.EmitBlock(ScalarBB);
-}
-
 /// EmitDestructorBody - Emits the body of the current destructor.
 void CodeGenFunction::EmitDestructorBody(FunctionArgList &Args) {
   const CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(CurGD.getDecl());
@@ -1522,9 +1458,7 @@ void CodeGenFunction::EmitDestructorBody(FunctionArgList 
&Args) {
   // outside of the function-try-block, which means it's always
   // possible to delegate the destructor body to the complete
   // destructor.  Do so.
-  if (DtorType == Dtor_Deleting || DtorType == Dtor_VectorDeleting) {
-    if (CXXStructorImplicitParamValue && DtorType == Dtor_VectorDeleting)
-      EmitConditionalArrayDtorCall(Dtor, *this, CXXStructorImplicitParamValue);
+  if (DtorType == Dtor_Deleting) {
     RunCleanupsScope DtorEpilogue(*this);
     EnterDtorCleanups(Dtor, Dtor_Deleting);
     if (HaveInsertPoint()) {
@@ -1553,8 +1487,6 @@ void CodeGenFunction::EmitDestructorBody(FunctionArgList 
&Args) {
   switch (DtorType) {
   case Dtor_Comdat: llvm_unreachable("not expecting a COMDAT");
   case Dtor_Deleting: llvm_unreachable("already handled deleting case");
-  case Dtor_VectorDeleting:
-    llvm_unreachable("already handled vector deleting case");
 
   case Dtor_Complete:
     assert((Body || getTarget().getCXXABI().isMicrosoft()) &&
@@ -1637,6 +1569,7 @@ namespace {
       return CGF.EmitScalarExpr(ThisArg);
     return CGF.LoadCXXThis();
   }
+
   /// Call the operator delete associated with the curre...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/135611
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to