- template <class _Term, class _BB> // Successor Iterator
- class SuccIterator : public std::bidirectional_iterator<_BB, ptrdiff_t> {
- const _Term Term;
- unsigned idx;
- public:
- typedef SuccIterator<_Term, _BB> _Self;
- // TODO: This can be random access iterator, need operator+ and stuff tho
-
- inline SuccIterator(_Term T) : Term(T), idx(0) { // begin iterator
- assert(T && "getTerminator returned null!");
- }
- inline SuccIterator(_Term T, bool) // end iterator
- : Term(T), idx(Term->getNumSuccessors()) {
- assert(T && "getTerminator returned null!");
- }
-
- inline bool operator==(const _Self& x) const { return idx == x.idx; }
- inline bool operator!=(const _Self& x) const { return !operator==(x); }
-
- inline pointer operator*() const { return Term->getSuccessor(idx); }
- inline pointer operator->() const { return operator*(); }
-
- inline _Self& operator++() { ++idx; return *this; } // Preincrement
- inline _Self operator++(int) { // Postincrement
- _Self tmp = *this; ++*this; return tmp;
- }
-
- inline _Self& operator--() { --idx; return *this; } // Predecrement
- inline _Self operator--(int) { // Postdecrement
- _Self tmp = *this; --*this; return tmp;
- }
- };
-
- inline succ_iterator succ_begin() { return succ_iterator(getTerminator()); }
- inline succ_const_iterator succ_begin() const {
- return succ_const_iterator(getTerminator());
- }
- inline succ_iterator succ_end() {return succ_iterator(getTerminator(), true);}
- inline succ_const_iterator succ_end() const {
- return succ_const_iterator(getTerminator(), true);
- }
+private:
+ // getNext/Prev - Return the next or previous basic block in the list. Access
+ // these with Function::iterator.
+ BasicBlock *getNext() { return Next; }
+ const BasicBlock *getNext() const { return Next; }
+ BasicBlock *getPrev() { return Prev; }
+ const BasicBlock *getPrev() const { return Prev; }