[libcxx-commits] [libcxx] [libc++][test] Don't use `__libcpp_is_constant_evaluated` in `min_allocator.h` (PR #72226)

S. B. Tam via libcxx-commits libcxx-commits at lists.llvm.org
Tue Nov 14 01:49:04 PST 2023


https://github.com/cpplearner updated https://github.com/llvm/llvm-project/pull/72226

>From 50913c7fd1a31f481de16e9c9f880789c9af7bd5 Mon Sep 17 00:00:00 2001
From: cpplearner <cpplearner at outlook.com>
Date: Tue, 14 Nov 2023 17:46:24 +0800
Subject: [PATCH] [libc++][test] Don't use __libcpp_is_constant_evaluated in
 tests

---
 libcxx/test/support/asan_testing.h  | 2 +-
 libcxx/test/support/min_allocator.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libcxx/test/support/asan_testing.h b/libcxx/test/support/asan_testing.h
index 759956ba687b46c..5d044374044dea7 100644
--- a/libcxx/test/support/asan_testing.h
+++ b/libcxx/test/support/asan_testing.h
@@ -19,7 +19,7 @@ extern "C" int __sanitizer_verify_contiguous_container
 template <typename T, typename Alloc>
 TEST_CONSTEXPR bool is_contiguous_container_asan_correct ( const std::vector<T, Alloc> &c )
 {
-    if (std::__libcpp_is_constant_evaluated())
+    if (TEST_IS_CONSTANT_EVALUATED)
         return true;
     if (std::is_same<Alloc, std::allocator<T> >::value && c.data() != NULL)
         return __sanitizer_verify_contiguous_container(
diff --git a/libcxx/test/support/min_allocator.h b/libcxx/test/support/min_allocator.h
index 1b3727af8185c61..13ee98289c36b7a 100644
--- a/libcxx/test/support/min_allocator.h
+++ b/libcxx/test/support/min_allocator.h
@@ -464,14 +464,14 @@ class safe_allocator {
 
   TEST_CONSTEXPR_CXX20 T* allocate(std::size_t n) {
     T* memory = std::allocator<T>().allocate(n);
-    if (!std::__libcpp_is_constant_evaluated())
+    if (!TEST_IS_CONSTANT_EVALUATED)
       std::memset(memory, 0, sizeof(T) * n);
 
     return memory;
   }
 
   TEST_CONSTEXPR_CXX20 void deallocate(T* p, std::size_t n) {
-    if (!std::__libcpp_is_constant_evaluated())
+    if (!TEST_IS_CONSTANT_EVALUATED)
       DoNotOptimize(std::memset(p, 0, sizeof(T) * n));
     std::allocator<T>().deallocate(p, n);
   }



More information about the libcxx-commits mailing list