[llvm] ec59313 - [EquivalenceClasses] Use range-based for loops (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 1 13:45:20 PDT 2025
Author: Florian Hahn
Date: 2025-04-01T21:45:01+01:00
New Revision: ec59313c0416018dc008c586478b825fe42bf323
URL: https://github.com/llvm/llvm-project/commit/ec59313c0416018dc008c586478b825fe42bf323
DIFF: https://github.com/llvm/llvm-project/commit/ec59313c0416018dc008c586478b825fe42bf323.diff
LOG: [EquivalenceClasses] Use range-based for loops (NFC).
Added:
Modified:
llvm/include/llvm/ADT/EquivalenceClasses.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/EquivalenceClasses.h b/llvm/include/llvm/ADT/EquivalenceClasses.h
index 4f692052847aa..46f186a71f5ce 100644
--- a/llvm/include/llvm/ADT/EquivalenceClasses.h
+++ b/llvm/include/llvm/ADT/EquivalenceClasses.h
@@ -146,9 +146,9 @@ class EquivalenceClasses {
EquivalenceClasses &operator=(const EquivalenceClasses &RHS) {
TheMapping.clear();
- for (iterator I = RHS.begin(), E = RHS.end(); I != E; ++I)
- if (I->isLeader()) {
- member_iterator MI = RHS.member_begin(*I);
+ for (const auto &E : RHS)
+ if (E.isLeader()) {
+ member_iterator MI = RHS.member_begin(E);
member_iterator LeaderIt = member_begin(insert(*MI));
for (++MI; MI != member_end(); ++MI)
unionSets(LeaderIt, member_begin(insert(*MI)));
@@ -207,8 +207,9 @@ class EquivalenceClasses {
/// Note that this is a linear time operation.
unsigned getNumClasses() const {
unsigned NC = 0;
- for (iterator I = begin(), E = end(); I != E; ++I)
- if (I->isLeader()) ++NC;
+ for (const auto &E : *this)
+ if (E.isLeader())
+ ++NC;
return NC;
}
More information about the llvm-commits
mailing list