[libcxx-commits] [libcxx] [libc++] Use __array_rank in Clang versions without any known bugs (PR #136103)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Apr 25 01:37:05 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Nikolas Klauser (philnik777)

<details>
<summary>Changes</summary>

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.


---
Full diff: https://github.com/llvm/llvm-project/pull/136103.diff


1 Files Affected:

- (modified) libcxx/include/__type_traits/rank.h (+3-3) 


``````````diff
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
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/136103


More information about the libcxx-commits mailing list