From f77b57097d00b301c164e10a034860fdbbcbe932 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 10 Oct 2002 22:31:31 +0000 Subject: [PATCH] Expose API to graph library to allow iteration over all nodes, even unreachable ones git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4111 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/CFG.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/llvm/Support/CFG.h b/include/llvm/Support/CFG.h index 8b68627201d..48918e06099 100644 --- a/include/llvm/Support/CFG.h +++ b/include/llvm/Support/CFG.h @@ -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 > { // template <> struct GraphTraits : public GraphTraits { 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 : public GraphTraits { 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(); } };