From 4a20c7a0a9ffa2b60668b1b8c39e550531dbcbb1 Mon Sep 17 00:00:00 2001 From: Duncan Sands Date: Tue, 17 Nov 2009 10:54:25 +0000 Subject: [PATCH] 1. Allow SCCIterator to work with GraphT types that are constant. 2. Allow SCCIterator to work with inverse graphs. 3. Fix an incorrect comment in GraphTraits.h (the type in the comment was given as GraphType* when it is actually const GraphType &). Patch by Patrick Alexander Simmons. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89091 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/GraphTraits.h | 2 +- include/llvm/ADT/SCCIterator.h | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/include/llvm/ADT/GraphTraits.h b/include/llvm/ADT/GraphTraits.h index 2d103cf83eb..0fd1f5022af 100644 --- a/include/llvm/ADT/GraphTraits.h +++ b/include/llvm/ADT/GraphTraits.h @@ -30,7 +30,7 @@ struct GraphTraits { // typedef NodeType - Type of Node in the graph // typedef ChildIteratorType - Type used to iterate over children in graph - // static NodeType *getEntryNode(GraphType *) + // static NodeType *getEntryNode(const GraphType &) // Return the entry node of the graph // static ChildIteratorType child_begin(NodeType *) diff --git a/include/llvm/ADT/SCCIterator.h b/include/llvm/ADT/SCCIterator.h index db985b5ae1d..3afcabd8375 100644 --- a/include/llvm/ADT/SCCIterator.h +++ b/include/llvm/ADT/SCCIterator.h @@ -136,8 +136,8 @@ public: typedef scc_iterator _Self; // Provide static "constructors"... - static inline _Self begin(GraphT& G) { return _Self(GT::getEntryNode(G)); } - static inline _Self end (GraphT& G) { return _Self(); } + static inline _Self begin(const GraphT& G) { return _Self(GT::getEntryNode(G)); } + static inline _Self end (const GraphT& G) { return _Self(); } // Direct loop termination test (I.fini() is more efficient than I == end()) inline bool fini() const { @@ -186,15 +186,25 @@ public: // Global constructor for the SCC iterator. template -scc_iterator scc_begin(T G) { +scc_iterator scc_begin(const T& G) { return scc_iterator::begin(G); } template -scc_iterator scc_end(T G) { +scc_iterator scc_end(const T& G) { return scc_iterator::end(G); } +template +scc_iterator > scc_begin(const Inverse& G) { + return scc_iterator >::begin(G); +} + +template +scc_iterator > scc_end(const Inverse& G) { + return scc_iterator >::end(G); +} + } // End llvm namespace #endif