Skip to content

Commit fd35899

Browse files
[IR] Use range-based for loops (NFC)
1 parent c0cb803 commit fd35899

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

llvm/lib/IR/Dominators.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ static constexpr bool ExpensiveChecksEnabled = false;
4949
#endif
5050

5151
bool BasicBlockEdge::isSingleEdge() const {
52-
const Instruction *TI = Start->getTerminator();
5352
unsigned NumEdgesToEnd = 0;
54-
for (unsigned int i = 0, n = TI->getNumSuccessors(); i < n; ++i) {
55-
if (TI->getSuccessor(i) == End)
53+
for (const BasicBlock *Succ : successors(Start)) {
54+
if (Succ == End)
5655
++NumEdgesToEnd;
5756
if (NumEdgesToEnd >= 2)
5857
return false;

llvm/lib/IR/StructuralHash.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,9 @@ class StructuralHashImpl {
125125
for (auto &Inst : *BB)
126126
updateInstruction(Inst, DetailedHash);
127127

128-
const Instruction *Term = BB->getTerminator();
129-
for (unsigned i = 0, e = Term->getNumSuccessors(); i != e; ++i) {
130-
if (!VisitedBBs.insert(Term->getSuccessor(i)).second)
131-
continue;
132-
BBs.push_back(Term->getSuccessor(i));
133-
}
128+
for (const BasicBlock *Succ : successors(BB))
129+
if (VisitedBBs.insert(Succ).second)
130+
BBs.push_back(Succ);
134131
}
135132
}
136133

0 commit comments

Comments
 (0)