[llvm] dc8446c - [ADT][NFC] Use `size_t` type for index in `indexed_accessor_range`

Vladislav Vinogradov via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 10 00:41:48 PST 2021


Author: Vladislav Vinogradov
Date: 2021-03-10T11:40:59+03:00
New Revision: dc8446c2a0882a0779a12df72e968afe9161a339

URL: https://github.com/llvm/llvm-project/commit/dc8446c2a0882a0779a12df72e968afe9161a339
DIFF: https://github.com/llvm/llvm-project/commit/dc8446c2a0882a0779a12df72e968afe9161a339.diff

LOG: [ADT][NFC] Use `size_t` type for index in `indexed_accessor_range`

It makes it consistent with `size()` method return type and with
STL-like containers API.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D97921

Added: 
    

Modified: 
    llvm/include/llvm/ADT/STLExtras.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index 7741edf04959..67aa6341c951 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -1114,9 +1114,9 @@ class indexed_accessor_range_base {
 
   iterator begin() const { return iterator(base, 0); }
   iterator end() const { return iterator(base, count); }
-  ReferenceT operator[](unsigned index) const {
-    assert(index < size() && "invalid index for value range");
-    return DerivedT::dereference_iterator(base, index);
+  ReferenceT operator[](size_t Index) const {
+    assert(Index < size() && "invalid index for value range");
+    return DerivedT::dereference_iterator(base, static_cast<ptr
diff _t>(Index));
   }
   ReferenceT front() const {
     assert(!empty() && "expected non-empty range");


        


More information about the llvm-commits mailing list