[llvm] [ADT] Fix ArrayRef<T>::slice (PR #113048)
Jakub Kuderski via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 19 18:38:30 PDT 2024
================
@@ -198,7 +198,10 @@ namespace llvm {
}
/// slice(n) - Chop off the first N elements of the array.
- ArrayRef<T> slice(size_t N) const { return slice(N, size() - N); }
+ ArrayRef<T> slice(size_t N) const {
+ assert(N <= size() && "Invalid specifier");
+ return slice(N, size() - N);
----------------
kuhar wrote:
I think `drop_front` is more idiomatic and we could probably mark the single-argument slice as deprecated and eventually remove it. Although that's all out of scope for this PR. cc: @kazutakahirata
https://github.com/llvm/llvm-project/pull/113048
More information about the llvm-commits
mailing list