[clang] Remove device override for operator new when the C++ standard >= 26 (PR #114056)
Ognyan Mirev via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 30 02:43:49 PDT 2024
https://github.com/OgnianM updated https://github.com/llvm/llvm-project/pull/114056
>From db9a3ff75fdaf5f838826c809f84dcc471420920 Mon Sep 17 00:00:00 2001
From: ognyan <ognyan.mirev at software-supreme.com>
Date: Tue, 29 Oct 2024 15:38:34 +0200
Subject: [PATCH 1/2] Remove device override for operator new when the C++
standard >= 26
---
clang/lib/Headers/cuda_wrappers/new | 2 ++
1 file changed, 2 insertions(+)
diff --git a/clang/lib/Headers/cuda_wrappers/new b/clang/lib/Headers/cuda_wrappers/new
index d5fb3b7011de96..41dde0bf20403e 100644
--- a/clang/lib/Headers/cuda_wrappers/new
+++ b/clang/lib/Headers/cuda_wrappers/new
@@ -91,12 +91,14 @@ __device__ inline void operator delete[](void *ptr,
#endif
// Device overrides for placement new and delete.
+#if _LIBCPP_STD_VER < 26
__device__ inline void *operator new(__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT {
return __ptr;
}
__device__ inline void *operator new[](__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT {
return __ptr;
}
+#endif
__device__ inline void operator delete(void *, void *) CUDA_NOEXCEPT {}
__device__ inline void operator delete[](void *, void *) CUDA_NOEXCEPT {}
>From 635829e015d5943e63c2440e6af4236dfb86bf32 Mon Sep 17 00:00:00 2001
From: ognyan <ognyan.mirev at software-supreme.com>
Date: Wed, 30 Oct 2024 11:43:15 +0200
Subject: [PATCH 2/2] Change the #if to also check for the libstdc++ constexpr
new
---
clang/lib/Headers/cuda_wrappers/new | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/Headers/cuda_wrappers/new b/clang/lib/Headers/cuda_wrappers/new
index 41dde0bf20403e..9d3e31690e677c 100644
--- a/clang/lib/Headers/cuda_wrappers/new
+++ b/clang/lib/Headers/cuda_wrappers/new
@@ -91,7 +91,7 @@ __device__ inline void operator delete[](void *ptr,
#endif
// Device overrides for placement new and delete.
-#if _LIBCPP_STD_VER < 26
+#if !(_LIBCPP_STD_VER >= 26 || __cpp_lib_constexpr_new >= 202406L)
__device__ inline void *operator new(__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT {
return __ptr;
}
More information about the cfe-commits
mailing list