[PATCH] D133502: [ADT] Mark `llvm::array_lengthof` as deprecated

Joe Loser via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 8 09:24:56 PDT 2022


jloser added a comment.

In D133502#3777484 <https://reviews.llvm.org/D133502#3777484>, @kazu wrote:

> By the way, I just realized that `array_lengthof` is the only thing in `STLArrayExtras.h`.  You might want to consider a follow-up patch to stop including the header file (at 7 places or so).  Thanks!

Yep, I plan on doing that and fixing clang and lldb to no longer use this function as well. Once all of the internal callers are using `std::size`, then I'll land this.



================
Comment at: llvm/include/llvm/ADT/STLArrayExtras.h:29
 template <class T, std::size_t N>
-constexpr inline size_t array_lengthof(T (&)[N]) {
+[[deprecated("Use std::size(T(&)[N) instead")]] constexpr inline size_t
+array_lengthof(T (&)[N]) {
----------------
kazu wrote:
> Consider saying something like:
> 
> ```
> LLVM_DEPRECATED("Use std::size instead.", "std::size")
> ```
> 
> This way, the compiler warning 'underlines' `array_lengthof`, which I find very helpful.
> 
Just changed to using `LLVM_DEPRECATED` — thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133502/new/

https://reviews.llvm.org/D133502



More information about the llvm-commits mailing list