Skip to content

Commit 27f0bf7

Browse files
committed
ADT: ArrayRef: Assert that begin <= end
This came up in the context of #63169 - if this assert were in place it would've been much easier to reduce the test case.
1 parent 8a86f85 commit 27f0bf7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

llvm/include/llvm/ADT/ArrayRef.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ namespace llvm {
7979

8080
/// Construct an ArrayRef from a range.
8181
constexpr ArrayRef(const T *begin, const T *end)
82-
: Data(begin), Length(end - begin) {}
82+
: Data(begin), Length(end - begin) {
83+
assert(begin <= end);
84+
}
8385

8486
/// Construct an ArrayRef from a SmallVector. This is templated in order to
8587
/// avoid instantiating SmallVectorTemplateCommon<T> whenever we

0 commit comments

Comments
 (0)