[libcxx-commits] [libcxx] [libc++] Use __array_rank in Clang versions without any known bugs (PR #136103)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Apr 17 01:00:00 PDT 2025
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/136103
There was a bug in the implementation of `__array_rank` until LLVM 20 which prevented us from using the builtin. Since the bug has been fixed now we can enable the use and remove the generic implementation in a few releases.
>From 897b270d5dc94d898145c2cf1f40f255f827fc25 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Thu, 17 Apr 2025 09:58:48 +0200
Subject: [PATCH] [libc++] Use __array_rank in Clang versions without any known
bugs
---
libcxx/include/__type_traits/rank.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libcxx/include/__type_traits/rank.h b/libcxx/include/__type_traits/rank.h
index 55c78ea044b37..5196b62949fa2 100644
--- a/libcxx/include/__type_traits/rank.h
+++ b/libcxx/include/__type_traits/rank.h
@@ -19,11 +19,11 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-// TODO: Enable using the builtin __array_rank when https://llvm.org/PR57133 is resolved
-#if __has_builtin(__array_rank) && 0
+#if __has_builtin(__array_rank) && !defined(_LIBCPP_COMPILER_CLANG_BASED) || \
+ (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 2001)
template <class _Tp>
-struct rank : integral_constant<size_t, __array_rank(_Tp)> {};
+struct _LIBCPP_NO_SPECIALIZATIONS rank : integral_constant<size_t, __array_rank(_Tp)> {};
#else
More information about the libcxx-commits
mailing list