diff options
author | Kazu Hirata <kazu@google.com> | 2024-06-23 08:29:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-23 08:29:46 -0700 |
commit | c19028f364cceb4b2111c7956dcacbc257a96fd4 (patch) | |
tree | 062384c37cef420bf309f416aaa0ff4246bcfa5b | |
parent | 8990763d2c974a179dd0ed42b0cfb7b8b60e9c0c (diff) | |
download | llvm-c19028f364cceb4b2111c7956dcacbc257a96fd4.zip llvm-c19028f364cceb4b2111c7956dcacbc257a96fd4.tar.gz llvm-c19028f364cceb4b2111c7956dcacbc257a96fd4.tar.bz2 |
[GenericDomTree] Use range-based for loops (NFC) (#96404)
-rw-r--r-- | llvm/include/llvm/Support/GenericDomTree.h | 6 | ||||
-rw-r--r-- | llvm/include/llvm/Support/GenericDomTreeConstruction.h | 7 |
2 files changed, 4 insertions, 9 deletions
diff --git a/llvm/include/llvm/Support/GenericDomTree.h b/llvm/include/llvm/Support/GenericDomTree.h index 4fce9d8..a8e178d 100644 --- a/llvm/include/llvm/Support/GenericDomTree.h +++ b/llvm/include/llvm/Support/GenericDomTree.h @@ -187,10 +187,8 @@ template <class NodeT> void PrintDomTree(const DomTreeNodeBase<NodeT> *N, raw_ostream &O, unsigned Lev) { O.indent(2 * Lev) << "[" << Lev << "] " << N; - for (typename DomTreeNodeBase<NodeT>::const_iterator I = N->begin(), - E = N->end(); - I != E; ++I) - PrintDomTree<NodeT>(*I, O, Lev + 1); + for (const auto &I : *N) + PrintDomTree<NodeT>(I, O, Lev + 1); } namespace DomTreeBuilder { diff --git a/llvm/include/llvm/Support/GenericDomTreeConstruction.h b/llvm/include/llvm/Support/GenericDomTreeConstruction.h index a216cd2..401cc4e 100644 --- a/llvm/include/llvm/Support/GenericDomTreeConstruction.h +++ b/llvm/include/llvm/Support/GenericDomTreeConstruction.h @@ -595,9 +595,7 @@ struct SemiNCAInfo { // Attach the first unreachable block to AttachTo. NodeToInfo[NumToNode[1]].IDom = AttachTo->getBlock(); // Loop over all of the discovered blocks in the function... - for (size_t i = 1, e = NumToNode.size(); i != e; ++i) { - NodePtr W = NumToNode[i]; - + for (NodePtr W : llvm::drop_begin(NumToNode)) { // Don't replace this with 'count', the insertion side effect is important if (DT.DomTreeNodes[W]) continue; // Haven't calculated this node yet? @@ -614,8 +612,7 @@ struct SemiNCAInfo { void reattachExistingSubtree(DomTreeT &DT, const TreeNodePtr AttachTo) { NodeToInfo[NumToNode[1]].IDom = AttachTo->getBlock(); - for (size_t i = 1, e = NumToNode.size(); i != e; ++i) { - const NodePtr N = NumToNode[i]; + for (const NodePtr N : llvm::drop_begin(NumToNode)) { const TreeNodePtr TN = DT.getNode(N); assert(TN); const TreeNodePtr NewIDom = DT.getNode(NodeToInfo[N].IDom); |