[libcxx-commits] [libcxx] 2b01e7c - [libc++] Remove _LIBCPP_HAS_SIZED_DEALLOCATION (#172285)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 6 08:16:09 PST 2026


Author: Nikolas Klauser
Date: 2026-01-06T17:16:04+01:00
New Revision: 2b01e7cf2b7053dc350b658c96e3db8404cc2594

URL: https://github.com/llvm/llvm-project/commit/2b01e7cf2b7053dc350b658c96e3db8404cc2594
DIFF: https://github.com/llvm/llvm-project/commit/2b01e7cf2b7053dc350b658c96e3db8404cc2594.diff

LOG: [libc++] Remove _LIBCPP_HAS_SIZED_DEALLOCATION (#172285)

This macro provides relatively little value. Using the standard FTM
directly removes one level of indicretion, making it easier to
understand what is actually happening.

Added: 
    

Modified: 
    libcxx/include/__new/allocate.h
    libcxx/include/__new/global_new_delete.h

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__new/allocate.h b/libcxx/include/__new/allocate.h
index 9bfe19aedb79f..b9bc2e1a50710 100644
--- a/libcxx/include/__new/allocate.h
+++ b/libcxx/include/__new/allocate.h
@@ -13,7 +13,6 @@
 #include <__cstddef/max_align_t.h>
 #include <__cstddef/size_t.h>
 #include <__new/align_val_t.h>
-#include <__new/global_new_delete.h> // for _LIBCPP_HAS_SIZED_DEALLOCATION
 #include <__type_traits/type_identity.h>
 #include <__utility/element_count.h>
 
@@ -43,7 +42,7 @@ __libcpp_allocate(__element_count __n, [[__maybe_unused__]] size_t __align = _LI
   return static_cast<_Tp*>(__builtin_operator_new(__size));
 }
 
-#if _LIBCPP_HAS_SIZED_DEALLOCATION
+#if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L
 #  define _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(...) __VA_ARGS__
 #else
 #  define _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(...) /* nothing */

diff  --git a/libcxx/include/__new/global_new_delete.h b/libcxx/include/__new/global_new_delete.h
index 96510ab56b00b..f31bac3730489 100644
--- a/libcxx/include/__new/global_new_delete.h
+++ b/libcxx/include/__new/global_new_delete.h
@@ -12,7 +12,6 @@
 #include <__config>
 #include <__cstddef/size_t.h>
 #include <__new/align_val_t.h>
-#include <__new/exceptions.h>
 #include <__new/nothrow_t.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -25,12 +24,6 @@
 #  define _THROW_BAD_ALLOC
 #endif
 
-#if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L
-#  define _LIBCPP_HAS_SIZED_DEALLOCATION 1
-#else
-#  define _LIBCPP_HAS_SIZED_DEALLOCATION 0
-#endif
-
 #if defined(_LIBCPP_ABI_VCRUNTIME)
 #  include <new.h>
 #else
@@ -39,7 +32,7 @@
     _LIBCPP_NOALIAS;
 _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT;
 _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT;
-#  if _LIBCPP_HAS_SIZED_DEALLOCATION
+#  if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L
 _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT;
 #  endif
 
@@ -48,7 +41,7 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _
     _LIBCPP_NOALIAS;
 _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT;
 _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;
-#  if _LIBCPP_HAS_SIZED_DEALLOCATION
+#  if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L
 _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz) _NOEXCEPT;
 #  endif
 
@@ -58,7 +51,7 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz)
 operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
 _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT;
 _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
-#    if _LIBCPP_HAS_SIZED_DEALLOCATION
+#    if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L
 _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
 #    endif
 
@@ -68,7 +61,7 @@ operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
 operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
 _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT;
 _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
-#    if _LIBCPP_HAS_SIZED_DEALLOCATION
+#    if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L
 _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
 #    endif
 #  endif


        


More information about the libcxx-commits mailing list