[clang] [RFC] Initial implementation of P2719 (PR #113510)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 7 00:20:43 PST 2025
================
@@ -2234,6 +2234,101 @@ enum class CXXNewInitializationStyle {
Braces
};
+enum class TypeAwareAllocationMode : unsigned { No, Yes };
+inline bool isTypeAwareAllocation(TypeAwareAllocationMode Mode) {
+ return Mode == TypeAwareAllocationMode::Yes;
+}
+inline TypeAwareAllocationMode
+typeAwareAllocationModeFromBool(bool IsTypeAwareAllocation) {
+ return IsTypeAwareAllocation ? TypeAwareAllocationMode::Yes
+ : TypeAwareAllocationMode::No;
+}
+
+enum class AlignedAllocationMode : unsigned { No, Yes };
+inline bool isAlignedAllocation(AlignedAllocationMode Mode) {
+ return Mode == AlignedAllocationMode::Yes;
+}
+inline AlignedAllocationMode alignedAllocationModeFromBool(bool IsAligned) {
+ return IsAligned ? AlignedAllocationMode::Yes : AlignedAllocationMode::No;
+}
+
+enum class SizedDeallocationMode : unsigned { No, Yes };
+inline bool isSizedDeallocation(SizedDeallocationMode Mode) {
+ return Mode == SizedDeallocationMode::Yes;
+}
+inline SizedDeallocationMode sizedDeallocationModeFromBool(bool IsSized) {
+ return IsSized ? SizedDeallocationMode::Yes : SizedDeallocationMode::No;
+}
+
+struct ImplicitAllocationParameters {
+ ImplicitAllocationParameters(QualType Type,
+ TypeAwareAllocationMode PassTypeIdentity,
+ AlignedAllocationMode PassAlignment)
+ : Type(Type.isNull() ? Type : Type.getUnqualifiedType()),
+ PassTypeIdentity(PassTypeIdentity), PassAlignment(PassAlignment) {
+ if (Type.isNull())
+ assert(!isTypeAwareAllocation(PassTypeIdentity));
+ assert(!Type.isNull());
+ }
+ explicit ImplicitAllocationParameters(AlignedAllocationMode PassAlignment)
+ : PassTypeIdentity(TypeAwareAllocationMode::No),
+ PassAlignment(PassAlignment) {}
+ QualType Type;
+ TypeAwareAllocationMode PassTypeIdentity;
+ AlignedAllocationMode PassAlignment;
+ unsigned getNumImplicitArgs() const {
+ unsigned Count = 1; // Size
+ if (isTypeAwareAllocation(PassTypeIdentity))
+ ++Count;
+ if (isAlignedAllocation(PassAlignment))
+ ++Count;
+ return Count;
+ }
+ bool isValid() const {
+ if (!isTypeAwareAllocation(PassTypeIdentity))
+ return true;
+ return !Type.isNull();
+ }
+};
+
+struct ImplicitDeallocationParameters {
----------------
cor3ntin wrote:
@ojhunt ping
https://github.com/llvm/llvm-project/pull/113510
More information about the cfe-commits
mailing list