[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 00:57:10 PST 2023
https://github.com/cpplearner updated https://github.com/llvm/llvm-project/pull/72226
>From 4db97a3541e9925c0bd51b9af4ea2b2c3b056e26 Mon Sep 17 00:00:00 2001
From: "S. B. Tam" <cpplearner at outlook.com>
Date: Tue, 14 Nov 2023 16:21:29 +0800
Subject: [PATCH 1/2] [libc++][test] Don't use __libcpp_is_constant_evaluated
in min_allocator.h
---
libcxx/test/support/min_allocator.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/libcxx/test/support/min_allocator.h b/libcxx/test/support/min_allocator.h
index 1b3727af8185c61..90709e1779b0ad9 100644
--- a/libcxx/test/support/min_allocator.h
+++ b/libcxx/test/support/min_allocator.h
@@ -21,6 +21,14 @@
#include "test_macros.h"
+inline constexpr bool test_is_constant_evaluated() {
+#if TEST_STD_VER >= 20
+ return std::is_constant_evaluated();
+#else
+ return false;
+#endif
+}
+
template <class T>
class bare_allocator
{
@@ -464,14 +472,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);
}
>From b3ece943df41dfa94a97af202579b809d3c47b42 Mon Sep 17 00:00:00 2001
From: "S. B. Tam" <cpplearner at outlook.com>
Date: Tue, 14 Nov 2023 16:57:02 +0800
Subject: [PATCH 2/2] Fix
---
libcxx/test/support/min_allocator.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/test/support/min_allocator.h b/libcxx/test/support/min_allocator.h
index 90709e1779b0ad9..76bfe273c69fa02 100644
--- a/libcxx/test/support/min_allocator.h
+++ b/libcxx/test/support/min_allocator.h
@@ -21,7 +21,7 @@
#include "test_macros.h"
-inline constexpr bool test_is_constant_evaluated() {
+inline TEST_CONSTEXPR bool test_is_constant_evaluated() {
#if TEST_STD_VER >= 20
return std::is_constant_evaluated();
#else
More information about the libcxx-commits
mailing list