Replace the BUILTIN_EXPECT macro with a less horrible LLVM_LIKELY/LLVM_UNLIKELY inter...
[oota-llvm.git] / include / llvm / Support / GetElementPtrTypeIterator.h
index 8f6c224a266408d7c4079959f41661bf9e3a5076..ef92c95ee7e0833ed814c5dfeb954f5dd3d7e102 100644 (file)
@@ -1,10 +1,10 @@
 //===- llvm/Support/GetElementPtrTypeIterator.h -----------------*- C++ -*-===//
-// 
+//
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
-// 
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
 //===----------------------------------------------------------------------===//
 //
 // This file implements an iterator for walking through the types indexed by
 namespace llvm {
   template<typename ItTy = User::const_op_iterator>
   class generic_gep_type_iterator
-    : public forward_iterator<const Type *, ptrdiff_t> {
-    typedef forward_iterator<const Type*, ptrdiff_t> super;
+    : public std::iterator<std::forward_iterator_tag, Type *, ptrdiff_t> {
+    typedef std::iterator<std::forward_iterator_tag,
+                          Type *, ptrdiff_t> super;
 
     ItTy OpIt;
-    const Type *CurTy;
+    Type *CurTy;
     generic_gep_type_iterator() {}
   public:
 
-    static generic_gep_type_iterator begin(const Type *Ty, ItTy It) {
+    static generic_gep_type_iterator begin(Type *Ty, ItTy It) {
       generic_gep_type_iterator I;
       I.CurTy = Ty;
       I.OpIt = It;
@@ -42,40 +43,40 @@ namespace llvm {
       return I;
     }
 
-    bool operator==(const generic_gep_type_iterator& x) const { 
+    bool operator==(const generic_gep_type_iterator& x) const {
       return OpIt == x.OpIt;
     }
     bool operator!=(const generic_gep_type_iterator& x) const {
       return !operator==(x);
     }
 
-    const Type *operator*() const { 
+    Type *operator*() const {
       return CurTy;
     }
 
-    const Type *getIndexedType() const {
-      const CompositeType *CT = cast<CompositeType>(CurTy);
+    Type *getIndexedType() const {
+      CompositeType *CT = cast<CompositeType>(CurTy);
       return CT->getTypeAtIndex(getOperand());
     }
 
     // This is a non-standard operator->.  It allows you to call methods on the
     // current type directly.
-    const Type *operator->() const { return operator*(); }
-    
+    Type *operator->() const { return operator*(); }
+
     Value *getOperand() const { return *OpIt; }
 
     generic_gep_type_iterator& operator++() {   // Preincrement
-      if (const CompositeType *CT = dyn_cast<CompositeType>(CurTy)) {
+      if (CompositeType *CT = dyn_cast<CompositeType>(CurTy)) {
         CurTy = CT->getTypeAtIndex(getOperand());
       } else {
         CurTy = 0;
       }
       ++OpIt;
-      return *this; 
+      return *this;
     }
 
     generic_gep_type_iterator operator++(int) { // Postincrement
-      generic_gep_type_iterator tmp = *this; ++*this; return tmp; 
+      generic_gep_type_iterator tmp = *this; ++*this; return tmp;
     }
   };
 
@@ -83,7 +84,7 @@ namespace llvm {
 
   inline gep_type_iterator gep_type_begin(const User *GEP) {
     return gep_type_iterator::begin(GEP->getOperand(0)->getType(),
-                                      GEP->op_begin()+1);
+                                    GEP->op_begin()+1);
   }
   inline gep_type_iterator gep_type_end(const User *GEP) {
     return gep_type_iterator::end(GEP->op_end());
@@ -96,16 +97,16 @@ namespace llvm {
     return gep_type_iterator::end(GEP.op_end());
   }
 
-  template<typename ItTy>
-  inline generic_gep_type_iterator<ItTy>
-  gep_type_begin(const Type *Op0, ItTy I, ItTy E) {
-    return generic_gep_type_iterator<ItTy>::begin(Op0, I);
+  template<typename T>
+  inline generic_gep_type_iterator<const T *>
+  gep_type_begin(Type *Op0, ArrayRef<T> A) {
+    return generic_gep_type_iterator<const T *>::begin(Op0, A.begin());
   }
 
-  template<typename ItTy>
-  inline generic_gep_type_iterator<ItTy>
-  gep_type_end(const Type *Op0, ItTy I, ItTy E) {
-    return generic_gep_type_iterator<ItTy>::end(E);
+  template<typename T>
+  inline generic_gep_type_iterator<const T *>
+  gep_type_end(Type *Op0, ArrayRef<T> A) {
+    return generic_gep_type_iterator<const T *>::end(A.end());
   }
 } // end namespace llvm