[llvm] 0de859c - [MC] Fix operator++ for various MCRegister iterators (#81250)

via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 9 06:16:52 PST 2024


Author: Jay Foad
Date: 2024-02-09T14:16:48Z
New Revision: 0de859c8f22669ab7a816afdf975c7b012e511b9

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

LOG: [MC] Fix operator++ for various MCRegister iterators (#81250)

Return *this from operator++. NFC, this just allows using ++Iter in
an expression in future patches.

Added: 
    

Modified: 
    llvm/include/llvm/MC/MCRegisterInfo.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/MC/MCRegisterInfo.h b/llvm/include/llvm/MC/MCRegisterInfo.h
index e52f0a4ff86edf..fb4d11ec1d4d16 100644
--- a/llvm/include/llvm/MC/MCRegisterInfo.h
+++ b/llvm/include/llvm/MC/MCRegisterInfo.h
@@ -572,9 +572,10 @@ class MCSubRegIndexIterator {
   bool isValid() const { return SRIter.isValid(); }
 
   /// Moves to the next position.
-  void operator++() {
+  MCSubRegIndexIterator &operator++() {
     ++SRIter;
     ++SRIndex;
+    return *this;
   }
 };
 
@@ -688,9 +689,10 @@ class MCRegUnitMaskIterator {
   bool isValid() const { return RUIter.isValid(); }
 
   /// Moves to the next position.
-  void operator++() {
+  MCRegUnitMaskIterator &operator++() {
     ++MaskListIter;
     ++RUIter;
+    return *this;
   }
 };
 
@@ -728,10 +730,11 @@ class MCRegUnitRootIterator {
   }
 
   /// Preincrement to move to the next root register.
-  void operator++() {
+  MCRegUnitRootIterator &operator++() {
     assert(isValid() && "Cannot move off the end of the list.");
     Reg0 = Reg1;
     Reg1 = 0;
+    return *this;
   }
 };
 
@@ -788,10 +791,11 @@ class MCRegAliasIterator {
     }
   }
 
-  void operator++() {
+  MCRegAliasIterator &operator++() {
     assert(isValid() && "Cannot move off the end of the list.");
     do advance();
     while (!IncludeSelf && isValid() && *SI == Reg);
+    return *this;
   }
 };
 


        


More information about the llvm-commits mailing list