[clang] [MS][clang] Error about ambiguous operator delete[] only when required (PR #135041)
Reid Kleckner via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 10 03:11:13 PDT 2025
================
@@ -11045,15 +11045,18 @@ bool Sema::CheckDestructor(CXXDestructorDecl *Destructor) {
DiagnoseUseOfDecl(OperatorDelete, Loc);
MarkFunctionReferenced(Loc, OperatorDelete);
Destructor->setOperatorDelete(OperatorDelete, ThisArg);
- // Lookup delete[] too in case we have to emit a vector deleting dtor;
- DeclarationName VDeleteName =
- Context.DeclarationNames.getCXXOperatorName(OO_Array_Delete);
- FunctionDecl *ArrOperatorDelete = FindDeallocationFunctionForDestructor(
- Loc, RD, VDeleteName, /*Diagnose=*/false);
- // delete[] in the TU will make sure the operator is referenced and its
- // uses diagnosed, otherwise vector deleting dtor won't be called anyway,
- // so just record it in the destructor.
- Destructor->setOperatorArrayDelete(ArrOperatorDelete);
+ if (Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+ // Lookup delete[] too in case we have to emit a vector deleting dtor;
+ DeclarationName VDeleteName =
+ Context.DeclarationNames.getCXXOperatorName(OO_Array_Delete);
+ FunctionDecl *ArrOperatorDelete = FindDeallocationFunctionForDestructor(
+ Loc, RD, VDeleteName,
+ Destructor->hasAttr<DLLExportAttr>() && Destructor->isDefined());
----------------
rnk wrote:
Right, that makes sense.
https://github.com/llvm/llvm-project/pull/135041
More information about the cfe-commits
mailing list