Add and use a helper elements() to StructType. NFC.
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 21 Nov 2014 18:53:05 +0000 (18:53 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 21 Nov 2014 18:53:05 +0000 (18:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222553 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/DerivedTypes.h
lib/IR/LLVMContextImpl.h

index 534d1e54160c60ff3212b1e3c16815264312bad3..175d45afdfcefac0075ee7ff01986ab9b9ab56cf 100644 (file)
@@ -275,6 +275,10 @@ public:
   element_iterator element_begin() const { return ContainedTys; }
   element_iterator element_end() const { return &ContainedTys[NumContainedTys];}
 
   element_iterator element_begin() const { return ContainedTys; }
   element_iterator element_end() const { return &ContainedTys[NumContainedTys];}
 
+  ArrayRef<Type *> const elements() const {
+    return ArrayRef<Type*>(&*element_begin(), getNumElements());
+  }
+
   /// isLayoutIdentical - Return true if this is layout identical to the
   /// specified struct.
   bool isLayoutIdentical(StructType *Other) const;  
   /// isLayoutIdentical - Return true if this is layout identical to the
   /// specified struct.
   bool isLayoutIdentical(StructType *Other) const;  
index e743ec3abc45ca22b7d9b4ad9cdd30269f09e707..f018dc737508a134120d9585b3c8608338fe5d9e 100644 (file)
@@ -104,9 +104,8 @@ struct AnonStructTypeKeyInfo {
     bool isPacked;
     KeyTy(const ArrayRef<Type*>& E, bool P) :
       ETypes(E), isPacked(P) {}
     bool isPacked;
     KeyTy(const ArrayRef<Type*>& E, bool P) :
       ETypes(E), isPacked(P) {}
-    KeyTy(const StructType* ST) :
-      ETypes(ArrayRef<Type*>(ST->element_begin(), ST->element_end())),
-      isPacked(ST->isPacked()) {}
+    KeyTy(const StructType *ST)
+        : ETypes(ST->elements()), isPacked(ST->isPacked()) {}
     bool operator==(const KeyTy& that) const {
       if (isPacked != that.isPacked)
         return false;
     bool operator==(const KeyTy& that) const {
       if (isPacked != that.isPacked)
         return false;