From e187d565207682978185624e8fcd8f2c9f31d290 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 7 Feb 2004 23:57:09 +0000 Subject: [PATCH] Abstract out the Nodes collection. Instead of providing a getNodes() method, provide node_begin/end iterators, which are only guaranteed to be bidirectional, not random access. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11165 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/DSGraph.h | 8 +++++--- include/llvm/Analysis/DSGraphTraits.h | 14 ++++++-------- include/llvm/Analysis/DataStructure/DSGraph.h | 8 +++++--- .../llvm/Analysis/DataStructure/DSGraphTraits.h | 14 ++++++-------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/llvm/Analysis/DSGraph.h b/include/llvm/Analysis/DSGraph.h index a86f5218eb1..7e19212abef 100644 --- a/include/llvm/Analysis/DSGraph.h +++ b/include/llvm/Analysis/DSGraph.h @@ -92,6 +92,7 @@ struct DSGraph { typedef DSScalarMap ScalarMapTy; typedef hash_map ReturnNodesTy; typedef hash_set GlobalSetTy; + typedef std::vector NodeListTy; /// NodeMapTy - This data type is used when cloning one graph into another to /// keep track of the correspondence between the nodes in the old and new @@ -101,7 +102,7 @@ private: DSGraph *GlobalsGraph; // Pointer to the common graph of global objects bool PrintAuxCalls; // Should this graph print the Aux calls vector? - std::vector Nodes; + NodeListTy Nodes; ScalarMapTy ScalarMap; // ReturnNodes - A return value for every function merged into this graph. @@ -170,8 +171,9 @@ public: /// getNodes - Get a vector of all the nodes in the graph /// - const std::vector &getNodes() const { return Nodes; } - std::vector &getNodes() { return Nodes; } + typedef NodeListTy::const_iterator node_iterator; + node_iterator node_begin() const { return Nodes.begin(); } + node_iterator node_end() const { return Nodes.end(); } /// getFunctionNames - Return a space separated list of the name of the /// functions in this graph (if any) diff --git a/include/llvm/Analysis/DSGraphTraits.h b/include/llvm/Analysis/DSGraphTraits.h index ad2cc6fa8f4..72541b8cd1f 100644 --- a/include/llvm/Analysis/DSGraphTraits.h +++ b/include/llvm/Analysis/DSGraphTraits.h @@ -115,13 +115,12 @@ template <> struct GraphTraits { typedef std::pointer_to_unary_function DerefFun; // nodes_iterator/begin/end - Allow iteration over all nodes in the graph - typedef mapped_iterator::iterator, - DerefFun> nodes_iterator; + typedef mapped_iterator nodes_iterator; static nodes_iterator nodes_begin(DSGraph *G) { - return map_iterator(G->getNodes().begin(), DerefFun(dereference)); + return map_iterator(G->node_begin(), DerefFun(dereference)); } static nodes_iterator nodes_end(DSGraph *G) { - return map_iterator(G->getNodes().end(), DerefFun(dereference)); + return map_iterator(G->node_end(), DerefFun(dereference)); } static ChildIteratorType child_begin(NodeType *N) { return N->begin(); } @@ -135,13 +134,12 @@ template <> struct GraphTraits { typedef std::pointer_to_unary_function DerefFun; // nodes_iterator/begin/end - Allow iteration over all nodes in the graph - typedef mapped_iterator::const_iterator, - DerefFun> nodes_iterator; + typedef mapped_iterator nodes_iterator; static nodes_iterator nodes_begin(const DSGraph *G) { - return map_iterator(G->getNodes().begin(), DerefFun(dereferenceC)); + return map_iterator(G->node_begin(), DerefFun(dereferenceC)); } static nodes_iterator nodes_end(const DSGraph *G) { - return map_iterator(G->getNodes().end(), DerefFun(dereferenceC)); + return map_iterator(G->node_end(), DerefFun(dereferenceC)); } static ChildIteratorType child_begin(const NodeType *N) { return N->begin(); } diff --git a/include/llvm/Analysis/DataStructure/DSGraph.h b/include/llvm/Analysis/DataStructure/DSGraph.h index a86f5218eb1..7e19212abef 100644 --- a/include/llvm/Analysis/DataStructure/DSGraph.h +++ b/include/llvm/Analysis/DataStructure/DSGraph.h @@ -92,6 +92,7 @@ struct DSGraph { typedef DSScalarMap ScalarMapTy; typedef hash_map ReturnNodesTy; typedef hash_set GlobalSetTy; + typedef std::vector NodeListTy; /// NodeMapTy - This data type is used when cloning one graph into another to /// keep track of the correspondence between the nodes in the old and new @@ -101,7 +102,7 @@ private: DSGraph *GlobalsGraph; // Pointer to the common graph of global objects bool PrintAuxCalls; // Should this graph print the Aux calls vector? - std::vector Nodes; + NodeListTy Nodes; ScalarMapTy ScalarMap; // ReturnNodes - A return value for every function merged into this graph. @@ -170,8 +171,9 @@ public: /// getNodes - Get a vector of all the nodes in the graph /// - const std::vector &getNodes() const { return Nodes; } - std::vector &getNodes() { return Nodes; } + typedef NodeListTy::const_iterator node_iterator; + node_iterator node_begin() const { return Nodes.begin(); } + node_iterator node_end() const { return Nodes.end(); } /// getFunctionNames - Return a space separated list of the name of the /// functions in this graph (if any) diff --git a/include/llvm/Analysis/DataStructure/DSGraphTraits.h b/include/llvm/Analysis/DataStructure/DSGraphTraits.h index ad2cc6fa8f4..72541b8cd1f 100644 --- a/include/llvm/Analysis/DataStructure/DSGraphTraits.h +++ b/include/llvm/Analysis/DataStructure/DSGraphTraits.h @@ -115,13 +115,12 @@ template <> struct GraphTraits { typedef std::pointer_to_unary_function DerefFun; // nodes_iterator/begin/end - Allow iteration over all nodes in the graph - typedef mapped_iterator::iterator, - DerefFun> nodes_iterator; + typedef mapped_iterator nodes_iterator; static nodes_iterator nodes_begin(DSGraph *G) { - return map_iterator(G->getNodes().begin(), DerefFun(dereference)); + return map_iterator(G->node_begin(), DerefFun(dereference)); } static nodes_iterator nodes_end(DSGraph *G) { - return map_iterator(G->getNodes().end(), DerefFun(dereference)); + return map_iterator(G->node_end(), DerefFun(dereference)); } static ChildIteratorType child_begin(NodeType *N) { return N->begin(); } @@ -135,13 +134,12 @@ template <> struct GraphTraits { typedef std::pointer_to_unary_function DerefFun; // nodes_iterator/begin/end - Allow iteration over all nodes in the graph - typedef mapped_iterator::const_iterator, - DerefFun> nodes_iterator; + typedef mapped_iterator nodes_iterator; static nodes_iterator nodes_begin(const DSGraph *G) { - return map_iterator(G->getNodes().begin(), DerefFun(dereferenceC)); + return map_iterator(G->node_begin(), DerefFun(dereferenceC)); } static nodes_iterator nodes_end(const DSGraph *G) { - return map_iterator(G->getNodes().end(), DerefFun(dereferenceC)); + return map_iterator(G->node_end(), DerefFun(dereferenceC)); } static ChildIteratorType child_begin(const NodeType *N) { return N->begin(); }