Skip to content

Commit c19028f

Browse files
[GenericDomTree] Use range-based for loops (NFC) (#96404)
1 parent 8990763 commit c19028f

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

llvm/include/llvm/Support/GenericDomTree.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,8 @@ template <class NodeT>
187187
void PrintDomTree(const DomTreeNodeBase<NodeT> *N, raw_ostream &O,
188188
unsigned Lev) {
189189
O.indent(2 * Lev) << "[" << Lev << "] " << N;
190-
for (typename DomTreeNodeBase<NodeT>::const_iterator I = N->begin(),
191-
E = N->end();
192-
I != E; ++I)
193-
PrintDomTree<NodeT>(*I, O, Lev + 1);
190+
for (const auto &I : *N)
191+
PrintDomTree<NodeT>(I, O, Lev + 1);
194192
}
195193

196194
namespace DomTreeBuilder {

llvm/include/llvm/Support/GenericDomTreeConstruction.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,7 @@ struct SemiNCAInfo {
595595
// Attach the first unreachable block to AttachTo.
596596
NodeToInfo[NumToNode[1]].IDom = AttachTo->getBlock();
597597
// Loop over all of the discovered blocks in the function...
598-
for (size_t i = 1, e = NumToNode.size(); i != e; ++i) {
599-
NodePtr W = NumToNode[i];
600-
598+
for (NodePtr W : llvm::drop_begin(NumToNode)) {
601599
// Don't replace this with 'count', the insertion side effect is important
602600
if (DT.DomTreeNodes[W]) continue; // Haven't calculated this node yet?
603601

@@ -614,8 +612,7 @@ struct SemiNCAInfo {
614612

615613
void reattachExistingSubtree(DomTreeT &DT, const TreeNodePtr AttachTo) {
616614
NodeToInfo[NumToNode[1]].IDom = AttachTo->getBlock();
617-
for (size_t i = 1, e = NumToNode.size(); i != e; ++i) {
618-
const NodePtr N = NumToNode[i];
615+
for (const NodePtr N : llvm::drop_begin(NumToNode)) {
619616
const TreeNodePtr TN = DT.getNode(N);
620617
assert(TN);
621618
const TreeNodePtr NewIDom = DT.getNode(NodeToInfo[N].IDom);

0 commit comments

Comments
 (0)