For PR351: \
[oota-llvm.git] / include / llvm / Support / CFG.h
index 9355139f34ae81ff13cf39f8f9987235d293c06f..badb846bac3dbb4da72fba1cbd269f4626e59d35 100644 (file)
 #ifndef LLVM_SUPPORT_CFG_H
 #define LLVM_SUPPORT_CFG_H
 
-#include "Support/GraphTraits.h"
+#include "llvm/ADT/GraphTraits.h"
 #include "llvm/Function.h"
 #include "llvm/InstrTypes.h"
-#include "Support/iterator"
+#include "llvm/ADT/iterator"
+
+namespace llvm {
 
 //===--------------------------------------------------------------------===//
 // BasicBlock pred_iterator definition
@@ -88,20 +90,20 @@ inline pred_const_iterator pred_end(const BasicBlock *BB) {
 // BasicBlock succ_iterator definition
 //===--------------------------------------------------------------------===//
 
-template <class _Term, class _BB>           // Successor Iterator
-class SuccIterator : public bidirectional_iterator<_BB, ptrdiff_t> {
-  const _Term Term;
+template <class Term_, class BB_>           // Successor Iterator
+class SuccIterator : public bidirectional_iterator<BB_, ptrdiff_t> {
+  const Term_ Term;
   unsigned idx;
-  typedef bidirectional_iterator<_BB, ptrdiff_t> super;
+  typedef bidirectional_iterator<BB_, ptrdiff_t> super;
 public:
-  typedef SuccIterator<_Term, _BB> _Self;
+  typedef SuccIterator<Term_, BB_> _Self;
   typedef typename super::pointer pointer;
   // TODO: This can be random access iterator, need operator+ and stuff tho
     
-  inline SuccIterator(_Term T) : Term(T), idx(0) {         // begin iterator
+  inline SuccIterator(Term_ T) : Term(T), idx(0) {         // begin iterator
     assert(T && "getTerminator returned null!");
   }
-  inline SuccIterator(_Term T, bool)                       // end iterator
+  inline SuccIterator(Term_ T, bool)                       // end iterator
     : Term(T), idx(Term->getNumSuccessors()) {
     assert(T && "getTerminator returned null!");
   }
@@ -111,6 +113,10 @@ public:
     idx = I.idx;
     return *this;
   }
+
+  /// getSuccessorIndex - This is used to interface between code that wants to
+  /// operate on terminator instructions directly.
+  unsigned getSuccessorIndex() const { return idx; }
     
   inline bool operator==(const _Self& x) const { return idx == x.idx; }
   inline bool operator!=(const _Self& x) const { return !operator==(x); }
@@ -260,4 +266,6 @@ template <> struct GraphTraits<Inverse<const Function*> > :
   }
 };
 
+} // End llvm namespace
+
 #endif