Add params() to FunctionType. NFC.
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 21 Nov 2014 19:03:35 +0000 (19:03 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 21 Nov 2014 19:03:35 +0000 (19:03 +0000)
While at it, also use makeArrayRef in elements().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222556 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 175d45afdfcefac0075ee7ff01986ab9b9ab56cf..182015c98aa24525b6a94df2ee5de55f7e7ade3d 100644 (file)
@@ -123,6 +123,9 @@ public:
   typedef Type::subtype_iterator param_iterator;
   param_iterator param_begin() const { return ContainedTys + 1; }
   param_iterator param_end() const { return &ContainedTys[NumContainedTys]; }
   typedef Type::subtype_iterator param_iterator;
   param_iterator param_begin() const { return ContainedTys + 1; }
   param_iterator param_end() const { return &ContainedTys[NumContainedTys]; }
+  ArrayRef<Type *> params() const {
+    return makeArrayRef(param_begin(), param_end());
+  }
 
   /// Parameter type accessors.
   Type *getParamType(unsigned i) const { return ContainedTys[i+1]; }
 
   /// Parameter type accessors.
   Type *getParamType(unsigned i) const { return ContainedTys[i+1]; }
@@ -274,9 +277,8 @@ public:
   typedef Type::subtype_iterator element_iterator;
   element_iterator element_begin() const { return ContainedTys; }
   element_iterator element_end() const { return &ContainedTys[NumContainedTys];}
   typedef Type::subtype_iterator element_iterator;
   element_iterator element_begin() const { return ContainedTys; }
   element_iterator element_end() const { return &ContainedTys[NumContainedTys];}
-
   ArrayRef<Type *> const elements() const {
   ArrayRef<Type *> const elements() const {
-    return ArrayRef<Type*>(&*element_begin(), getNumElements());
+    return makeArrayRef(element_begin(), element_end());
   }
 
   /// isLayoutIdentical - Return true if this is layout identical to the
   }
 
   /// isLayoutIdentical - Return true if this is layout identical to the
index f018dc737508a134120d9585b3c8608338fe5d9e..7a298cfecf31cf27e19253bf755adcf4805cf3bb 100644 (file)
@@ -148,10 +148,9 @@ struct FunctionTypeKeyInfo {
     bool isVarArg;
     KeyTy(const Type* R, const ArrayRef<Type*>& P, bool V) :
       ReturnType(R), Params(P), isVarArg(V) {}
     bool isVarArg;
     KeyTy(const Type* R, const ArrayRef<Type*>& P, bool V) :
       ReturnType(R), Params(P), isVarArg(V) {}
-    KeyTy(const FunctionType* FT) :
-      ReturnType(FT->getReturnType()),
-      Params(makeArrayRef(FT->param_begin(), FT->param_end())),
-      isVarArg(FT->isVarArg()) {}
+    KeyTy(const FunctionType *FT)
+        : ReturnType(FT->getReturnType()), Params(FT->params()),
+          isVarArg(FT->isVarArg()) {}
     bool operator==(const KeyTy& that) const {
       if (ReturnType != that.ReturnType)
         return false;
     bool operator==(const KeyTy& that) const {
       if (ReturnType != that.ReturnType)
         return false;