[llvm] bf02dfc - [llvm][ADT] Some AddressRanges.h improvements (#132847)

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 28 14:52:03 PDT 2025


Author: Mohammed Keyvanzadeh
Date: 2025-03-29T01:22:00+03:30
New Revision: bf02dfcd8c69f45f5ea0e273fc63cc34675ae5c2

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

LOG: [llvm][ADT] Some AddressRanges.h improvements (#132847)

- Rename parameter to adhere to the project's parameter naming
convention.
- Remove redundant template argument.
- Remove redundant name-qualification.
- Change non-explicit conversion operator to an explicit one to avoid
surprising implicit conversions.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/AddressRanges.h b/llvm/include/llvm/ADT/AddressRanges.h
index 415d30bbb5cf9..299b89c18b7e9 100644
--- a/llvm/include/llvm/ADT/AddressRanges.h
+++ b/llvm/include/llvm/ADT/AddressRanges.h
@@ -83,12 +83,12 @@ template <typename T> class AddressRangesBase {
   typename Collection::const_iterator begin() const { return Ranges.begin(); }
   typename Collection::const_iterator end() const { return Ranges.end(); }
 
-  const T &operator[](size_t i) const {
-    assert(i < Ranges.size());
-    return Ranges[i];
+  const T &operator[](size_t I) const {
+    assert(I < Ranges.size());
+    return Ranges[I];
   }
 
-  bool operator==(const AddressRangesBase<T> &RHS) const {
+  bool operator==(const AddressRangesBase &RHS) const {
     return Ranges == RHS.Ranges;
   }
 
@@ -124,7 +124,7 @@ class AddressRanges : public AddressRangesBase<AddressRange> {
     if (Range.empty())
       return Ranges.end();
 
-    auto It = llvm::upper_bound(Ranges, Range);
+    auto It = upper_bound(Ranges, Range);
     auto It2 = It;
     while (It2 != Ranges.end() && It2->start() <= Range.end())
       ++It2;
@@ -144,7 +144,7 @@ class AddressRanges : public AddressRangesBase<AddressRange> {
 
 class AddressRangeValuePair {
 public:
-  operator AddressRange() const { return Range; }
+  explicit operator AddressRange() const { return Range; }
 
   AddressRange Range;
   int64_t Value = 0;


        


More information about the llvm-commits mailing list