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

2025-03-08 Thread Oliver Hunt via cfe-commits
ojhunt wrote: I'm planning on removing the docs, but I've left them in for now just so that reviewers can read them if they want context to understand the PR. @cor3ntin @AaronBallman @erichkeane I'm ok removing the flag, I'll look into how to diagnose the "you're using an extension/future lang

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

2025-03-09 Thread Oliver Hunt via cfe-commits
ojhunt wrote: @cor3ntin @AaronBallman @erichkeane There is a bunch of super unpleasant nonsense in the new and delete codegen paths, it would simplify things a lot if we actually had the AST nodes actually be complete, e.g. the AST node would include expression nodes for the implicit parameter

[clang] [PAC] Add support for __ptrauth type qualifier (PR #100830)

2025-02-27 Thread Oliver Hunt via cfe-commits
@@ -2850,6 +2850,26 @@ void CXXNameMangler::mangleQualifiers(Qualifiers Quals, const DependentAddressSp if (Quals.hasUnaligned()) mangleVendorQualifier("__unaligned"); + // __ptrauth. Note that this is parameterized. + if (PointerAuthQualifier PtrAuth = Quals.getPoin

[clang] [PAC] Add support for __ptrauth type qualifier (PR #100830)

2025-03-11 Thread Oliver Hunt via cfe-commits
@@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -triple arm64-apple-ios -fsyntax-only -verify -fptrauth-intrinsics -std=c++11 %s +// RUN: %clang_cc1 -triple aarch64-linux-gnu -fsyntax-only -verify -fptrauth-intrinsics -std=c++11 %s + +template struct G { + T __ptrauth(0,0,1234) test; +

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

2025-02-21 Thread Oliver Hunt via cfe-commits
ojhunt wrote: These updates in principle bring the major semantics up to match P2719r4 Primary changes: * CV qualifiers are dropped * size and alignment parameters become mandatory, semantics for placement cleanup are updated to permit this, and to permit cleanup when the cleanup operator dele

[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
@@ -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-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-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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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-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-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] [clang] Fix crash on invalid `std::initializer_list` template-id (PR #132284)

2025-04-04 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt requested changes to this pull request. https://github.com/llvm/llvm-project/pull/132284 ___ 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-03-25 Thread Oliver Hunt via cfe-commits
@@ -10509,14 +10516,18 @@ static bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init, ED->getNumPositiveBits() == FieldWidth) { DiagID = diag::warn_signed_bitfield_enum_conversion; } - + unsigned PreferredTypeDiagIndex =

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

2025-03-25 Thread Oliver Hunt via cfe-commits
@@ -6418,6 +6418,12 @@ def warn_signed_bitfield_enum_conversion : Warning< InGroup, DefaultIgnore; def note_change_bitfield_sign : Note< "consider making the bitfield type %select{unsigned|signed}0">; +def warn_ms_bitfield_mismatched_storage_packing : Warning< + "bit-field

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

2025-03-25 Thread Oliver Hunt via cfe-commits
@@ -6418,6 +6418,12 @@ def warn_signed_bitfield_enum_conversion : Warning< InGroup, DefaultIgnore; def note_change_bitfield_sign : Note< "consider making the bitfield type %select{unsigned|signed}0">; +def warn_ms_bitfield_mismatched_storage_packing : Warning< + "bit-field

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

2025-03-25 Thread Oliver Hunt via cfe-commits
@@ -633,6 +633,50 @@ 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] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)

2025-03-25 Thread Oliver Hunt via cfe-commits
@@ -0,0 +1,113 @@ +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fsyntax-only -verify=expected,preferrednotes -std=c11 -Wno-unused-value -Wno-unused-but-set-variable +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fsyntax-only -verify=expected,bitfieldwarning,prefe

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

2025-03-25 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-03-25 Thread Oliver Hunt via cfe-commits
@@ -6418,6 +6418,12 @@ def warn_signed_bitfield_enum_conversion : Warning< InGroup, DefaultIgnore; def note_change_bitfield_sign : Note< "consider making the bitfield type %select{unsigned|signed}0">; +def warn_ms_bitfield_mismatched_storage_packing : Warning< + "bit-field

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

2025-03-25 Thread Oliver Hunt via cfe-commits
@@ -10488,7 +10488,14 @@ static bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init, // The RHS is not constant. If the RHS has an enum type, make sure the // bitfield is wide enough to hold all the values of the enum without // truncation. -

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

2025-03-25 Thread Oliver Hunt via cfe-commits
@@ -6408,20 +6408,24 @@ 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] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)

2025-03-25 Thread Oliver Hunt via cfe-commits
@@ -6408,20 +6408,24 @@ 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] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)

2025-03-25 Thread Oliver Hunt via cfe-commits
@@ -0,0 +1,113 @@ +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fsyntax-only -verify=expected,preferrednotes -std=c11 -Wno-unused-value -Wno-unused-but-set-variable +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fsyntax-only -verify=expected,bitfieldwarning,prefe

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

2025-03-25 Thread Oliver Hunt via cfe-commits
@@ -6408,20 +6408,24 @@ 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] Add an off-by-default warning to complain about MSVC bitfield padding (PR #117428)

2025-03-25 Thread Oliver Hunt via cfe-commits
@@ -19213,6 +19213,29 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, Decl *EnclosingDecl, if (Record && FD->getType().isVolatileQualified()) Record->setHasVolatileMember(true); +auto IsNonDependentBitField = [](const FieldDecl *FD) { + if (!FD->

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

2025-03-25 Thread Oliver Hunt via cfe-commits
@@ -6418,6 +6418,12 @@ def warn_signed_bitfield_enum_conversion : Warning< InGroup, DefaultIgnore; def note_change_bitfield_sign : Note< "consider making the bitfield type %select{unsigned|signed}0">; +def warn_ms_bitfield_mismatched_storage_packing : Warning< + "bit-field

[clang] [clang] Fix crash on invalid `std::initializer_list` template-id (PR #132284)

2025-03-25 Thread Oliver Hunt via cfe-commits
@@ -12182,10 +12182,14 @@ QualType Sema::BuildStdInitializerList(QualType Element, SourceLocation Loc) { Args.addArgument(TemplateArgumentLoc(TemplateArgument(Element), Context.getTrivialTypeSourceInfo(Element,

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

2025-04-04 Thread Oliver Hunt via cfe-commits
@@ -10601,19 +10608,28 @@ static bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init, // on Windows where unfixed enums always use an underlying type of 'int'. unsigned DiagID = 0; if (SignedEnum && !SignedBitfield) { -DiagID = dia

[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/136828 >From 8d42eca9da4afd53b9d51fda5a8d285ed2cdeb72 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Wed, 30 Apr 2025 22:26:59 -0700 Subject: [PATCH] [clang][PAC] add support for options parameter to __ptrauth This P

[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread Oliver Hunt via cfe-commits
@@ -65,6 +65,17 @@ enum class PointerAuthenticationMode : unsigned { SignAndAuth }; +static constexpr llvm::StringLiteral PointerAuthenticationOptionStrip = "strip"; ojhunt wrote: @cor3ntin @AaronBallman is there a better/more idiomatic way of doing these?

[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt ready_for_review https://github.com/llvm/llvm-project/pull/136828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread Oliver Hunt via cfe-commits
@@ -1735,8 +1735,8 @@ def warn_pragma_unroll_cuda_value_in_parens : Warning< "argument to '#pragma unroll' should not be in parentheses in CUDA C/C++">, InGroup; -def err_ptrauth_qualifier_bad_arg_count : Error< - "'__ptrauth' qualifier must take between 1 and 3 arguments

[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread Oliver Hunt via cfe-commits
@@ -8373,10 +8375,140 @@ static void HandlePtrAuthQualifier(ASTContext &Ctx, QualType &T, IsAddressDiscriminated); IsInvalid |= !S.checkPointerAuthDiscriminatorArg( ExtraDiscriminatorArg, PointerAuthDiscArgKind::Extra,

[clang] [clang] Add support for `__ptrauth` being applied to integer types (PR #137580)

2025-05-09 Thread Oliver Hunt via cfe-commits
@@ -1031,10 +1031,12 @@ def err_ptrauth_qualifier_invalid : Error< "%select{return type|parameter type|property}1 may not be qualified with '__ptrauth'; type is %0">; def err_ptrauth_qualifier_cast : Error< "cannot cast to '__ptrauth'-qualified type %0">; -def err_ptrauth_

[clang] [clang] Add support for `__ptrauth` being applied to integer types (PR #137580)

2025-05-09 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/137580 >From 07b6275740646c6ac0ffd95518e7e9fa8f1e8717 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Sun, 27 Apr 2025 22:33:44 -0700 Subject: [PATCH 1/2] [clang] Add support for __ptrauth being applied to integer typ

[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/136828 >From d53d1ad252ad5c4c9db61ad03e8a606e195156d9 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Wed, 30 Apr 2025 22:26:59 -0700 Subject: [PATCH] [clang][PAC] add support for options parameter to __ptrauth This P

[clang] [clang][PAC] add ptrauth intptr test (PR #139338)

2025-05-09 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/139338 Forgot to actually add the test as part of the `__ptrauth` on intptr PR >From db7075b4855eca0dbb5c0d6c7184c193a975f405 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Fri, 9 May 2025 16:36:51 -0700 Subject: [PA

[clang] [clang][PAC] add ptrauth intptr test (PR #139338)

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

[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/136828 >From 6f161d3699cac269f74376dc02697a7242b5 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Wed, 30 Apr 2025 22:26:59 -0700 Subject: [PATCH] [clang][PAC] add support for options parameter to __ptrauth This P

[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/136828 >From f19a0a6045c98211fcb354e6614aa6707dfccc59 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Wed, 30 Apr 2025 22:26:59 -0700 Subject: [PATCH] [clang][ptrauth] add support for options parameter to __ptrauth T

[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/136828 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-se

[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/136828 >From 8d42eca9da4afd53b9d51fda5a8d285ed2cdeb72 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Wed, 30 Apr 2025 22:26:59 -0700 Subject: [PATCH 1/2] [clang][PAC] add support for options parameter to __ptrauth T

[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-12 Thread Oliver Hunt via cfe-commits
@@ -65,6 +65,17 @@ enum class PointerAuthenticationMode : unsigned { SignAndAuth }; +static constexpr llvm::StringLiteral PointerAuthenticationOptionStrip = "strip"; ojhunt wrote: It's not stored as a string (or even an attribute), they're stored as flags

[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-12 Thread Oliver Hunt via cfe-commits
@@ -65,6 +65,17 @@ enum class PointerAuthenticationMode : unsigned { SignAndAuth }; +static constexpr llvm::StringLiteral PointerAuthenticationOptionStrip = "strip"; ojhunt wrote: I was meaning "is there a more idiomatic way to have these string constants

[clang] [clang][ptrauth] Add support for querying the ptrauth schema of a type (PR #138482)

2025-05-07 Thread Oliver Hunt via cfe-commits
@@ -1039,6 +1039,8 @@ def err_ptrauth_address_discrimination_invalid : Error< "invalid address discrimination flag '%0'; '__ptrauth' requires '0' or '1'">; def err_ptrauth_extra_discriminator_invalid : Error< "invalid extra discriminator flag '%0'; '__ptrauth' requires a va

[clang] [ItaniumMangle] Make sure class types are added to the dictionary of substitution candidates when compiling for older ABIs (PR #138947)

2025-05-07 Thread Oliver Hunt via cfe-commits
ojhunt wrote: Given that the original PR broke pointer auth discriminators for function pointers, can we verify that discriminators for vtable pointers and vtable pointer slots are still correct as well? I think what we might actually need is for mangling to be aware that it is being used for

[clang] [ItaniumMangle] Make sure class types are added to the dictionary of substitution candidates when compiling for older ABIs (PR #138947)

2025-05-07 Thread Oliver Hunt via cfe-commits
ojhunt wrote: I'd like to have @tcwzxx look at this as well https://github.com/llvm/llvm-project/pull/138947 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [ItaniumMangle] Make sure class types are added to the dictionary of substitution candidates when compiling for older ABIs (PR #138947)

2025-05-07 Thread Oliver Hunt via cfe-commits
ojhunt wrote: This change seems to impact the path add for #108015 which was explicitly related to vtable mangling, are we sure we're not regressing that bug? https://github.com/llvm/llvm-project/pull/138947 ___ cfe-commits mailing list cfe-commits@li

[clang] [ItaniumMangle] Make sure class types are added to the dictionary of substitution candidates when compiling for older ABIs (PR #138947)

2025-05-07 Thread Oliver Hunt via cfe-commits
ojhunt wrote: (sorry for the noise, I see the above references are PRs rather than the issue # so they're all the same thing :D) https://github.com/llvm/llvm-project/pull/138947 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llv

[clang] [clang][ptrauth] Add support for querying the ptrauth schema of a type (PR #138482)

2025-05-07 Thread Oliver Hunt via cfe-commits
@@ -9561,6 +9561,41 @@ class PointerExprEvaluator return true; } + bool VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *E) { +// This is the only UETT we evaluate here. +assert(E->getKind() == UETT_PtrAuthSchemaOptions && + "Unknown Unary

[clang] [clang][ptrauth] Add support for querying the ptrauth schema of a type (PR #138482)

2025-05-07 Thread Oliver Hunt via cfe-commits
@@ -9619,6 +9620,65 @@ ObjCInterfaceDecl *ASTContext::getObjCProtocolDecl() const { return ObjCProtocolClassDecl; } +std::optional +ASTContext::getExplicitOrImplicitPointerAuth(QualType T) { + auto ExplicitQualifier = T.getPointerAuth(); + if (ExplicitQualifier.isPresent(

[clang] [clang][ptrauth] Add support for querying the ptrauth schema of a type (PR #138482)

2025-05-07 Thread Oliver Hunt via cfe-commits
@@ -9619,6 +9620,65 @@ ObjCInterfaceDecl *ASTContext::getObjCProtocolDecl() const { return ObjCProtocolClassDecl; } +std::optional +ASTContext::getExplicitOrImplicitPointerAuth(QualType T) { + auto ExplicitQualifier = T.getPointerAuth(); + if (ExplicitQualifier.isPresent(

[clang] [clang][ptrauth] Add support for querying the ptrauth schema of a type (PR #138482)

2025-05-07 Thread Oliver Hunt via cfe-commits
@@ -9619,6 +9620,65 @@ ObjCInterfaceDecl *ASTContext::getObjCProtocolDecl() const { return ObjCProtocolClassDecl; } +std::optional +ASTContext::getExplicitOrImplicitPointerAuth(QualType T) { + auto ExplicitQualifier = T.getPointerAuth(); + if (ExplicitQualifier.isPresent(

[clang] [clang][ptrauth] Add support for querying the ptrauth schema of a type (PR #138482)

2025-05-07 Thread Oliver Hunt via cfe-commits
ojhunt wrote: > This should come with a release note so users know about the new builtins, > right? I'm wondering if we should actually just have the release notes say something like "Added support for ARMv{revision} pointer authentication, see the `pointer authentication` section for details

[clang] [ItaniumMangle] Make sure class types are added to the dictionary of substitution candidates when compiling for older ABIs (PR #138947)

2025-05-07 Thread Oliver Hunt via cfe-commits
ojhunt wrote: Ok, I went over this with Akira, and verified the discriminators for vtable pointers and vtable pointer slots have remained consistent. I think we should consider adding additional run commands to some of the existing pointer auth tests to explicitly run with abi-compatibility=4

[clang] [clang] Add support for `__ptrauth` being applied to integer types (PR #137580)

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

[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt edited https://github.com/llvm/llvm-project/pull/136828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt edited https://github.com/llvm/llvm-project/pull/136828 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread Oliver Hunt via cfe-commits
@@ -8350,14 +8350,16 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, /// Handle the __ptrauth qualifier. static void HandlePtrAuthQualifier(ASTContext &Ctx, QualType &T, const ParsedAttr &Attr, Sema &S) { -

[clang] [clang] Add support for `__ptrauth` being applied to integer types (PR #137580)

2025-05-08 Thread Oliver Hunt via cfe-commits
ojhunt wrote: > Would it make sense to add the feature macro to your downstream instead? > e.g., downstream supports `__has_feature(ptrauth_restricted_intptr)` and > upstream would return `false` for it. We have that, I just need to determine if there's any code that treats the lack of that q

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

2025-05-06 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/137580 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-se

[clang] [clang][ptrauth] Add support for querying the ptrauth schema of a type (PR #138482)

2025-05-06 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/138482 >From ecea44f2965cda3a4e6e1ccec096066830ddfa41 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Sun, 4 May 2025 21:07:33 -0700 Subject: [PATCH] [clang][ptrauth] Add support for querying the ptrauth schema of a t

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

2025-05-13 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt closed 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] [clang] Add builtin_get_vtable_pointer and virtual_member_address (PR #135469)

2025-05-13 Thread Oliver Hunt via cfe-commits
ojhunt wrote: Closing this, as I'm not sure the virtual_member_address builtin is actually needed, so for now we'll just do `builtin_get_vtable` which is used in other projects https://github.com/llvm/llvm-project/pull/135469 ___ cfe-commits mailing

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

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

[clang] [clang][PAC] Add __builtin_get_vtable_pointer (PR #139790)

2025-05-13 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt updated https://github.com/llvm/llvm-project/pull/139790 >From a933679801bde89b53584c4c65118658477db4da Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Tue, 13 May 2025 13:35:55 -0700 Subject: [PATCH] [clang][PAC] Add __builtin_get_vtable_pointer With pointer authent

[clang] [clang][PAC] Add __builtin_get_vtable_pointer (PR #139790)

2025-05-13 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/139790 With pointer authentication it becomes non-trivial to correctly load the vtable pointer of a polymorphic object. __builtin_get_vtable_pointer is a function that performs the load and performs the appropriate au

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

2025-05-13 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] [FixIt] Improve Source Ranges and Fix-It Hints for Unused Lambda Captures #106445 (PR #117953)

2025-05-13 Thread Oliver Hunt via cfe-commits
@@ -219,11 +222,10 @@ UnsignedOrNone clang::getStackIndexOfNearestEnclosingCaptureCapableLambda( // Check if the capture-ready lambda can truly capture 'this' by checking // whether all enclosing lambdas of the capture-ready lambda can capture // 'this'. -const

[clang] [FixIt] Improve Source Ranges and Fix-It Hints for Unused Lambda Captures #106445 (PR #117953)

2025-05-13 Thread Oliver Hunt via cfe-commits
@@ -238,7 +240,7 @@ getGenericLambdaTemplateParameterList(LambdaScopeInfo *LSI, Sema &SemaRef) { /*Template kw loc*/ SourceLocation(), /*L angle loc*/ LSI->ExplicitTemplateParamsRange.getBegin(), LSI->TemplateParams, -/*R angle loc*/LSI->Explici

[clang] [FixIt] Improve Source Ranges and Fix-It Hints for Unused Lambda Captures #106445 (PR #117953)

2025-05-13 Thread Oliver Hunt via cfe-commits
@@ -1247,12 +1311,12 @@ void Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro, if (C->Kind == LCK_ByRef && Intro.Default == LCD_ByRef) { Diag(C->Loc, diag::err_reference_capture_with_reference_default) << FixItHint::CreateRemoval( -

[clang] [FixIt] Improve Source Ranges and Fix-It Hints for Unused Lambda Captures #106445 (PR #117953)

2025-05-13 Thread Oliver Hunt via cfe-commits
@@ -1186,15 +1188,28 @@ void Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro, CheckCXXThisCapture(C->Loc, /*Explicit=*/true, /*BuildAndDiagnose*/ true, /*FunctionScopeIndexToStopAtPtr*/ nullptr, C->Ki

[clang] [FixIt] Improve Source Ranges and Fix-It Hints for Unused Lambda Captures #106445 (PR #117953)

2025-05-13 Thread Oliver Hunt via cfe-commits
@@ -1207,12 +1222,61 @@ void Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro, // for e.g., [n{0}] { }; <-- if no is included. // FIXME: we should create the init capture variable and mark it invalid // in this case. - if (C->InitCaptu

[clang] [FixIt] Improve Source Ranges and Fix-It Hints for Unused Lambda Captures #106445 (PR #117953)

2025-05-13 Thread Oliver Hunt via cfe-commits
@@ -597,8 +598,7 @@ static EnumDecl *findEnumForBlockReturn(Expr *E) { // - it is an enumerator whose enum type is T or if (DeclRefExpr *DRE = dyn_cast(E)) { -if (EnumConstantDecl *D - = dyn_cast(DRE->getDecl())) { +if (EnumConstantDecl *D = dyn_cast(DRE-

[clang] [FixIt] Improve Source Ranges and Fix-It Hints for Unused Lambda Captures #106445 (PR #117953)

2025-05-13 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt edited https://github.com/llvm/llvm-project/pull/117953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [FixIt] Improve Source Ranges and Fix-It Hints for Unused Lambda Captures #106445 (PR #117953)

2025-05-13 Thread Oliver Hunt via cfe-commits
@@ -662,12 +662,13 @@ static EnumDecl *findEnumForBlockReturn(ReturnStmt *ret) { /// Attempt to find a common type T for which all of the returned /// expressions in a block are enumerator-like expressions of that /// type. -static EnumDecl *findCommonEnumForBlockReturns(ArrayR

[clang] [FixIt] Improve Source Ranges and Fix-It Hints for Unused Lambda Captures #106445 (PR #117953)

2025-05-13 Thread Oliver Hunt via cfe-commits
@@ -575,8 +577,7 @@ void Sema::ActOnLambdaExplicitTemplateParameterList( assert(LSI->TemplateParams.empty() && "Explicit template parameters should come " "before invented (auto) ones"); - assert(!TParams.empty() && - "No template parameters to act

[clang] [FixIt] Improve Source Ranges and Fix-It Hints for Unused Lambda Captures #106445 (PR #117953)

2025-05-13 Thread Oliver Hunt via cfe-commits
@@ -676,17 +677,18 @@ static EnumDecl *findCommonEnumForBlockReturns(ArrayRef returns) { } // Never infer an anonymous enum type. - if (!ED->hasNameForLinkage()) return nullptr; + if (!ED->hasNameForLinkage()) ojhunt wrote: NFC formatting change https

[clang] [FixIt] Improve Source Ranges and Fix-It Hints for Unused Lambda Captures #106445 (PR #117953)

2025-05-13 Thread Oliver Hunt via cfe-commits
@@ -1207,12 +1222,61 @@ void Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro, // for e.g., [n{0}] { }; <-- if no is included. // FIXME: we should create the init capture variable and mark it invalid // in this case. - if (C->InitCaptu

[clang] [FixIt] Improve Source Ranges and Fix-It Hints for Unused Lambda Captures #106445 (PR #117953)

2025-05-13 Thread Oliver Hunt via cfe-commits
@@ -662,12 +662,13 @@ static EnumDecl *findEnumForBlockReturn(ReturnStmt *ret) { /// Attempt to find a common type T for which all of the returned /// expressions in a block are enumerator-like expressions of that /// type. -static EnumDecl *findCommonEnumForBlockReturns(ArrayR

[clang] [PAuth] Use different discriminators for __int128_t / __uint128_t / _BitInt(n) (PR #140276)

2025-05-16 Thread Oliver Hunt via cfe-commits
ojhunt wrote: This looks reasonable to me, but are we able to add a flag on it - we might need to be able to disable it on Darwin as it's technically an ABI change https://github.com/llvm/llvm-project/pull/140276 ___ cfe-commits mailing list cfe-commi

[clang] [clang][AArch64] Move initialization of ptrauth-* function attrs (PR #140277)

2025-05-16 Thread Oliver Hunt via cfe-commits
https://github.com/ojhunt approved this pull request. Looks good, I may start working on moving the preferences into the targetinfo unless you're working on that already https://github.com/llvm/llvm-project/pull/140277 ___ cfe-commits mailing list cfe

[clang] [PAuth] Use different discriminators for __int128_t / __uint128_t / _BitInt(n) (PR #140276)

2025-05-16 Thread Oliver Hunt via cfe-commits
ojhunt wrote: @ahatanak I've discussed this with @asl in discord, I think this is a sensible change my only real concern is the ABI, even though it would in principle require the effected types being used in an ABI exposed way to matter https://github.com/llvm/llvm-project/pull/140276

[clang] [PAuth] Use different discriminators for __int128_t / __uint128_t / _BitInt(n) (PR #140276)

2025-05-16 Thread Oliver Hunt via cfe-commits
@@ -3383,21 +3383,27 @@ static void encodeTypeForFunctionPointerAuth(const ASTContext &Ctx, // Don't bother discriminating based on these types. case Type::Pipe: - case Type::BitInt: case Type::ConstantMatrix: OS << "?"; return; + case Type::BitInt: { +

[clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)

2025-05-14 Thread Oliver Hunt via cfe-commits
@@ -2032,6 +2032,7 @@ class SourceManagerForFile { // as they are created in `createSourceManagerForFile` so that they can be // deleted in the reverse order as they are created. std::unique_ptr FileMgr; + std::unique_ptr DiagOpts; ojhunt wrote: I don't

[clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)

2025-05-14 Thread Oliver Hunt via cfe-commits
@@ -2032,6 +2032,7 @@ class SourceManagerForFile { // as they are created in `createSourceManagerForFile` so that they can be // deleted in the reverse order as they are created. std::unique_ptr FileMgr; + std::unique_ptr DiagOpts; ojhunt wrote: @jansvo

[clang] [clang] Constant-evaluate format strings as last resort (PR #135864)

2025-05-14 Thread Oliver Hunt via cfe-commits
ojhunt wrote: @apple-fcloutier I feel like this PR can be made easier to review by separating the improvements to string constant evaluation from the improvements to the format string checking, as the former introduces a number of new interfaces and the operations required to provide those API

[clang] [clang][PAC] Add __builtin_get_vtable_pointer (PR #139790)

2025-05-13 Thread Oliver Hunt via cfe-commits
@@ -1825,6 +1825,37 @@ static ExprResult PointerAuthStringDiscriminator(Sema &S, CallExpr *Call) { return Call; } +static ExprResult GetVTablePointer(Sema &S, CallExpr *Call) { + if (S.checkArgCount(Call, 1)) +return ExprError(); + ExprResult ThisArg = S.DefaultFuncti

[clang] [FixIt] Improve Source Ranges and Fix-It Hints for Unused Lambda Captures #106445 (PR #117953)

2025-05-19 Thread Oliver Hunt via cfe-commits
@@ -1633,8 +1633,8 @@ static void repeatForLambdaConversionFunctionCallingConvs( CC_C,CC_X86StdCall, CC_X86FastCall, CC_X86VectorCall, DefaultFree, DefaultMember, CallOpCC}; llvm::sort(Convs); -llvm::iterator_range Range( -std::begin(Conv

<    1   2   3   4   5   6   >