[libcxx-commits] [libcxx] [libc++][test] Don't use `__libcpp_is_constant_evaluated` in `min_allocator.h` (PR #72226)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Nov 14 00:25:32 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: S. B. Tam (cpplearner)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/72226.diff
1 Files Affected:
- (modified) libcxx/test/support/min_allocator.h (+10-2)
``````````diff
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);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/72226
More information about the libcxx-commits
mailing list