[libcxx-commits] [libcxx] [libc++] Remove __libcpp_allocate (PR #220981)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed Sep 9 04:01:40 PDT 2026


https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/220981

>From 2847acd03d5350bc40bc064e4754259acb7310c7 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Thu, 3 Sep 2026 17:53:02 +0200
Subject: [PATCH] [libc++] Remove __libcpp_allocate

---
 libcxx/include/CMakeLists.txt                 |   1 -
 libcxx/include/__memory/allocator.h           |  32 ++-
 libcxx/include/__memory/shared_ptr.h          |   1 +
 .../__memory/unique_temporary_buffer.h        |  19 +-
 libcxx/include/__new/allocate.h               |  78 ------
 libcxx/include/__utility/small_buffer.h       |   6 +-
 libcxx/include/module.modulemap.in            |   5 -
 libcxx/include/new                            |   1 -
 libcxx/src/include/aligned_alloc.h            |   2 +-
 .../support.dynamic/libcpp_deallocate.sh.cpp  | 252 ------------------
 .../valarray.cons/size.pass.cpp               |   5 +-
 11 files changed, 44 insertions(+), 358 deletions(-)
 delete mode 100644 libcxx/include/__new/allocate.h
 delete mode 100644 libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index b559309929a67..43d48e74a2546 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -650,7 +650,6 @@ set(files
   __mutex/tag_types.h
   __mutex/unique_lock.h
   __new/align_val_t.h
-  __new/allocate.h
   __new/destroying_delete_t.h
   __new/exceptions.h
   __new/global_new_delete.h
diff --git a/libcxx/include/__memory/allocator.h b/libcxx/include/__memory/allocator.h
index dd8c8647c178a..1c6e632f8d356 100644
--- a/libcxx/include/__memory/allocator.h
+++ b/libcxx/include/__memory/allocator.h
@@ -15,7 +15,7 @@
 #include <__cstddef/size_t.h>
 #include <__memory/addressof.h>
 #include <__memory/allocator_traits.h>
-#include <__new/allocate.h>
+#include <__new/align_val_t.h>
 #include <__new/exceptions.h>
 #include <__type_traits/is_const.h>
 #include <__type_traits/is_constant_evaluated.h>
@@ -86,11 +86,12 @@ class allocator
     static_assert(sizeof(_Tp) >= 0, "cannot allocate memory for an incomplete type");
     if (__n > allocator_traits<allocator>::max_size(*this))
       std::__throw_bad_array_new_length();
-    if (__libcpp_is_constant_evaluated()) {
-      return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
-    } else {
-      return std::__libcpp_allocate<_Tp>(__element_count(__n));
-    }
+#if _LIBCPP_HAS_ALIGNED_ALLOCATION
+    if _LIBCPP_CONSTEXPR (_LIBCPP_ALIGNOF(value_type) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
+      return static_cast<_Tp*>(
+          __builtin_operator_new(__n * sizeof(value_type), static_cast<align_val_t>(_LIBCPP_ALIGNOF(value_type))));
+#endif
+    return static_cast<_Tp*>(__builtin_operator_new(__n * sizeof(value_type)));
   }
 
 #if _LIBCPP_STD_VER >= 23
@@ -100,14 +101,23 @@ class allocator
   }
 #endif
 
+#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 */
+#endif
+
   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void deallocate(_Tp* __p, size_t __n) _NOEXCEPT {
-    if (__libcpp_is_constant_evaluated()) {
-      ::operator delete(__p);
-    } else {
-      std::__libcpp_deallocate<_Tp>(__p, __element_count(__n));
-    }
+#if _LIBCPP_HAS_ALIGNED_ALLOCATION
+    if (_LIBCPP_ALIGNOF(value_type) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
+      return __builtin_operator_delete(__p _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __n * sizeof(value_type)),
+                                       static_cast<align_val_t>(_LIBCPP_ALIGNOF(value_type)));
+#endif
+    return __builtin_operator_delete(__p _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __n * sizeof(value_type)));
   }
 
+#undef _LIBCPP_ONLY_IF_SIZED_DEALLOCATION
+
   // C++20 Removed members
 #if _LIBCPP_STD_VER <= 17
   _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* pointer;
diff --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h
index 5386eb29e58a2..692b7504b22d7 100644
--- a/libcxx/include/__memory/shared_ptr.h
+++ b/libcxx/include/__memory/shared_ptr.h
@@ -51,6 +51,7 @@
 #include <__type_traits/remove_extent.h>
 #include <__type_traits/remove_pointer.h>
 #include <__type_traits/remove_reference.h>
+#include <__type_traits/type_identity.h>
 #include <__type_traits/void_t.h>
 #include <__utility/declval.h>
 #include <__utility/exception_guard.h>
diff --git a/libcxx/include/__memory/unique_temporary_buffer.h b/libcxx/include/__memory/unique_temporary_buffer.h
index 32a3f0f081c00..9af94433407eb 100644
--- a/libcxx/include/__memory/unique_temporary_buffer.h
+++ b/libcxx/include/__memory/unique_temporary_buffer.h
@@ -16,7 +16,6 @@
 #include <__cstddef/ptrdiff_t.h>
 #include <__memory/allocator.h>
 #include <__memory/unique_ptr.h>
-#include <__new/allocate.h>
 #include <__new/global_new_delete.h>
 #include <__type_traits/is_constant_evaluated.h>
 
@@ -26,6 +25,14 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
+template <class _Tp>
+inline const bool __is_overaligned_for_new = _LIBCPP_ALIGNOF(_Tp) > __STDCPP_DEFAULT_NEW_ALIGNMENT__;
+#else
+template <class _Tp>
+inline const bool __is_overaligned_for_new = _LIBCPP_ALIGNOF(_Tp) > _LIBCPP_ALIGNOF(max_align_t);
+#endif
+
 template <class _Tp>
 struct __temporary_buffer_deleter {
   ptrdiff_t __count_; // ignored in non-constant evaluation
@@ -40,7 +47,11 @@ struct __temporary_buffer_deleter {
       return;
     }
 
-    std::__libcpp_deallocate_unsized<_Tp>(__ptr);
+#if _LIBCPP_HAS_ALIGNED_ALLOCATION
+    if _LIBCPP_CONSTEXPR (__is_overaligned_for_new<_Tp>)
+      return __builtin_operator_delete(__ptr, static_cast<align_val_t>(_LIBCPP_ALIGNOF(_Tp)));
+#endif
+    return __builtin_operator_delete(__ptr);
   }
 };
 
@@ -64,14 +75,14 @@ __allocate_unique_temporary_buffer(ptrdiff_t __count) {
     __count = __max_count;
   while (__count > 0) {
 #if _LIBCPP_HAS_ALIGNED_ALLOCATION
-    if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp))) {
+    if _LIBCPP_CONSTEXPR (__is_overaligned_for_new<_Tp>) {
       align_val_t __al = align_val_t(_LIBCPP_ALIGNOF(_Tp));
       __ptr            = static_cast<_Tp*>(::operator new(__count * sizeof(_Tp), __al, nothrow));
     } else {
       __ptr = static_cast<_Tp*>(::operator new(__count * sizeof(_Tp), nothrow));
     }
 #else
-    if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp))) {
+    if _LIBCPP_CONSTEXPR (__is_overaligned_for_new<_Tp>) {
       // Since aligned operator new is unavailable, constructs an empty buffer rather than one with invalid alignment.
       return __unique_buffer_type();
     }
diff --git a/libcxx/include/__new/allocate.h b/libcxx/include/__new/allocate.h
deleted file mode 100644
index b9bc2e1a50710..0000000000000
--- a/libcxx/include/__new/allocate.h
+++ /dev/null
@@ -1,78 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP___NEW_ALLOCATE_H
-#define _LIBCPP___NEW_ALLOCATE_H
-
-#include <__config>
-#include <__cstddef/max_align_t.h>
-#include <__cstddef/size_t.h>
-#include <__new/align_val_t.h>
-#include <__type_traits/type_identity.h>
-#include <__utility/element_count.h>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#  pragma GCC system_header
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI bool __is_overaligned_for_new(size_t __align) _NOEXCEPT {
-#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
-  return __align > __STDCPP_DEFAULT_NEW_ALIGNMENT__;
-#else
-  return __align > _LIBCPP_ALIGNOF(max_align_t);
-#endif
-}
-
-template <class _Tp>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _Tp*
-__libcpp_allocate(__element_count __n, [[__maybe_unused__]] size_t __align = _LIBCPP_ALIGNOF(_Tp)) {
-  size_t __size = static_cast<size_t>(__n) * sizeof(_Tp);
-#if _LIBCPP_HAS_ALIGNED_ALLOCATION
-  if (__is_overaligned_for_new(__align))
-    return static_cast<_Tp*>(__builtin_operator_new(__size, static_cast<align_val_t>(__align)));
-#endif
-
-  return static_cast<_Tp*>(__builtin_operator_new(__size));
-}
-
-#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 */
-#endif
-
-template <class _Tp>
-inline _LIBCPP_HIDE_FROM_ABI void
-__libcpp_deallocate(__type_identity_t<_Tp>* __ptr,
-                    __element_count __n,
-                    [[__maybe_unused__]] size_t __align = _LIBCPP_ALIGNOF(_Tp)) _NOEXCEPT {
-  [[__maybe_unused__]] size_t __size = static_cast<size_t>(__n) * sizeof(_Tp);
-#if _LIBCPP_HAS_ALIGNED_ALLOCATION
-  if (__is_overaligned_for_new(__align))
-    return __builtin_operator_delete(
-        __ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size), static_cast<align_val_t>(__align));
-#endif
-  return __builtin_operator_delete(__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size));
-}
-
-#undef _LIBCPP_ONLY_IF_SIZED_DEALLOCATION
-
-template <class _Tp>
-inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate_unsized(
-    __type_identity_t<_Tp>* __ptr, [[__maybe_unused__]] size_t __align = _LIBCPP_ALIGNOF(_Tp)) _NOEXCEPT {
-#if _LIBCPP_HAS_ALIGNED_ALLOCATION
-  if (__is_overaligned_for_new(__align))
-    return __builtin_operator_delete(__ptr, static_cast<align_val_t>(__align));
-#endif
-  return __builtin_operator_delete(__ptr);
-}
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // _LIBCPP___NEW_ALLOCATE_H
diff --git a/libcxx/include/__utility/small_buffer.h b/libcxx/include/__utility/small_buffer.h
index 132a57f0fefab..98577bbc0564c 100644
--- a/libcxx/include/__utility/small_buffer.h
+++ b/libcxx/include/__utility/small_buffer.h
@@ -12,8 +12,8 @@
 #include <__config>
 #include <__cstddef/byte.h>
 #include <__cstddef/size_t.h>
+#include <__memory/allocator.h>
 #include <__memory/construct_at.h>
-#include <__new/allocate.h>
 #include <__new/launder.h>
 #include <__type_traits/decay.h>
 #include <__type_traits/is_trivially_constructible.h>
@@ -68,7 +68,7 @@ class __small_buffer {
     if constexpr (__fits_in_buffer<_Stored>) {
       return std::launder(reinterpret_cast<_Stored*>(__buffer_));
     } else {
-      byte* __allocation = reinterpret_cast<byte*>(std::__libcpp_allocate<_Stored>(__element_count(1)));
+      byte* __allocation = reinterpret_cast<byte*>(std::allocator<_Stored>().allocate(1));
       std::construct_at(reinterpret_cast<byte**>(__buffer_), __allocation);
       return std::launder(reinterpret_cast<_Stored*>(__allocation));
     }
@@ -77,7 +77,7 @@ class __small_buffer {
   template <class _Stored>
   _LIBCPP_HIDE_FROM_ABI void __dealloc() noexcept {
     if constexpr (!__fits_in_buffer<_Stored>)
-      std::__libcpp_deallocate<_Stored>(__get<_Stored>(), __element_count(1));
+      std::allocator<_Stored>().deallocate(__get<_Stored>(), 1);
   }
 
   template <class _Stored, class... _Args>
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index f0defc3040ef9..aaedf93a81aef 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -1781,11 +1781,6 @@ module std {
   module new {
     header "new"
     module align_val_t          { header "__new/align_val_t.h" }
-    module allocate {
-      header "__new/allocate.h"
-      export std.utility.element_count // used as part of the API
-      export * // TODO: Workaround for https://llvm.org/PR120108
-    }
     module destroying_delete_t  { header "__new/destroying_delete_t.h" }
     module exceptions           { header "__new/exceptions.h" }
     module global_new_delete    {
diff --git a/libcxx/include/new b/libcxx/include/new
index 673e105bc5230..7b7be39537edc 100644
--- a/libcxx/include/new
+++ b/libcxx/include/new
@@ -91,7 +91,6 @@ void  operator delete[](void* ptr, void*) noexcept;                     // const
 #else
 #  include <__config>
 #  include <__new/align_val_t.h>
-#  include <__new/allocate.h>
 #  include <__new/exceptions.h>
 #  include <__new/global_new_delete.h>
 #  include <__new/new_handler.h>
diff --git a/libcxx/src/include/aligned_alloc.h b/libcxx/src/include/aligned_alloc.h
index 2b69a344006a3..07d50eab7151e 100644
--- a/libcxx/src/include/aligned_alloc.h
+++ b/libcxx/src/include/aligned_alloc.h
@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 // Low-level helpers to call the aligned allocation and deallocation functions
 // on the target platform. This is used to implement libc++'s own memory
 // allocation routines -- if you need to allocate memory inside the library,
-// chances are that you want to use `__libcpp_allocate` instead.
+// chances are that you want to use `allocator::allocate` instead.
 //
 // Returns the allocated memory, or `nullptr` on failure.
 inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) {
diff --git a/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp b/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
deleted file mode 100644
index 282d49d727c8c..0000000000000
--- a/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
+++ /dev/null
@@ -1,252 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// Test libc++'s implementation of align_val_t, and the relevant new/delete
-// overloads in all dialects when -faligned-allocation is present.
-
-// Libc++ when built for z/OS doesn't contain the aligned allocation functions,
-// nor does the dynamic library shipped with z/OS.
-// XFAIL: target={{.+}}-zos{{.*}}
-
-// XFAIL: sanitizer-new-delete && !hwasan
-
-// TODO: Investigate this failure
-// UNSUPPORTED: ubsan
-
-// GCC doesn't support the aligned-allocation flags.
-// XFAIL: gcc
-
-// ADDITIONAL_COMPILE_FLAGS: -I %{libcxx-dir}/src -Wno-macro-redefined
-
-// RUN: %{build} -faligned-allocation -fsized-deallocation
-// RUN: %{run}
-// RUN: %{build} -faligned-allocation -fno-sized-deallocation -DNO_SIZE
-// RUN: %{run}
-// RUN: %{build} -fno-aligned-allocation -fsized-deallocation -DNO_ALIGN
-// RUN: %{run}
-// RUN: %{build} -fno-aligned-allocation -fno-sized-deallocation -DNO_ALIGN -DNO_SIZE
-// RUN: %{run}
-
-#include <cassert>
-#include <cstdlib>
-#include <new>
-
-#include "test_macros.h"
-
-#include "include/aligned_alloc.h"
-
-struct alloc_stats {
-  alloc_stats() { reset(); }
-
-  int aligned_sized_called;
-  int aligned_called;
-  int sized_called;
-  int plain_called;
-  int last_size;
-  int last_align;
-
-  void reset() {
-    aligned_sized_called = aligned_called = sized_called = plain_called = 0;
-    last_align = last_size = -1;
-  }
-
-  bool expect_plain() const {
-    assert(aligned_sized_called == 0);
-    assert(aligned_called == 0);
-    assert(sized_called == 0);
-    assert(last_size == -1);
-    assert(last_align == -1);
-    return plain_called == 1;
-  }
-
-  bool expect_size(int n) const {
-    assert(plain_called == 0);
-    assert(aligned_sized_called == 0);
-    assert(aligned_called == 0);
-    assert(last_size == n);
-    assert(last_align == -1);
-    return sized_called == 1;
-  }
-
-  bool expect_align(int a) const {
-    assert(plain_called == 0);
-    assert(aligned_sized_called == 0);
-    assert(sized_called == 0);
-    assert(last_size == -1);
-    assert(last_align == a);
-    return aligned_called == 1;
-  }
-
-  bool expect_size_align(int n, int a) const {
-    assert(plain_called == 0);
-    assert(sized_called == 0);
-    assert(aligned_called == 0);
-    assert(last_size == n);
-    assert(last_align == a);
-    return aligned_sized_called == 1;
-  }
-};
-alloc_stats stats;
-
-void operator delete(void* p) TEST_NOEXCEPT {
-  ::free(p);
-  stats.plain_called++;
-  stats.last_size = stats.last_align = -1;
-}
-
-#ifndef NO_SIZE
-void operator delete(void* p, std::size_t n) TEST_NOEXCEPT {
-  ::free(p);
-  stats.sized_called++;
-  stats.last_size  = n;
-  stats.last_align = -1;
-}
-#endif
-
-#ifndef NO_ALIGN
-void operator delete(void* p, std::align_val_t a) TEST_NOEXCEPT {
-  std::__libcpp_aligned_free(p);
-  stats.aligned_called++;
-  stats.last_align = static_cast<int>(a);
-  stats.last_size  = -1;
-}
-
-void operator delete(void* p, std::size_t n, std::align_val_t a) TEST_NOEXCEPT {
-  std::__libcpp_aligned_free(p);
-  stats.aligned_sized_called++;
-  stats.last_align = static_cast<int>(a);
-  stats.last_size  = n;
-}
-#endif
-
-void test_libcpp_dealloc() {
-  void* p = nullptr;
-#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
-  std::size_t over_align_val = __STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2;
-#else
-  std::size_t over_align_val = TEST_ALIGNOF(std::max_align_t) * 2;
-#endif
-  std::size_t under_align_val = TEST_ALIGNOF(int);
-  std::size_t with_size_val   = 2;
-
-  {
-    std::__libcpp_deallocate_unsized<char>(static_cast<char*>(p), under_align_val);
-    assert(stats.expect_plain());
-  }
-  stats.reset();
-
-#if defined(NO_SIZE) && defined(NO_ALIGN)
-  {
-    std::__libcpp_deallocate<char>(static_cast<char*>(p), std::__element_count(with_size_val), over_align_val);
-    assert(stats.expect_plain());
-  }
-  stats.reset();
-#elif defined(NO_SIZE)
-  {
-    std::__libcpp_deallocate<char>(static_cast<char*>(p), std::__element_count(with_size_val), over_align_val);
-    assert(stats.expect_align(over_align_val));
-  }
-  stats.reset();
-#elif defined(NO_ALIGN)
-  {
-    std::__libcpp_deallocate<char>(static_cast<char*>(p), std::__element_count(with_size_val), over_align_val);
-    assert(stats.expect_size(with_size_val));
-  }
-  stats.reset();
-#else
-  {
-    std::__libcpp_deallocate<char>(static_cast<char*>(p), std::__element_count(with_size_val), over_align_val);
-    assert(stats.expect_size_align(with_size_val, over_align_val));
-  }
-  stats.reset();
-  {
-    std::__libcpp_deallocate_unsized<char>(static_cast<char*>(p), over_align_val);
-    assert(stats.expect_align(over_align_val));
-  }
-  stats.reset();
-  {
-    std::__libcpp_deallocate<char>(static_cast<char*>(p), std::__element_count(with_size_val), under_align_val);
-    assert(stats.expect_size(with_size_val));
-  }
-  stats.reset();
-#endif
-}
-
-struct TEST_ALIGNAS(128) AlignedType {
-  AlignedType() : elem(0) {}
-  TEST_ALIGNAS(128) char elem;
-};
-
-void test_allocator_and_new_match() {
-  stats.reset();
-#if defined(NO_SIZE) && defined(NO_ALIGN)
-  {
-    int* x = DoNotOptimize(new int(42));
-    delete x;
-    assert(stats.expect_plain());
-  }
-  stats.reset();
-  {
-    AlignedType* a = DoNotOptimize(new AlignedType());
-    delete a;
-    assert(stats.expect_plain());
-  }
-  stats.reset();
-#elif defined(NO_SIZE)
-  stats.reset();
-#  if TEST_STD_VER >= 11
-  {
-    int* x = DoNotOptimize(new int(42));
-    delete x;
-    assert(stats.expect_plain());
-  }
-#  endif
-  stats.reset();
-  {
-    AlignedType* a = DoNotOptimize(new AlignedType());
-    delete a;
-    assert(stats.expect_align(TEST_ALIGNOF(AlignedType)));
-  }
-  stats.reset();
-#elif defined(NO_ALIGN)
-  stats.reset();
-  {
-    int* x = DoNotOptimize(new int(42));
-    delete x;
-    assert(stats.expect_size(sizeof(int)));
-  }
-  stats.reset();
-  {
-    AlignedType* a = DoNotOptimize(new AlignedType());
-    delete a;
-    assert(stats.expect_size(sizeof(AlignedType)));
-  }
-  stats.reset();
-#else
-  stats.reset();
-  {
-    int* x = DoNotOptimize(new int(42));
-    delete x;
-    assert(stats.expect_size(sizeof(int)));
-  }
-  stats.reset();
-  {
-    AlignedType* a = DoNotOptimize(new AlignedType());
-    delete a;
-    assert(stats.expect_size_align(sizeof(AlignedType), TEST_ALIGNOF(AlignedType)));
-  }
-  stats.reset();
-#endif
-}
-
-int main(int, char**) {
-  test_libcpp_dealloc();
-  test_allocator_and_new_match();
-
-  return 0;
-}
diff --git a/libcxx/test/std/numerics/numarray/template.valarray/valarray.cons/size.pass.cpp b/libcxx/test/std/numerics/numarray/template.valarray/valarray.cons/size.pass.cpp
index 21d4ee15f57c6..fd7b903116c75 100644
--- a/libcxx/test/std/numerics/numarray/template.valarray/valarray.cons/size.pass.cpp
+++ b/libcxx/test/std/numerics/numarray/template.valarray/valarray.cons/size.pass.cpp
@@ -12,8 +12,9 @@
 
 // explicit valarray(size_t);
 
-#include <valarray>
 #include <cassert>
+#include <cstdint>
+#include <valarray>
 
 #include "test_macros.h"
 
@@ -24,7 +25,7 @@ struct S {
     static std::size_t cnt_dtor;
 };
 
-size_t S::cnt_dtor = 0;
+std::size_t S::cnt_dtor = 0;
 
 int main(int, char**)
 {



More information about the libcxx-commits mailing list