From e30f330393848f141d0399610e2ae1231a85f971 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Wed, 6 Apr 2011 20:28:34 +0000 Subject: [PATCH] Replace const std::vector& with ArrayRef in the type creation APIs. llvm-svn: 129024 --- llvm/include/llvm/DerivedTypes.h | 10 +++++----- llvm/lib/VMCore/Type.cpp | 9 +++++---- llvm/lib/VMCore/TypesContext.h | 9 +++++---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/llvm/include/llvm/DerivedTypes.h b/llvm/include/llvm/DerivedTypes.h index 56d1e3e237d6..cef7ec192d45 100644 --- a/llvm/include/llvm/DerivedTypes.h +++ b/llvm/include/llvm/DerivedTypes.h @@ -19,6 +19,7 @@ #define LLVM_DERIVED_TYPES_H #include "llvm/Type.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/Support/DataTypes.h" namespace llvm { @@ -147,7 +148,7 @@ class FunctionType : public DerivedType { FunctionType(const FunctionType &); // Do not implement const FunctionType &operator=(const FunctionType &); // Do not implement - FunctionType(const Type *Result, const std::vector &Params, + FunctionType(const Type *Result, ArrayRef Params, bool IsVarArgs); public: @@ -156,7 +157,7 @@ public: /// static FunctionType *get( const Type *Result, ///< The result type - const std::vector &Params, ///< The types of the parameters + ArrayRef Params, ///< The types of the parameters bool isVarArg ///< Whether this is a variable argument length function ); @@ -237,14 +238,13 @@ class StructType : public CompositeType { friend class TypeMap; StructType(const StructType &); // Do not implement const StructType &operator=(const StructType &); // Do not implement - StructType(LLVMContext &C, - const std::vector &Types, bool isPacked); + StructType(LLVMContext &C, ArrayRef Types, bool isPacked); public: /// StructType::get - This static method is the primary way to create a /// StructType. /// static StructType *get(LLVMContext &Context, - const std::vector &Params, + ArrayRef Params, bool isPacked=false); /// StructType::get - Create an empty structure type. diff --git a/llvm/lib/VMCore/Type.cpp b/llvm/lib/VMCore/Type.cpp index be28ad1f7122..b15304cc9593 100644 --- a/llvm/lib/VMCore/Type.cpp +++ b/llvm/lib/VMCore/Type.cpp @@ -17,6 +17,7 @@ #include "llvm/Assembly/Writer.h" #include "llvm/LLVMContext.h" #include "llvm/Metadata.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/SCCIterator.h" @@ -460,7 +461,7 @@ bool FunctionType::isValidArgumentType(const Type *ArgTy) { } FunctionType::FunctionType(const Type *Result, - const std::vector &Params, + ArrayRef Params, bool IsVarArgs) : DerivedType(Result->getContext(), FunctionTyID), isVarArgs(IsVarArgs) { ContainedTys = reinterpret_cast(this+1); @@ -483,7 +484,7 @@ FunctionType::FunctionType(const Type *Result, } StructType::StructType(LLVMContext &C, - const std::vector &Types, bool isPacked) + ArrayRef Types, bool isPacked) : CompositeType(C, StructTyID) { ContainedTys = reinterpret_cast(this + 1); NumContainedTys = Types.size(); @@ -838,7 +839,7 @@ FunctionValType FunctionValType::get(const FunctionType *FT) { // FunctionType::get - The factory function for the FunctionType class... FunctionType *FunctionType::get(const Type *ReturnType, - const std::vector &Params, + ArrayRef Params, bool isVarArg) { FunctionValType VT(ReturnType, Params, isVarArg); FunctionType *FT = 0; @@ -915,7 +916,7 @@ bool VectorType::isValidElementType(const Type *ElemTy) { // StructType *StructType::get(LLVMContext &Context, - const std::vector &ETypes, + ArrayRef ETypes, bool isPacked) { StructValType STV(ETypes, isPacked); StructType *ST = 0; diff --git a/llvm/lib/VMCore/TypesContext.h b/llvm/lib/VMCore/TypesContext.h index 4694486c41b6..6fb53be95996 100644 --- a/llvm/lib/VMCore/TypesContext.h +++ b/llvm/lib/VMCore/TypesContext.h @@ -15,6 +15,7 @@ #ifndef LLVM_TYPESCONTEXT_H #define LLVM_TYPESCONTEXT_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLExtras.h" #include @@ -157,8 +158,8 @@ class StructValType { std::vector ElTypes; bool packed; public: - StructValType(const std::vector &args, bool isPacked) - : ElTypes(args), packed(isPacked) {} + StructValType(ArrayRef args, bool isPacked) + : ElTypes(args.vec()), packed(isPacked) {} static StructValType get(const StructType *ST) { std::vector ElTypes; @@ -187,8 +188,8 @@ class FunctionValType { std::vector ArgTypes; bool isVarArg; public: - FunctionValType(const Type *ret, const std::vector &args, - bool isVA) : RetTy(ret), ArgTypes(args), isVarArg(isVA) {} + FunctionValType(const Type *ret, ArrayRef args, bool isVA) + : RetTy(ret), ArgTypes(args.vec()), isVarArg(isVA) {} static FunctionValType get(const FunctionType *FT);