Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADT] Fix ArrayRef<T>::slice #113048

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

[ADT] Fix ArrayRef<T>::slice #113048

wants to merge 1 commit into from

Conversation

FLZ101
Copy link
Contributor

@FLZ101 FLZ101 commented Oct 19, 2024

No description provided.

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 19, 2024

@llvm/pr-subscribers-llvm-adt

Author: Franklin (FLZ101)

Changes

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

1 Files Affected:

  • (modified) llvm/include/llvm/ADT/ArrayRef.h (+4-1)
diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h
index ac40ec4a6b2404..69a08fd079043a 100644
--- a/llvm/include/llvm/ADT/ArrayRef.h
+++ b/llvm/include/llvm/ADT/ArrayRef.h
@@ -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);
+    }
 
     /// Drop the first \p N elements of the array.
     ArrayRef<T> drop_front(size_t N = 1) const {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants