As a follow-up of 5e96cea1db0623a833d5376c9ea2ce4528771f97, mark
llvm::array_lengthof as deprecated in favor of using std::size function
directly.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
As I commented in D133429, please be sure to take care of replacements in internal downstream users before checking this in. LGTM other than that. Thanks!
llvm/include/llvm/ADT/STLArrayExtras.h | ||
---|---|---|
30 | 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. |
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.
llvm/include/llvm/ADT/STLArrayExtras.h | ||
---|---|---|
30 | Just changed to using LLVM_DEPRECATED — thanks! |
With my downstream inspection, I think array_lengthof is used much less than Optional::{hasValue,getValue}, etc.
I appreciate that Optional::{hasValue,getValue} had a very long deprecation period so downstream can be more prepared.
array_lengthof removal may not need that long time.
This produces a warning when built with GCC for every single source file that includes the header:
../include/llvm/Support/Compiler.h:145:35: warning: attribute ignored [-Wattributes] 145 | #define LLVM_DEPRECATED(MSG, FIX) [[deprecated(MSG)]] | ^ ../include/llvm/ADT/STLArrayExtras.h:31:18: note: in expansion of macro ‘LLVM_DEPRECATED’ 31 | constexpr inline LLVM_DEPRECATED("Use std::size instead.", "std::size") size_t | ^~~~~~~~~~~~~~~ ../include/llvm/Support/Compiler.h:145:35: note: an attribute that appertains to a type-specifier is ignored 145 | #define LLVM_DEPRECATED(MSG, FIX) [[deprecated(MSG)]] | ^ ../include/llvm/ADT/STLArrayExtras.h:31:18: note: in expansion of macro ‘LLVM_DEPRECATED’ 31 | constexpr inline LLVM_DEPRECATED("Use std::size instead.", "std::size") size_t | ^~~~~~~~~~~~~~~
Should be fixed now. The placement before Placement of LLVM_DEPRECATED matters was actually correct for [[deprecated(...)]] :)
Thanks for the quick fix, @MaskRay — I appreciate it. By the way, the extra includes for STLArrayExtras.h in the LLVM tree is addressed with https://reviews.llvm.org/D133600
Consider saying something like:
This way, the compiler warning 'underlines' array_lengthof, which I find very helpful.