[llvm] [MC] Fix operator++ for various MCRegister iterators (PR #81250)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 9 05:51:13 PST 2024
https://github.com/jayfoad created https://github.com/llvm/llvm-project/pull/81250
Return *this from operator++. NFC, this just allows using ++Iter in
an expression in future patches.
>From e3e07b0d9c8578422710798391411892d5e30543 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Fri, 9 Feb 2024 13:49:15 +0000
Subject: [PATCH] [MC] Fix operator++ for various MCRegister iterators
Return *this from operator++. NFC, this just allows using ++Iter in
an expression in future patches.
---
llvm/include/llvm/MC/MCRegisterInfo.h | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
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