[compiler-rt] 6114579 - [NFC][sanitizer] Extend ArrayRef
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Tue May 30 19:19:39 PDT 2023
Author: Vitaly Buka
Date: 2023-05-30T19:19:33-07:00
New Revision: 6114579b609a560c504d80337d992223a095a685
URL: https://github.com/llvm/llvm-project/commit/6114579b609a560c504d80337d992223a095a685
DIFF: https://github.com/llvm/llvm-project/commit/6114579b609a560c504d80337d992223a095a685.diff
LOG: [NFC][sanitizer] Extend ArrayRef
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_common.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
index afd1a786d5d33..d43e066ca1b9b 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
@@ -1085,12 +1085,19 @@ class ArrayRef {
ArrayRef() {}
ArrayRef(T *begin, T *end) : begin_(begin), end_(end) {}
- T *begin() { return begin_; }
- T *end() { return end_; }
+ template <typename C>
+ ArrayRef(const C &src) : begin_(src.begin()), end_(src.end()) {}
+
+ const T *begin() const { return begin_; }
+ const T *end() const { return end_; }
+
+ bool empty() const { return begin_ == end_; }
+
+ uptr size() const { return end_ - begin_; }
private:
- T *begin_ = nullptr;
- T *end_ = nullptr;
+ const T *begin_ = nullptr;
+ const T *end_ = nullptr;
};
} // namespace __sanitizer
More information about the llvm-commits
mailing list