[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-07 Thread Erich Keane via cfe-commits
https://github.com/erichkeane edited 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

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-07 Thread Aaron Ballman via cfe-commits
@@ -9753,27 +9753,46 @@ def err_operator_new_delete_invalid_result_type : Error< def err_operator_new_delete_dependent_result_type : Error< "%0 cannot have a dependent return type; use %1 instead">; def err_operator_new_delete_too_few_parameters : Error< - "%0 must have at l

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-07 Thread via cfe-commits
https://github.com/cor3ntin edited 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

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-07 Thread via cfe-commits
@@ -16421,33 +16715,70 @@ CheckOperatorDeleteDeclaration(Sema &SemaRef, FunctionDecl *FnDecl) { return true; auto *MD = dyn_cast(FnDecl); + auto ConstructDestroyingDeleteAddressType = [&]() { +assert(MD); +return SemaRef.Context.getCanonicalType(SemaRef.Context

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-07 Thread via cfe-commits
@@ -9753,27 +9753,46 @@ def err_operator_new_delete_invalid_result_type : Error< def err_operator_new_delete_dependent_result_type : Error< "%0 cannot have a dependent return type; use %1 instead">; def err_operator_new_delete_too_few_parameters : Error< - "%0 must have at l

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-07 Thread via cfe-commits
@@ -9753,27 +9753,46 @@ def err_operator_new_delete_invalid_result_type : Error< def err_operator_new_delete_dependent_result_type : Error< "%0 cannot have a dependent return type; use %1 instead">; def err_operator_new_delete_too_few_parameters : Error< - "%0 must have at l

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-07 Thread via cfe-commits
https://github.com/cor3ntin commented: A few nits. My intent is to approve the pr once they are addressed @AaronBallman @erichkeane https://github.com/llvm/llvm-project/pull/113510 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-05 Thread Oliver Hunt via cfe-commits
@@ -16223,6 +16324,70 @@ bool Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor, return Invalid; } +bool Sema::isTypeAwareOperatorNewOrDelete(const NamedDecl *ND) const { + const FunctionDecl *FnDecl = nullptr; ojhunt wrote: Removed and replac

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-05 Thread Oliver Hunt via cfe-commits
@@ -2234,6 +2234,101 @@ enum class CXXNewInitializationStyle { Braces }; +enum class TypeAwareAllocationMode : unsigned { No, Yes }; +inline bool isTypeAwareAllocation(TypeAwareAllocationMode Mode) { + return Mode == TypeAwareAllocationMode::Yes; +} +inline TypeAwareAllocat

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-05 Thread Oliver Hunt via cfe-commits
@@ -312,6 +312,7 @@ LANGOPT(OpenACC , 1, 0, "OpenACC Enabled") LANGOPT(MSVCEnableStdcMacro , 1, 0, "Define __STDC__ with '-fms-compatibility'") LANGOPT(SizedDeallocation , 1, 0, "sized deallocation") +LANGOPT(TypeAwareAllocators , 1, 1, "type aware C++ allocation op

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-05 Thread Oliver Hunt via cfe-commits
@@ -7353,6 +7354,69 @@ void Sema::CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record) { else if (Record->hasAttr()) checkCUDADeviceBuiltinTextureClassTemplate(*this, Record); } + + llvm::SmallVector TypeAwareNewDecls; + llvm::SmallVector TypeAwareDeleteDecls;

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-05 Thread Oliver Hunt via cfe-commits
@@ -7353,6 +7354,69 @@ void Sema::CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record) { else if (Record->hasAttr()) checkCUDADeviceBuiltinTextureClassTemplate(*this, Record); } + + llvm::SmallVector TypeAwareNewDecls; + llvm::SmallVector TypeAwareDeleteDecls;

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-05 Thread Oliver Hunt via cfe-commits
@@ -2527,6 +2527,32 @@ class FunctionDecl : public DeclaratorDecl, /// If this function is an allocation/deallocation function that takes /// the `std::nothrow_t` tag, return true through IsNothrow, bool isReplaceableGlobalAllocationFunction( + std::optional *Alignme

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-05 Thread Matheus Izvekov via cfe-commits
@@ -1098,12 +1098,39 @@ static TypeSourceInfo *getTypeSourceInfoForStdAlignValT(Sema &S, return S.Context.getTrivialTypeSourceInfo(StdAlignValDecl); } +// When searching for custom allocators on the PromiseType we want to +// warn that we will ignore type aware allocators.

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-05 Thread Matheus Izvekov via cfe-commits
@@ -16439,33 +16735,70 @@ CheckOperatorDeleteDeclaration(Sema &SemaRef, FunctionDecl *FnDecl) { return true; auto *MD = dyn_cast(FnDecl); + auto ConstructDestroyingDeleteAddressType = [&]() { +assert(MD); +return SemaRef.Context.getCanonicalType(SemaRef.Context

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-05 Thread Oliver Hunt via cfe-commits
@@ -2474,19 +2474,46 @@ bool CXXMethodDecl::isUsualDeallocationFunction( getOverloadedOperator() != OO_Array_Delete) return false; + auto NumParams = getNumParams(); + bool IsTypeAware = IsTypeAwareOperatorNewOrDelete(); + // C++ [basic.stc.dynamic.deallocation]

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-05 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt edited 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

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-05 Thread Matheus Izvekov via cfe-commits
@@ -1098,12 +1098,39 @@ static TypeSourceInfo *getTypeSourceInfoForStdAlignValT(Sema &S, return S.Context.getTrivialTypeSourceInfo(StdAlignValDecl); } +// When searching for custom allocators on the PromiseType we want to +// warn that we will ignore type aware allocators.

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-04 Thread Oliver Hunt via cfe-commits
@@ -17389,6 +17389,19 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, Previous.clear(); } + // I think DC check should be DC->isStdNamespace()? ojhunt wrote: @erichkeane so I think this was a case where the test can

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-04 Thread via cfe-commits
@@ -16147,6 +16169,108 @@ bool Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor, return Invalid; } +bool Sema::isTypeAwareOperatorNewOrDelete(const NamedDecl *ND) const { + const FunctionDecl *FnDecl = nullptr; + if (auto *FTD = dyn_cast(ND)) +FnDecl = FT

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-02 Thread Oliver Hunt via cfe-commits
@@ -1095,12 +1095,40 @@ static TypeSourceInfo *getTypeSourceInfoForStdAlignValT(Sema &S, return S.Context.getTrivialTypeSourceInfo(StdAlignValDecl); } +// When searching for custom allocators on the PromiseType we want to +// warn that we will ignore type aware allocators.

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-02 Thread Oliver Hunt via cfe-commits
@@ -3096,6 +3096,29 @@ bool Type::isStdByteType() const { return false; } +TemplateDecl *Type::getSpecializedTemplateDecl() const { + const auto *DesugaredType = getUnqualifiedDesugaredType(); + if (auto *Specialization = DesugaredType->getAs()) +return Specialization

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-02 Thread Oliver Hunt via cfe-commits
@@ -1586,8 +1597,22 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() { if (NewRef.isInvalid()) return false; - SmallVector NewArgs(1, FrameSize); - if (S.getLangOpts().CoroAlignedAllocation && PassAlignment) + SmallVector NewArgs; + if (IAP.PassTypeIdentity) { +

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-01 Thread Oliver Hunt via cfe-commits
@@ -9688,6 +9688,18 @@ def err_operator_delete_param_type : Error< def err_destroying_operator_delete_not_usual : Error< "destroying operator delete can have only an optional size and optional " "alignment parameter">; +def err_type_aware_destroying_operator_delete : Error<

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-01 Thread Oliver Hunt via cfe-commits
@@ -2474,19 +2474,46 @@ bool CXXMethodDecl::isUsualDeallocationFunction( getOverloadedOperator() != OO_Array_Delete) return false; + auto NumParams = getNumParams(); ojhunt wrote: Done. https://github.com/llvm/llvm-project/pull/113510 _

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-01 Thread Oliver Hunt via cfe-commits
@@ -3482,15 +3486,40 @@ bool FunctionDecl::isDestroyingOperatorDelete() const { // Within a class C, a single object deallocation function with signature // (T, std::destroying_delete_t, ) // is a destroying operator delete. - if (!isa(this) || getOverloadedOpera

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-01 Thread Oliver Hunt via cfe-commits
@@ -1392,7 +1393,13 @@ static UsualDeleteParams getUsualDeleteParams(const FunctionDecl *FD) { const FunctionProtoType *FPT = FD->getType()->castAs(); auto AI = FPT->param_type_begin(), AE = FPT->param_type_end(); - // The first argument is always a void*. + if (FD->isT

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-01 Thread Oliver Hunt via cfe-commits
@@ -3096,6 +3096,29 @@ bool Type::isStdByteType() const { return false; } +TemplateDecl *Type::getSpecializedTemplateDecl() const { + const auto *DesugaredType = getUnqualifiedDesugaredType(); + if (auto *Specialization = DesugaredType->getAs()) +return Specialization

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-01 Thread Oliver Hunt via cfe-commits
@@ -16147,6 +16169,108 @@ bool Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor, return Invalid; } +bool Sema::isTypeAwareOperatorNewOrDelete(const NamedDecl *ND) const { + const FunctionDecl *FnDecl = nullptr; + if (auto *FTD = dyn_cast(ND)) +FnDecl = FT

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-01 Thread Oliver Hunt via cfe-commits
@@ -1435,6 +1444,8 @@ namespace { unsigned NumPlacementArgs : 31; LLVM_PREFERRED_TYPE(bool) unsigned PassAlignmentToPlacementDelete : 1; +LLVM_PREFERRED_TYPE(bool) +unsigned PassTypeToPlacementDelete : 1; ojhunt wrote: Should we add a stati

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-01 Thread Oliver Hunt via cfe-commits
@@ -9817,27 +9817,54 @@ def err_operator_new_delete_invalid_result_type : Error< def err_operator_new_delete_dependent_result_type : Error< "%0 cannot have a dependent return type; use %1 instead">; def err_operator_new_delete_too_few_parameters : Error< - "%0 must have at l

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-01 Thread Oliver Hunt via cfe-commits
@@ -1586,8 +1597,22 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() { if (NewRef.isInvalid()) return false; - SmallVector NewArgs(1, FrameSize); - if (S.getLangOpts().CoroAlignedAllocation && PassAlignment) + SmallVector NewArgs; + if (IAP.PassTypeIdentity) { +

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-01 Thread Oliver Hunt via cfe-commits
@@ -2474,19 +2474,46 @@ bool CXXMethodDecl::isUsualDeallocationFunction( getOverloadedOperator() != OO_Array_Delete) return false; + auto NumParams = getNumParams(); + bool IsTypeAware = IsTypeAwareOperatorNewOrDelete(); + // C++ [basic.stc.dynamic.deallocation]

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-01 Thread Oliver Hunt via cfe-commits
@@ -16110,6 +16128,127 @@ bool Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor, return Invalid; } +bool Sema::IsTypeIdentitySpecialization(QualType Type) const { + auto *TypeIdentity = getStdTypeIdentity(); + if (!TypeIdentity) +return false; + auto *Sp

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-01 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt commented: > *[Reviewable](https://reviewable.io/reviews/llvm/llvm-project/113510)* > status: 0 of 62 files reviewed, 127 unresolved discussions (waiting on > @AaronBallman, @Bigcheese, @ChuanqiXu9, @cor3ntin, @efriedma-quic, > @erichkeane, @mizvekov, @ogiroux, @Sir

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-01 Thread Oliver Hunt via cfe-commits
@@ -1466,17 +1477,30 @@ namespace { void Emit(CodeGenFunction &CGF, Flags flags) override { const auto *FPT = OperatorDelete->getType()->castAs(); CallArgList DeleteArgs; - - // The first argument is always a void* (or C* for a destroying operator - //

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-01 Thread Oliver Hunt via cfe-commits
@@ -2527,6 +2527,32 @@ class FunctionDecl : public DeclaratorDecl, /// If this function is an allocation/deallocation function that takes /// the `std::nothrow_t` tag, return true through IsNothrow, bool isReplaceableGlobalAllocationFunction( + std::optional *Alignme

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-31 Thread Oliver Hunt via cfe-commits
@@ -1098,12 +1098,39 @@ static TypeSourceInfo *getTypeSourceInfoForStdAlignValT(Sema &S, return S.Context.getTrivialTypeSourceInfo(StdAlignValDecl); } +// When searching for custom allocators on the PromiseType we want to +// warn that we will ignore type aware allocators.

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-31 Thread Matheus Izvekov via cfe-commits
@@ -1098,12 +1098,39 @@ static TypeSourceInfo *getTypeSourceInfoForStdAlignValT(Sema &S, return S.Context.getTrivialTypeSourceInfo(StdAlignValDecl); } +// When searching for custom allocators on the PromiseType we want to +// warn that we will ignore type aware allocators.

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-31 Thread Oliver Hunt via cfe-commits
@@ -16327,79 +16531,181 @@ static CanQualType RemoveAddressSpaceFromPtr(Sema &SemaRef, PtrTy->getPointeeType().getUnqualifiedType(), PtrQuals))); } -static inline bool -CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl, -C

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-31 Thread Oliver Hunt via cfe-commits
@@ -1098,12 +1098,39 @@ static TypeSourceInfo *getTypeSourceInfoForStdAlignValT(Sema &S, return S.Context.getTrivialTypeSourceInfo(StdAlignValDecl); } +// When searching for custom allocators on the PromiseType we want to +// warn that we will ignore type aware allocators.

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-31 Thread Oliver Hunt via cfe-commits
@@ -7353,6 +7354,69 @@ void Sema::CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record) { else if (Record->hasAttr()) checkCUDADeviceBuiltinTextureClassTemplate(*this, Record); } + + llvm::SmallVector TypeAwareNewDecls; + llvm::SmallVector TypeAwareDeleteDecls;

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-30 Thread Oliver Hunt via cfe-commits
@@ -16327,79 +16531,181 @@ static CanQualType RemoveAddressSpaceFromPtr(Sema &SemaRef, PtrTy->getPointeeType().getUnqualifiedType(), PtrQuals))); } -static inline bool -CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl, -C

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-30 Thread Matheus Izvekov via cfe-commits
@@ -7353,6 +7354,69 @@ void Sema::CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record) { else if (Record->hasAttr()) checkCUDADeviceBuiltinTextureClassTemplate(*this, Record); } + + llvm::SmallVector TypeAwareNewDecls; + llvm::SmallVector TypeAwareDeleteDecls;

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-30 Thread Oliver Hunt via cfe-commits
@@ -7353,6 +7354,69 @@ void Sema::CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record) { else if (Record->hasAttr()) checkCUDADeviceBuiltinTextureClassTemplate(*this, Record); } + + llvm::SmallVector TypeAwareNewDecls; + llvm::SmallVector TypeAwareDeleteDecls;

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-30 Thread Oliver Hunt via cfe-commits
@@ -16439,33 +16735,70 @@ CheckOperatorDeleteDeclaration(Sema &SemaRef, FunctionDecl *FnDecl) { return true; auto *MD = dyn_cast(FnDecl); + auto ConstructDestroyingDeleteAddressType = [&]() { +assert(MD); +return SemaRef.Context.getCanonicalType(SemaRef.Context

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-30 Thread Matheus Izvekov via cfe-commits
@@ -16327,79 +16531,181 @@ static CanQualType RemoveAddressSpaceFromPtr(Sema &SemaRef, PtrTy->getPointeeType().getUnqualifiedType(), PtrQuals))); } -static inline bool -CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl, -C

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-30 Thread Matheus Izvekov via cfe-commits
@@ -7353,6 +7354,69 @@ void Sema::CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record) { else if (Record->hasAttr()) checkCUDADeviceBuiltinTextureClassTemplate(*this, Record); } + + llvm::SmallVector TypeAwareNewDecls; + llvm::SmallVector TypeAwareDeleteDecls;

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-30 Thread Matheus Izvekov via cfe-commits
@@ -9817,27 +9817,54 @@ def err_operator_new_delete_invalid_result_type : Error< def err_operator_new_delete_dependent_result_type : Error< "%0 cannot have a dependent return type; use %1 instead">; def err_operator_new_delete_too_few_parameters : Error< - "%0 must have at l

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-30 Thread Matheus Izvekov via cfe-commits
@@ -16327,79 +16531,181 @@ static CanQualType RemoveAddressSpaceFromPtr(Sema &SemaRef, PtrTy->getPointeeType().getUnqualifiedType(), PtrQuals))); } -static inline bool -CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl, -C

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-30 Thread Matheus Izvekov via cfe-commits
@@ -16327,79 +16531,181 @@ static CanQualType RemoveAddressSpaceFromPtr(Sema &SemaRef, PtrTy->getPointeeType().getUnqualifiedType(), PtrQuals))); } -static inline bool -CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl, -C

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-30 Thread Oliver Hunt via cfe-commits
@@ -1466,17 +1477,30 @@ namespace { void Emit(CodeGenFunction &CGF, Flags flags) override { const auto *FPT = OperatorDelete->getType()->castAs(); CallArgList DeleteArgs; - - // The first argument is always a void* (or C* for a destroying operator - //

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-29 Thread Oliver Hunt via cfe-commits
@@ -0,0 +1,145 @@ +// RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify %s -std=c++26 -fcoroutines -fexceptions -Wall -Wpedantic + + +#include "Inputs/std-coroutine.h" + +namespace std { + template struct type_identity { + typedef T type; + }; + typedef __

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-29 Thread Oliver Hunt via cfe-commits
@@ -3128,6 +3128,26 @@ bool Type::isStdByteType() const { return false; } +static const TemplateDecl *getSpecializedTemplateType(const Type *T) { + const Type *DesugaredType = T->getUnqualifiedDesugaredType(); + if (const auto *Specialization = + DesugaredType->ge

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-29 Thread Oliver Hunt via cfe-commits
@@ -477,6 +477,44 @@ class DeclarationName { return OO_None; } + bool isOperatorNew() const { +if (getNameKind() != DeclarationName::CXXOperatorName) + return false; +switch (getCXXOverloadedOperator()) { +case OO_New: +case OO_Array_New: + ret

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-29 Thread Oliver Hunt via cfe-commits
@@ -307,6 +307,10 @@ EXTENSION(datasizeof, LangOpts.CPlusPlus) FEATURE(cxx_abi_relative_vtable, LangOpts.CPlusPlus && LangOpts.RelativeCXXABIVTables) +// Type aware allocators +FEATURE(cxx_type_aware_allocators, LangOpts.TypeAwareAllocators) ojhunt wrote: R

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-29 Thread Oliver Hunt via cfe-commits
@@ -1110,9 +1138,10 @@ static bool findDeleteForPromise(Sema &S, SourceLocation Loc, QualType PromiseTy // The deallocation function's name is looked up by searching for it in the // scope of the promise type. If nothing is found, a search is performed in // the global s

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-29 Thread Oliver Hunt via cfe-commits
@@ -9784,10 +9850,16 @@ bool Sema::ShouldDeleteSpecialMember(CXXMethodDecl *MD, //results in an ambiguity or in a function that is deleted or inaccessible if (CSM == CXXSpecialMemberKind::Destructor && MD->isVirtual()) { FunctionDecl *OperatorDelete = nullptr; +

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-29 Thread Oliver Hunt via cfe-commits
@@ -16147,6 +16169,108 @@ bool Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor, return Invalid; } +bool Sema::isTypeAwareOperatorNewOrDelete(const NamedDecl *ND) const { + const FunctionDecl *FnDecl = nullptr; + if (auto *FTD = dyn_cast(ND)) +FnDecl = FT

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-29 Thread Oliver Hunt via cfe-commits
@@ -3134,6 +3134,31 @@ bool Type::isStdByteType() const { return false; } +bool Type::isDestroyingDeleteT() const { + auto *RD = getAsCXXRecordDecl(); + return RD && RD->isInStdNamespace() && RD->getIdentifier() && + RD->getIdentifier()->isStr("destroying_delete_t"

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-29 Thread Oliver Hunt via cfe-commits
@@ -2533,9 +2533,43 @@ bool CXXMethodDecl::isUsualDeallocationFunction( getOverloadedOperator() != OO_Array_Delete) ojhunt wrote: I've adopted them in a few places, and I'm renaming them to isAnyOperatorNew, isAnyOperatorDelete so it's less confusable wit

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-29 Thread Oliver Hunt via cfe-commits
@@ -16298,6 +16396,70 @@ bool Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor, return Invalid; } +bool Sema::isTypeAwareOperatorNewOrDelete(const NamedDecl *ND) const { + const FunctionDecl *FnDecl = nullptr; + if (auto *FTD = dyn_cast(ND)) +FnDecl = FTD

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-29 Thread Oliver Hunt via cfe-commits
@@ -1829,10 +1829,18 @@ class DeclContext { // refers to an enclosing template for hte purposes of [temp.friend]p9. LLVM_PREFERRED_TYPE(bool) uint64_t FriendConstraintRefersToEnclosingTemplate : 1; + +// Indicates this function is type aware operator new or dele

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-26 Thread via cfe-commits
@@ -1829,10 +1829,18 @@ class DeclContext { // refers to an enclosing template for hte purposes of [temp.friend]p9. LLVM_PREFERRED_TYPE(bool) uint64_t FriendConstraintRefersToEnclosingTemplate : 1; + +// Indicates this function is type aware operator new or dele

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-26 Thread via cfe-commits
@@ -1866,13 +1959,13 @@ static UsualDeallocFnInfo resolveDeallocationOverload( BestFns->push_back(Info); continue; } - -if (Best.isBetterThan(Info, WantSize, WantAlign)) +int ComparisonResult = Best.Compare(S, Info, IDP); +if (ComparisonResult > 0)

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread Oliver Hunt via cfe-commits
@@ -2533,9 +2533,43 @@ bool CXXMethodDecl::isUsualDeallocationFunction( getOverloadedOperator() != OO_Array_Delete) ojhunt wrote: *adding the new accessors and adopting them https://github.com/llvm/llvm-project/pull/113510

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread Oliver Hunt via cfe-commits
@@ -16298,6 +16396,70 @@ bool Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor, return Invalid; } +bool Sema::isTypeAwareOperatorNewOrDelete(const NamedDecl *ND) const { + const FunctionDecl *FnDecl = nullptr; + if (auto *FTD = dyn_cast(ND)) +FnDecl = FTD

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread via cfe-commits
https://github.com/cor3ntin edited 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

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread Oliver Hunt via cfe-commits
@@ -2520,6 +2520,18 @@ class FunctionDecl : public DeclaratorDecl, /// If this function is an allocation/deallocation function that takes /// the `std::nothrow_t` tag, return true through IsNothrow, bool isReplaceableGlobalAllocationFunction( + std::optional *Alignme

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread Oliver Hunt via cfe-commits
@@ -3503,9 +3518,23 @@ bool FunctionDecl::isDestroyingOperatorDelete() const { getNumParams() < 2) return false; - auto *RD = getParamDecl(1)->getType()->getAsCXXRecordDecl(); - return RD && RD->isInStdNamespace() && RD->getIdentifier() && - RD->getIdentifi

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread Oliver Hunt via cfe-commits
@@ -9817,27 +9817,54 @@ def err_operator_new_delete_invalid_result_type : Error< def err_operator_new_delete_dependent_result_type : Error< "%0 cannot have a dependent return type; use %1 instead">; def err_operator_new_delete_too_few_parameters : Error< - "%0 must have at l

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread Oliver Hunt via cfe-commits
@@ -2533,9 +2533,43 @@ bool CXXMethodDecl::isUsualDeallocationFunction( getOverloadedOperator() != OO_Array_Delete) ojhunt wrote: Shall I just do a global search/replace/update? Actually maybe I should just do that as a separate PR? https://github.com/ll

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread via cfe-commits
@@ -0,0 +1,145 @@ +// RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify %s -std=c++26 -fcoroutines -fexceptions -Wall -Wpedantic + + +#include "Inputs/std-coroutine.h" + +namespace std { + template struct type_identity { + typedef T type; + }; + typedef __

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread via cfe-commits
@@ -3134,6 +3134,31 @@ bool Type::isStdByteType() const { return false; } +bool Type::isDestroyingDeleteT() const { + auto *RD = getAsCXXRecordDecl(); + return RD && RD->isInStdNamespace() && RD->getIdentifier() && + RD->getIdentifier()->isStr("destroying_delete_t"

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread via cfe-commits
@@ -16298,6 +16396,70 @@ bool Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor, return Invalid; } +bool Sema::isTypeAwareOperatorNewOrDelete(const NamedDecl *ND) const { + const FunctionDecl *FnDecl = nullptr; + if (auto *FTD = dyn_cast(ND)) +FnDecl = FTD

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread via cfe-commits
@@ -16147,6 +16169,108 @@ bool Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor, return Invalid; } +bool Sema::isTypeAwareOperatorNewOrDelete(const NamedDecl *ND) const { + const FunctionDecl *FnDecl = nullptr; + if (auto *FTD = dyn_cast(ND)) +FnDecl = FT

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread via cfe-commits
@@ -2527,6 +2527,32 @@ class FunctionDecl : public DeclaratorDecl, /// If this function is an allocation/deallocation function that takes /// the `std::nothrow_t` tag, return true through IsNothrow, bool isReplaceableGlobalAllocationFunction( + std::optional *Alignme

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread via cfe-commits
@@ -3849,7 +4119,15 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, // delete. This is only necessary if we selected a destroying operator // delete that we are going to call (non-virtually); converting to void* // is trivial and left to AST consum

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread via cfe-commits
@@ -9817,27 +9817,54 @@ def err_operator_new_delete_invalid_result_type : Error< def err_operator_new_delete_dependent_result_type : Error< "%0 cannot have a dependent return type; use %1 instead">; def err_operator_new_delete_too_few_parameters : Error< - "%0 must have at l

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread via cfe-commits
@@ -9784,10 +9850,16 @@ bool Sema::ShouldDeleteSpecialMember(CXXMethodDecl *MD, //results in an ambiguity or in a function that is deleted or inaccessible if (CSM == CXXSpecialMemberKind::Destructor && MD->isVirtual()) { FunctionDecl *OperatorDelete = nullptr; +

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread via cfe-commits
@@ -2520,6 +2520,18 @@ class FunctionDecl : public DeclaratorDecl, /// If this function is an allocation/deallocation function that takes /// the `std::nothrow_t` tag, return true through IsNothrow, bool isReplaceableGlobalAllocationFunction( + std::optional *Alignme

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread via cfe-commits
@@ -2234,6 +2234,101 @@ enum class CXXNewInitializationStyle { Braces }; +enum class TypeAwareAllocationMode : unsigned { No, Yes }; +inline bool isTypeAwareAllocation(TypeAwareAllocationMode Mode) { + return Mode == TypeAwareAllocationMode::Yes; +} +inline TypeAwareAllocat

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread via cfe-commits
https://github.com/cor3ntin commented: I think I have found all your comments that needed a follow-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/li

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread via cfe-commits
@@ -16223,6 +16324,70 @@ bool Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor, return Invalid; } +bool Sema::isTypeAwareOperatorNewOrDelete(const NamedDecl *ND) const { + const FunctionDecl *FnDecl = nullptr; cor3ntin wrote: I don't think so

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread Oliver Hunt via cfe-commits
@@ -3503,9 +3518,23 @@ bool FunctionDecl::isDestroyingOperatorDelete() const { getNumParams() < 2) return false; - auto *RD = getParamDecl(1)->getType()->getAsCXXRecordDecl(); - return RD && RD->isInStdNamespace() && RD->getIdentifier() && - RD->getIdentifi

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread via cfe-commits
https://github.com/cor3ntin commented: > *[Reviewable](https://reviewable.io/reviews/llvm/llvm-project/113510)* > status: 0 of 54 files reviewed, 119 unresolved discussions (waiting on > @AaronBallman, @Bigcheese, @ChuanqiXu9, @efriedma-quic, @erichkeane, > @mizvekov, @ogiroux, @ojhunt, @Sir

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread via cfe-commits
@@ -4778,6 +4784,16 @@ class Sema final : public SemaBase { CXXRecordDecl *getStdBadAlloc() const; EnumDecl *getStdAlignValT() const; + const ClassTemplateDecl *getStdTypeIdentity() const; + ClassTemplateDecl *getStdTypeIdentity(); + std::optional instantiateSpecialized

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread via cfe-commits
@@ -2234,6 +2234,101 @@ enum class CXXNewInitializationStyle { Braces }; +enum class TypeAwareAllocationMode : unsigned { No, Yes }; +inline bool isTypeAwareAllocation(TypeAwareAllocationMode Mode) { + return Mode == TypeAwareAllocationMode::Yes; +} +inline TypeAwareAllocat

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-25 Thread via cfe-commits
@@ -3482,15 +3486,40 @@ bool FunctionDecl::isDestroyingOperatorDelete() const { // Within a class C, a single object deallocation function with signature // (T, std::destroying_delete_t, ) // is a destroying operator delete. - if (!isa(this) || getOverloadedOpera

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-24 Thread Oliver Hunt via cfe-commits
@@ -3134,6 +3134,31 @@ bool Type::isStdByteType() const { return false; } +bool Type::isDestroyingDeleteT() const { + auto *RD = getAsCXXRecordDecl(); + return RD && RD->isInStdNamespace() && RD->getIdentifier() && + RD->getIdentifier()->isStr("destroying_delete_t"

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-24 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt commented: > *[Reviewable](https://reviewable.io/reviews/llvm/llvm-project/113510)* > status: 0 of 54 files reviewed, 119 unresolved discussions (waiting on > @AaronBallman, @Bigcheese, @ChuanqiXu9, @cor3ntin, @efriedma-quic, > @erichkeane, @mizvekov, @ogiroux, @Sir

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-24 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt edited 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

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-24 Thread Oliver Hunt via cfe-commits
@@ -4749,6 +4753,15 @@ class Sema final : public SemaBase { CXXRecordDecl *getStdBadAlloc() const; EnumDecl *getStdAlignValT() const; + ClassTemplateDecl *getStdTypeIdentity() const; + std::optional InstantiateSpecializedTypeIdentity(QualType Subject); o

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-24 Thread via cfe-commits
@@ -477,6 +477,44 @@ class DeclarationName { return OO_None; } + bool isOperatorNew() const { +if (getNameKind() != DeclarationName::CXXOperatorName) + return false; +switch (getCXXOverloadedOperator()) { +case OO_New: +case OO_Array_New: + ret

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-24 Thread via cfe-commits
@@ -7256,6 +7257,71 @@ void Sema::CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record) { else if (Record->hasAttr()) checkCUDADeviceBuiltinTextureClassTemplate(*this, Record); } + + if (getLangOpts().TypeAwareAllocators) { +llvm::SmallVector TypeAwareNewDec

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-24 Thread via cfe-commits
@@ -3482,15 +3486,40 @@ bool FunctionDecl::isDestroyingOperatorDelete() const { // Within a class C, a single object deallocation function with signature // (T, std::destroying_delete_t, ) // is a destroying operator delete. - if (!isa(this) || getOverloadedOpera

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-24 Thread via cfe-commits
@@ -2533,9 +2533,43 @@ bool CXXMethodDecl::isUsualDeallocationFunction( getOverloadedOperator() != OO_Array_Delete) cor3ntin wrote: We have a function for that now! https://github.com/llvm/llvm-project/pull/113510 _

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-24 Thread via cfe-commits
@@ -307,6 +307,10 @@ EXTENSION(datasizeof, LangOpts.CPlusPlus) FEATURE(cxx_abi_relative_vtable, LangOpts.CPlusPlus && LangOpts.RelativeCXXABIVTables) +// Type aware allocators +FEATURE(cxx_type_aware_allocators, LangOpts.TypeAwareAllocators) cor3ntin wrote:

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-24 Thread via cfe-commits
@@ -3134,6 +3134,31 @@ bool Type::isStdByteType() const { return false; } +bool Type::isDestroyingDeleteT() const { + auto *RD = getAsCXXRecordDecl(); + return RD && RD->isInStdNamespace() && RD->getIdentifier() && + RD->getIdentifier()->isStr("destroying_delete_t"

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-03-24 Thread via cfe-commits
https://github.com/cor3ntin edited 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

  1   2   >