[PATCH] D42698: [GraphTraits] Add support for iterating over children edges.

Easwaran Raman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 1 10:56:00 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL323990: [GraphTraits] Add support for iterating over children edges. (authored by eraman, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D42698

Files:
  llvm/trunk/include/llvm/ADT/GraphTraits.h


Index: llvm/trunk/include/llvm/ADT/GraphTraits.h
===================================================================
--- llvm/trunk/include/llvm/ADT/GraphTraits.h
+++ llvm/trunk/include/llvm/ADT/GraphTraits.h
@@ -47,6 +47,19 @@
   // static nodes_iterator nodes_end  (GraphType *G)
   //    nodes_iterator/begin/end - Allow iteration over all nodes in the graph
 
+  // typedef EdgeRef           - Type of Edge token in the graph, which should
+  //                             be cheap to copy.
+  // typedef ChildEdgeIteratorType - Type used to iterate over children edges in
+  //                             graph, dereference to a EdgeRef.
+
+  // static ChildEdgeIteratorType child_edge_begin(NodeRef)
+  // static ChildEdgeIteratorType child_edge_end(NodeRef)
+  //     Return iterators that point to the beginning and ending of the
+  //     edge list for the given callgraph node.
+  //
+  // static NodeRef edge_dest(EdgeRef)
+  //     Return the destination node of an edge.
+
   // static unsigned       size       (GraphType *G)
   //    Return total number of nodes in the graph
 
@@ -111,6 +124,13 @@
                     GraphTraits<Inverse<GraphType>>::child_end(G));
 }
 
+template <class GraphType>
+iterator_range<typename GraphTraits<GraphType>::ChildEdgeIteratorType>
+children_edges(const typename GraphTraits<GraphType>::NodeRef &G) {
+  return make_range(GraphTraits<GraphType>::child_edge_begin(G),
+                    GraphTraits<GraphType>::child_edge_end(G));
+}
+
 } // end namespace llvm
 
 #endif // LLVM_ADT_GRAPHTRAITS_H


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42698.132428.patch
Type: text/x-patch
Size: 1556 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180201/d33ded3a/attachment.bin>


More information about the llvm-commits mailing list