[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-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
@@ -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 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 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
@@ -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] Add an off-by-default warning to complain about MSVC bitfield padding (PR #117428)

2025-04-05 Thread Oliver Hunt via cfe-commits
@@ -19001,9 +19001,9 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, Decl *EnclosingDecl, // Verify that all the fields are okay. SmallVector RecFields; - + std::optional PreviousField; ojhunt wrote: @rnk this is sufficiently constrained/non-

[clang] Add an off-by-default warning to complain about MSVC bitfield padding (PR #117428)

2025-04-05 Thread Oliver Hunt via cfe-commits
@@ -631,6 +631,9 @@ Improvements to Clang's diagnostics - Clang now diagnoses dangling references for C++20's parenthesized aggregate initialization (#101957). +- A new off-by-default warning ``-Wms-bitfield-compatibility`` has been added to alert to cases where bit-field -

[clang] Add an off-by-default warning to complain about MSVC bitfield padding (PR #117428)

2025-04-05 Thread Oliver Hunt via cfe-commits
@@ -631,6 +631,7 @@ def Packed : DiagGroup<"packed", [PackedNonPod]>; def PaddedBitField : DiagGroup<"padded-bitfield">; def Padded : DiagGroup<"padded", [PaddedBitField]>; def UnalignedAccess : DiagGroup<"unaligned-access">; +def MSBitfieldCompatibility : DiagGroup<"ms-bitfiel

[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
@@ -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] Add an off-by-default warning to complain about MSVC bitfield padding (PR #117428)

2025-03-25 Thread Oliver Hunt via cfe-commits
ojhunt wrote: No one commented on this test case, but for the record: * It runs in both ms_bitfields and sane (:D) mode * The static assertions are used to force struct layout * We assert the structs are the same size or different sizes depending on layout mod

[clang] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)

2025-03-25 Thread Oliver Hunt via cfe-commits
@@ -6404,20 +6404,23 @@ def warn_bitfield_width_exceeds_type_width: Warning< def err_bitfield_too_wide : Error< "%select{bit-field %1|anonymous bit-field}0 is too wide (%2 bits)">; def warn_bitfield_too_small_for_enum : Warning< - "bit-field %0 is not wide enough to store al

[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
@@ -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
@@ -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
@@ -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
@@ -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 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] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)

2025-03-26 Thread Oliver Hunt via cfe-commits
@@ -6517,8 +6517,22 @@ def warn_signed_bitfield_enum_conversion : Warning< "signed bit-field %0 needs an extra bit to represent the largest positive " "enumerators of %1">, InGroup, DefaultIgnore; +def warn_preferred_type_bitfield_too_small_for_enum : Warning< + "bit-fie

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

2025-04-07 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-08 Thread Oliver Hunt via cfe-commits
@@ -2627,16 +2731,21 @@ static bool resolveAllocationOverload( // FIXME: Find out how this interacts with the std::align_val_t fallback // once MSVC implements it. if (R.getLookupName().getCXXOverloadedOperator() == OO_Array_New && -S.Context.getLangOpts().M

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

2025-04-08 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-04-08 Thread Oliver Hunt 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-04-08 Thread Oliver Hunt 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-08 Thread Oliver Hunt via cfe-commits
@@ -16335,22 +16550,27 @@ CheckOperatorNewDeclaration(Sema &SemaRef, const FunctionDecl *FnDecl) { CanQualType SizeTy = SemaRef.Context.getCanonicalType(SemaRef.Context.getSizeType()); + unsigned MinimumNonDefaultArgs = 0; // C++ [basic.stc.dynamic.allocation]p1:

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

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

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

2025-04-08 Thread Oliver Hunt via cfe-commits
@@ -2709,14 +2831,63 @@ static bool resolveAllocationOverload( llvm_unreachable("Unreachable, bad result from BestViableFunction"); } -bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, - AllocationFunctionScope N

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

2025-04-08 Thread Oliver Hunt 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-08 Thread Oliver Hunt 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-08 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
@@ -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
@@ -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-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-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-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-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
@@ -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-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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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-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
@@ -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
@@ -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
@@ -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
@@ -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-08 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-04-08 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] Add an off-by-default warning to complain about MSVC bitfield padding (PR #117428)

2025-04-11 Thread Oliver Hunt via cfe-commits
@@ -0,0 +1,180 @@ + +// RUN: %clang_cc1 -fsyntax-only -Wms-bitfield-compatibility -verify -triple armv8 -std=c++23 %s +// RUN: %clang_cc1 -fsyntax-only -DMS_BITFIELDS -mms-bitfields -verify=msbitfields -triple armv8-apple-macos10.15 -std=c++23 %s + +// msbitfields-no-diagnostics

[clang] Add an off-by-default warning to complain about MSVC bitfield padding (PR #117428)

2025-04-11 Thread Oliver Hunt via cfe-commits
ojhunt wrote: (Finally getting back to this one) https://github.com/llvm/llvm-project/pull/117428 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Add an off-by-default warning to complain about MSVC bitfield padding (PR #117428)

2025-04-11 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/117428 >From 3e25d7ef2e223942298078dace8979905956d05c Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Fri, 22 Nov 2024 17:53:24 +0100 Subject: [PATCH 01/10] Add an off-by-default warning to complain about MSVC bitfiel

[clang] Add an off-by-default warning to complain about MSVC bitfield padding (PR #117428)

2025-04-11 Thread Oliver Hunt via cfe-commits
@@ -633,6 +633,52 @@ def Packed : DiagGroup<"packed", [PackedNonPod]>; def PaddedBitField : DiagGroup<"padded-bitfield">; def Padded : DiagGroup<"padded", [PaddedBitField]>; def UnalignedAccess : DiagGroup<"unaligned-access">; +def MSBitfieldCompatibility : DiagGroup<"ms-bitfie

[clang] Add an off-by-default warning to complain about MSVC bitfield padding (PR #117428)

2025-04-11 Thread Oliver Hunt via cfe-commits
@@ -6519,6 +6519,13 @@ def warn_signed_bitfield_enum_conversion : Warning< InGroup, DefaultIgnore; def note_change_bitfield_sign : Note< "consider making the bit-field type %select{unsigned|signed}0">; +def warn_ms_bitfield_mismatched_storage_packing : Warning< + "bit-fiel

[clang] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)

2025-04-11 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/116785 >From 5f260726253e78a00d2dff02c22837ce02b49075 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Tue, 19 Nov 2024 11:55:11 +0100 Subject: [PATCH 1/6] [Clang] Consider preferred_type in bitfield warnings (#116760)

[clang] [clang] Add builtin_get_vtable_pointer and virtual_member_address (PR #135469)

2025-04-13 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/135469 >From 1607a76c4fd2bd7f0c4e834d2935668d51daf55f Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Sun, 13 Apr 2025 00:47:18 -0700 Subject: [PATCH] [clang] Add builtin_get_vtable_pointer and virtual_member_address

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

2025-04-14 Thread Oliver Hunt via cfe-commits
ojhunt wrote: @Sterling-Augustine thank you! 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] [Clang]Ensure correct handling of cleanup access control (#135668) (PR #135686)

2025-04-14 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/135686 >From 62be33b3aa475a33d1c11679ed069eb2af981754 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Mon, 14 Apr 2025 15:02:46 -0700 Subject: [PATCH] [Clang]Ensure correct handling of access control in P2719 diagnost

[clang] [Clang]Ensure correct handling of cleanup access control (#135668) (PR #135686)

2025-04-14 Thread Oliver Hunt via cfe-commits
ojhunt wrote: > Thanks for the quick fix it's so very very stupid :O https://github.com/llvm/llvm-project/pull/135686 ___ 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-14 Thread Oliver Hunt via cfe-commits
ojhunt wrote: I have a very immediate fix, but I'd rather a slightly nicer one - at some point refactoring exposed a problem in access control diagnostics, in a way that is very very weird and implies something else broken in the existing tree as well. If I can't work out the correct systemic

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

2025-04-14 Thread Oliver Hunt via cfe-commits
ojhunt wrote: https://github.com/llvm/llvm-project/pull/135686 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] [Clang]Ensure correct handling of cleanup access control (#135668) (PR #135686)

2025-04-14 Thread Oliver Hunt via cfe-commits
ojhunt wrote: @Sterling-Augustine sorry I was waiting for all the bots to pass https://github.com/llvm/llvm-project/pull/135686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang]Ensure correct handling of cleanup access control (#135668) (PR #135686)

2025-04-14 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/135686 >From 62be33b3aa475a33d1c11679ed069eb2af981754 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Mon, 14 Apr 2025 15:02:46 -0700 Subject: [PATCH] [Clang]Ensure correct handling of access control in P2719 diagnost

[clang] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)

2025-04-20 Thread Oliver Hunt via cfe-commits
ojhunt wrote: Waiting on review for https://github.com/llvm/llvm-project/pull/136515 https://github.com/llvm/llvm-project/pull/116785 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Ensure bit-fields storing FPEvalMethodKind are wide enough to do so (PR #136515)

2025-04-20 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/136515 After landing #116760 we hit build failures due to existing fields storing FPEvalMethodKind not being wide enough. >From 535e11400ea11461fa8e0cc98f9b481b045805c4 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date:

[clang] Ensure bit-fields storing FPEvalMethodKind are wide enough to do so (PR #136515)

2025-04-20 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt closed https://github.com/llvm/llvm-project/pull/136515 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Ensure bit-fields storing FPEvalMethodKind are wide enough to do so (PR #136515)

2025-04-20 Thread Oliver Hunt via cfe-commits
ojhunt wrote: This is a blind build fix, so I'll merge https://github.com/llvm/llvm-project/pull/136515 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)

2025-04-20 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt closed https://github.com/llvm/llvm-project/pull/116785 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][ptrauth] Make ptrauth feature detection tests more robust (PR #136204)

2025-04-17 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt closed https://github.com/llvm/llvm-project/pull/136204 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Add builtin_get_vtable_pointer and virtual_member_address (PR #135469)

2025-04-17 Thread Oliver Hunt via cfe-commits
@@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -triple arm64e-apple-ios -fptrauth-calls -emit-llvm -no-enable-noundef-analysis -o - %s | FileCheck %s --check-prefixes CHECK,CHECK-AUTH +// RUN: %clang_cc1 -triple arm64-apple-ios -emit-llvm -no-enable-noundef-analysis -o - %s | FileCheck %

[clang] [clang][ptrauth] Make ptrauth feature detection tests more robust (PR #136204)

2025-04-17 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/136204 The existing test behavior checked for a warning being emitted under an #if, but if the feature detection fails the #if fails and the warning is not expected in the output. I've made the test more explicit, and

[clang] [lldb] [clang] Add `__ptrauth_restricted_intptr` qualifier (PR #137580)

2025-04-27 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/137580 >From 0129e28643f667febb23dba1521134a6151c2f7d Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Sun, 27 Apr 2025 22:33:44 -0700 Subject: [PATCH] [clang] Add `__ptrauth_restricted_intptr` qualifier __ptrauth_rest

[clang] [clang] Fix and test triviality of __ptrauth types (PR #137474)

2025-04-27 Thread Oliver Hunt via cfe-commits
ojhunt wrote: Thanks! https://github.com/llvm/llvm-project/pull/137474 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix and test triviality of __ptrauth types (PR #137474)

2025-04-27 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt closed https://github.com/llvm/llvm-project/pull/137474 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Remove FEM_Indeterminable (PR #137247)

2025-04-28 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt closed https://github.com/llvm/llvm-project/pull/137247 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Remove FEM_Indeterminable (PR #137247)

2025-04-28 Thread Oliver Hunt via cfe-commits
ojhunt wrote: @zahiraam it's currently causing a warning (@Endilll asking for an update is why I ended up looking at this on my phone) https://github.com/llvm/llvm-project/pull/137247 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lis

[clang] [clang] Remove FEM_Indeterminable (PR #137661)

2025-04-28 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/137661 Remove FEM_Indeterminable as it is unused and cannot be stored safely in an unsigned bitfield >From a33b76cb769b8669922101c9cb7b9fbb28cbb1fe Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Thu, 24 Apr 2025 13:

[clang] [clang] Remove FEM_Indeterminable (PR #137661)

2025-04-28 Thread Oliver Hunt via cfe-commits
ojhunt wrote: @Endilll this is the fix for the warning you're seeing https://github.com/llvm/llvm-project/pull/137661 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Remove FEM_Indeterminable (PR #137661)

2025-04-28 Thread Oliver Hunt via cfe-commits
ojhunt wrote: (Recreating after mismerge) https://github.com/llvm/llvm-project/pull/137661 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Remove FEM_Indeterminable (PR #137247)

2025-04-28 Thread Oliver Hunt via cfe-commits
ojhunt wrote: Hmmm, I thought it had been? https://github.com/llvm/llvm-project/pull/137247 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Remove FEM_Indeterminable (PR #137247)

2025-04-28 Thread Oliver Hunt via cfe-commits
ojhunt wrote: I've reverted, not sure why I thought it had been reviewed? https://github.com/llvm/llvm-project/pull/137247 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Revert "[clang] Remove FEM_Indeterminable" (PR #137654)

2025-04-28 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/137654 Reverts llvm/llvm-project#137247 >From 8da1b21e8c45980741fc6f5d8f290ac9ac80d878 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Mon, 28 Apr 2025 08:50:35 -0700 Subject: [PATCH] Revert "[clang] Remove FEM_Indete

[clang] Revert "[clang] Remove FEM_Indeterminable" (PR #137654)

2025-04-28 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt closed https://github.com/llvm/llvm-project/pull/137654 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Remove FEM_Indeterminable (PR #137661)

2025-04-28 Thread Oliver Hunt via cfe-commits
ojhunt wrote: @zahiraam we started diagnosing size/type mismatch of bitfields vs preferred_type in, which exposed that FPEvalMethodKind based options can't store FEM_Indeterminable https://github.com/llvm/llvm-project/pull/116785 https://github.com/llvm/llvm-project/pull/137661 ___

[clang] [clang] Remove FEM_Indeterminable (PR #137661)

2025-04-28 Thread Oliver Hunt via cfe-commits
ojhunt wrote: @zahiraam @AaronBallman a different option would be to add a signed vs unsigned storage option to the `OPTION` and `BENIGN_ENUM_LANGOPT` macros so we can store negative enumerations safely https://github.com/llvm/llvm-project/pull/137661 __

[clang] [clang] Fix and test triviality of __ptrauth types (PR #137474)

2025-04-27 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt approved this pull request. Good catch, we'll need to add cases to the test when pushing __ptrauth_restricted_intptr https://github.com/llvm/llvm-project/pull/137474 ___ cfe-commits mailing list cfe-commits@lists.llvm.org ht

[clang] [clang] Ensure correct copying of records with authenticated fields (PR #136783)

2025-04-22 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/136783 When records contain fields with pointer authentication, even simple copies can require additional work be performed. This patch contains the core functionality required to handle user defined structs, as well a

[clang] [clang] Ensure correct copying of records with authenticated fields (PR #136783)

2025-04-23 Thread Oliver Hunt via cfe-commits
@@ -2801,6 +2801,10 @@ static bool isTriviallyCopyableTypeImpl(const QualType &type, if (type.hasNonTrivialObjCLifetime()) return false; + QualType::PrimitiveCopyKind PCK = type.isNonTrivialToPrimitiveCopy(); + if (PCK != QualType::PCK_Trivial && PCK != QualType::PCK_

[clang] [clang] Ensure correct copying of records with authenticated fields (PR #136783)

2025-04-24 Thread Oliver Hunt via cfe-commits
@@ -103,3 +103,46 @@ static_assert(_Generic(typeof(overload_func(&ptr0)), int : 1, default : 0)); static_assert(_Generic(typeof(overload_func(&valid0)), float : 1, default : 0)); void func(int array[__ptrauth(VALID_DATA_KEY) 10]); // expected-error {{'__ptrauth' qualifier o

[clang] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)

2025-04-24 Thread Oliver Hunt via cfe-commits
ojhunt wrote: > This change makes Clang produce warnings when building Clang itself; warnings > looking like this: > That was the entire point of this warning. As far as I know clang+llvm is the only project to use preferred_type (instead of just using enum typed bitfields), but as a result

[clang] [clang] Ensure correct copying of records with authenticated fields (PR #136783)

2025-04-24 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt closed https://github.com/llvm/llvm-project/pull/136783 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

<    1   2   3   4   5   >