From 798ac6c06b79c2ced35127d7fe6a8469c2b23897 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. llvm-svn: 222553 --- 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;