aboutsummaryrefslogtreecommitdiff
path: root/llvm
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2023-07-19 18:42:57 +0000
committerDavid Blaikie <dblaikie@gmail.com>2023-07-25 03:04:42 +0000
commit27f0bf75df78d7439ad698c70e75bf138525db3e (patch)
tree5f8ca98f27153ff17056c7519bf68472eb3b4ffd /llvm
parent8a86f85ab1e65fb5c148d7a645197b4634a2e2fc (diff)
downloadllvm-27f0bf75df78d7439ad698c70e75bf138525db3e.zip
llvm-27f0bf75df78d7439ad698c70e75bf138525db3e.tar.gz
llvm-27f0bf75df78d7439ad698c70e75bf138525db3e.tar.bz2
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.
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/ADT/ArrayRef.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h
index a25cf1c..713f463 100644
--- a/llvm/include/llvm/ADT/ArrayRef.h
+++ b/llvm/include/llvm/ADT/ArrayRef.h
@@ -79,7 +79,9 @@ namespace llvm {
/// Construct an ArrayRef from a range.
constexpr ArrayRef(const T *begin, const T *end)
- : Data(begin), Length(end - begin) {}
+ : Data(begin), Length(end - begin) {
+ assert(begin <= end);
+ }
/// Construct an ArrayRef from a SmallVector. This is templated in order to
/// avoid instantiating SmallVectorTemplateCommon<T> whenever we