eliminate all 80-col violations that I have introduced in my recent checkins (and...
[oota-llvm.git] / include / llvm / Support / GetElementPtrTypeIterator.h
index 068ec45dc5a2f97abdc1863350475f62f8b97a27..f5915c992cdbb50bc408647dd8f5f304dac0c5f5 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
 #include "llvm/DerivedTypes.h"
 
 namespace llvm {
-  template<typename ItTy = User::op_iterator>
+  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, const Type *, ptrdiff_t> {
+    typedef std::iterator<std::forward_iterator_tag,
+                          const Type *, ptrdiff_t> super;
 
     ItTy OpIt;
     const Type *CurTy;
@@ -42,21 +43,26 @@ 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 { 
+    const Type *operator*() const {
       return CurTy;
     }
 
+    const Type *getIndexedType() const {
+      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*(); }
-    
+
     Value *getOperand() const { return *OpIt; }
 
     generic_gep_type_iterator& operator++() {   // Preincrement
@@ -66,28 +72,28 @@ namespace llvm {
         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;
     }
   };
 
   typedef generic_gep_type_iterator<> gep_type_iterator;
 
-  inline gep_type_iterator gep_type_begin(User *GEP) {
+  inline gep_type_iterator gep_type_begin(const User *GEP) {
     return gep_type_iterator::begin(GEP->getOperand(0)->getType(),
                                       GEP->op_begin()+1);
   }
-  inline gep_type_iterator gep_type_end(User *GEP) {
+  inline gep_type_iterator gep_type_end(const User *GEP) {
     return gep_type_iterator::end(GEP->op_end());
   }
-  inline gep_type_iterator gep_type_begin(User &GEP) {
+  inline gep_type_iterator gep_type_begin(const User &GEP) {
     return gep_type_iterator::begin(GEP.getOperand(0)->getType(),
                                     GEP.op_begin()+1);
   }
-  inline gep_type_iterator gep_type_end(User &GEP) {
+  inline gep_type_iterator gep_type_end(const User &GEP) {
     return gep_type_iterator::end(GEP.op_end());
   }