diff --git a/include/llvm/IR/DerivedTypes.h b/include/llvm/IR/DerivedTypes.h index 534d1e54160..175d45afdfc 100644 --- a/include/llvm/IR/DerivedTypes.h +++ b/include/llvm/IR/DerivedTypes.h @@ -275,6 +275,10 @@ public: element_iterator element_begin() const { return ContainedTys; } element_iterator element_end() const { return &ContainedTys[NumContainedTys];} + ArrayRef const elements() const { + return ArrayRef(&*element_begin(), getNumElements()); + } + /// isLayoutIdentical - Return true if this is layout identical to the /// specified struct. bool isLayoutIdentical(StructType *Other) const; diff --git a/lib/IR/LLVMContextImpl.h b/lib/IR/LLVMContextImpl.h index e743ec3abc4..f018dc73750 100644 --- a/lib/IR/LLVMContextImpl.h +++ b/lib/IR/LLVMContextImpl.h @@ -104,9 +104,8 @@ struct AnonStructTypeKeyInfo { bool isPacked; KeyTy(const ArrayRef& E, bool P) : ETypes(E), isPacked(P) {} - KeyTy(const StructType* ST) : - ETypes(ArrayRef(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;