Skip to content

Commit deb22fa

Browse files
authored
[ADT] Fix ArrayRef<T>::slice (#113048)
Current implementation of `slice(N)` is buggy, since `slice(N, size() - N)` will never fail the assertion `assert(N+M <= size() && "Invalid specifier")` above, even `N > size()`.
1 parent affb2b7 commit deb22fa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/include/llvm/ADT/ArrayRef.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ namespace llvm {
198198
}
199199

200200
/// slice(n) - Chop off the first N elements of the array.
201-
ArrayRef<T> slice(size_t N) const { return slice(N, size() - N); }
201+
ArrayRef<T> slice(size_t N) const { return drop_front(N); }
202202

203203
/// Drop the first \p N elements of the array.
204204
ArrayRef<T> drop_front(size_t N = 1) const {

0 commit comments

Comments
 (0)