Remove references to `bugpoint' from the now-generic system utilities.
[oota-llvm.git] / include / Support / ilist
index 09c951c2572d57e9818cd5d4f47595815a898347..afd858d5590af09a30fb94289e9a1130033d6f52 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef INCLUDED_SUPPORT_ILIST
-#define INCLUDED_SUPPORT_ILIST
+#ifndef SUPPORT_ILIST
+#define SUPPORT_ILIST
 
-#include <assert.h>
-#include <iterator>
 #include <algorithm>
+#include <Support/iterator>
 
 template<typename NodeTy, typename Traits> class iplist;
 template<typename NodeTy> class ilist_iterator;
@@ -71,22 +70,20 @@ struct ilist_traits<const Ty> : public ilist_traits<Ty> {};
 //
 template<typename NodeTy>
 class ilist_iterator
-#if __GNUC__ == 3
-  : public std::iterator<std::bidirectional_iterator_tag, NodeTy> {
-  typedef std::iterator<std::bidirectional_iterator_tag, NodeTy> super;
-#else
-  : public std::bidirectional_iterator<NodeTy, ptrdiff_t> {
-  typedef std::bidirectional_iterator<NodeTy, ptrdiff_t> super;
-#endif
+  : public bidirectional_iterator<NodeTy, ptrdiff_t> {
   typedef ilist_traits<NodeTy> Traits;
+  typedef bidirectional_iterator<NodeTy, ptrdiff_t> super;
 
+public:
+  typedef size_t size_type;
   typedef typename super::pointer pointer;
   typedef typename super::reference reference;
+private:
   pointer NodePtr;
 public:
-  typedef size_t size_type;
 
   ilist_iterator(pointer NP) : NodePtr(NP) {}
+  ilist_iterator(reference NR) : NodePtr(&NR) {}
   ilist_iterator() : NodePtr(0) {}
 
   // This is templated so that we can allow constructing a const iterator from
@@ -155,6 +152,26 @@ public:
   pointer getNodePtrUnchecked() const { return NodePtr; }
 };
 
+// Allow ilist_iterators to convert into pointers to a node automatically when
+// used by the dyn_cast, cast, isa mechanisms...
+
+template<typename From> struct simplify_type;
+
+template<typename NodeTy> struct simplify_type<ilist_iterator<NodeTy> > {
+  typedef NodeTy* SimpleType;
+  
+  static SimpleType getSimplifiedValue(const ilist_iterator<NodeTy> &Node) {
+    return &*Node;
+  }
+};
+template<typename NodeTy> struct simplify_type<const ilist_iterator<NodeTy> > {
+  typedef NodeTy* SimpleType;
+  
+  static SimpleType getSimplifiedValue(const ilist_iterator<NodeTy> &Node) {
+    return &*Node;
+  }
+};
+
 
 //===----------------------------------------------------------------------===//
 //