[llvm] c19028f - [GenericDomTree] Use range-based for loops (NFC) (#96404)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 23 08:29:49 PDT 2024
Author: Kazu Hirata
Date: 2024-06-23T08:29:46-07:00
New Revision: c19028f364cceb4b2111c7956dcacbc257a96fd4
URL: https://github.com/llvm/llvm-project/commit/c19028f364cceb4b2111c7956dcacbc257a96fd4
DIFF: https://github.com/llvm/llvm-project/commit/c19028f364cceb4b2111c7956dcacbc257a96fd4.diff
LOG: [GenericDomTree] Use range-based for loops (NFC) (#96404)
Added:
Modified:
llvm/include/llvm/Support/GenericDomTree.h
llvm/include/llvm/Support/GenericDomTreeConstruction.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/GenericDomTree.h b/llvm/include/llvm/Support/GenericDomTree.h
index 4fce9d8bfb2b6..a8e178d6461e0 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 a216cd2a03596..401cc4eb0ec1b 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);
More information about the llvm-commits
mailing list