[llvm] r222553 - Add and use a helper elements() to StructType. NFC.

Rafael Espindola rafael.espindola at gmail.com
Fri Nov 21 10:53:05 PST 2014


Author: rafael
Date: Fri Nov 21 12:53:05 2014
New Revision: 222553

URL: http://llvm.org/viewvc/llvm-project?rev=222553&view=rev
Log:
Add and use a helper elements() to StructType. NFC.

Modified:
    llvm/trunk/include/llvm/IR/DerivedTypes.h
    llvm/trunk/lib/IR/LLVMContextImpl.h

Modified: llvm/trunk/include/llvm/IR/DerivedTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DerivedTypes.h?rev=222553&r1=222552&r2=222553&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DerivedTypes.h (original)
+++ llvm/trunk/include/llvm/IR/DerivedTypes.h Fri Nov 21 12:53:05 2014
@@ -275,6 +275,10 @@ public:
   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;  

Modified: llvm/trunk/lib/IR/LLVMContextImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContextImpl.h?rev=222553&r1=222552&r2=222553&view=diff
==============================================================================
--- llvm/trunk/lib/IR/LLVMContextImpl.h (original)
+++ llvm/trunk/lib/IR/LLVMContextImpl.h Fri Nov 21 12:53:05 2014
@@ -104,9 +104,8 @@ struct AnonStructTypeKeyInfo {
     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;





More information about the llvm-commits mailing list