SCC: Remove non-const operator*()
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 25 Apr 2014 18:26:45 +0000 (18:26 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 25 Apr 2014 18:26:45 +0000 (18:26 +0000)
<rdar://problem/14292693>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207254 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/SCCIterator.h

index 86bef96168d58476eb1d0b2761136ee09b2f0ce3..4732ef5e91fd017092f7e1881f2e1fab981cf9b0 100644 (file)
@@ -35,15 +35,17 @@ namespace llvm {
 /// This is implemented using Tarjan's DFS algorithm using an internal stack to
 /// build up a vector of nodes in a particular SCC. Note that it is a forward
 /// iterator and thus you cannot backtrack or re-visit nodes.
-template <class GraphT, class GT = GraphTraits<GraphT> >
+template <class GraphT, class GT = GraphTraits<GraphT>>
 class scc_iterator
     : public std::iterator<std::forward_iterator_tag,
-                           std::vector<typename GT::NodeType>, ptrdiff_t> {
+                           const std::vector<typename GT::NodeType>,
+                           ptrdiff_t> {
   typedef typename GT::NodeType NodeType;
   typedef typename GT::ChildIteratorType ChildItTy;
   typedef std::vector<NodeType *> SccTy;
   typedef std::iterator<std::forward_iterator_tag,
-                        std::vector<typename GT::NodeType>, ptrdiff_t> super;
+                        const std::vector<typename GT::NodeType>,
+                        ptrdiff_t> super;
   typedef typename super::reference reference;
   typedef typename super::pointer pointer;
 
@@ -129,10 +131,6 @@ public:
     assert(!CurrentSCC.empty() && "Dereferencing END SCC iterator!");
     return CurrentSCC;
   }
-  SccTy &operator*() {
-    assert(!CurrentSCC.empty() && "Dereferencing END SCC iterator!");
-    return CurrentSCC;
-  }
 
   /// \brief Test if the current SCC has a loop.
   ///