Expose API to graph library to allow iteration over all nodes, even unreachable ones
authorChris Lattner <sabre@nondot.org>
Thu, 10 Oct 2002 22:31:31 +0000 (22:31 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 10 Oct 2002 22:31:31 +0000 (22:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4111 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/CFG.h

index 8b68627201dac8c963f9285063dd4010766b4e45..48918e0609976b61d2426e86c96aad5fda996159 100644 (file)
@@ -10,7 +10,6 @@
 
 #include "Support/GraphTraits.h"
 #include "llvm/Function.h"
-#include "llvm/BasicBlock.h"
 #include "llvm/InstrTypes.h"
 #include "Support/iterator"
 
@@ -220,10 +219,20 @@ template <> struct GraphTraits<Inverse<const BasicBlock*> > {
 //
 template <> struct GraphTraits<Function*> : public GraphTraits<BasicBlock*> {
   static NodeType *getEntryNode(Function *F) { return &F->getEntryNode(); }
+
+  // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
+  typedef Function::iterator nodes_iterator;
+  static nodes_iterator nodes_begin(Function *F) { return F->begin(); }
+  static nodes_iterator nodes_end  (Function *F) { return F->end(); }
 };
 template <> struct GraphTraits<const Function*> :
   public GraphTraits<const BasicBlock*> {
   static NodeType *getEntryNode(const Function *F) { return &F->getEntryNode();}
+
+  // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
+  typedef Function::const_iterator nodes_iterator;
+  static nodes_iterator nodes_begin(const Function *F) { return F->begin(); }
+  static nodes_iterator nodes_end  (const Function *F) { return F->end(); }
 };