From 633e9689bfade2b027561f29546379653111ca9e Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 21 Nov 2014 18:53:05 +0000 Subject: [PATCH] Add and use a helper elements() to StructType. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222553 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/DerivedTypes.h | 4 ++++ lib/IR/LLVMContextImpl.h | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) 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; -- 2.34.1