================ @@ -3499,15 +3506,35 @@ bool FunctionDecl::isDestroyingOperatorDelete() const { // Within a class C, a single object deallocation function with signature // (T, std::destroying_delete_t, <more params>) // is a destroying operator delete. - if (!isa<CXXMethodDecl>(this) || getOverloadedOperator() != OO_Delete || - getNumParams() < 2) + if (!isa<CXXMethodDecl>(this) || getOverloadedOperator() != OO_Delete) + return false; + + unsigned DestroyingDeleteTagParam = 1; + if (isTypeAwareOperatorNewOrDelete()) + ++DestroyingDeleteTagParam; + + if (getNumParams() <= DestroyingDeleteTagParam) return false; - auto *RD = getParamDecl(1)->getType()->getAsCXXRecordDecl(); + auto *RD = + getParamDecl(DestroyingDeleteTagParam)->getType()->getAsCXXRecordDecl(); return RD && RD->isInStdNamespace() && RD->getIdentifier() && RD->getIdentifier()->isStr("destroying_delete_t"); } +bool FunctionDecl::isTypeAwareOperatorNewOrDelete() const { + if (getDeclName().getNameKind() != DeclarationName::CXXOperatorName) + return false; + if (getDeclName().getCXXOverloadedOperator() != OO_New && + getDeclName().getCXXOverloadedOperator() != OO_Delete && + getDeclName().getCXXOverloadedOperator() != OO_Array_New && + getDeclName().getCXXOverloadedOperator() != OO_Array_Delete) + return false; ---------------- cor3ntin wrote:
Maybe we should introduce ``` DeclarationName::isOperatorNew DeclarationName::isOperatorDelete DeclarationName::isOperatorNewOrDelete ``` to clean that up https://github.com/llvm/llvm-project/pull/113510 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits