Replace const std::vector& with ArrayRef in the type creation APIs.

llvm-svn: 129024
This commit is contained in:
Nick Lewycky 2011-04-06 20:28:34 +00:00
parent 6895b87dfe
commit e30f330393
3 changed files with 15 additions and 13 deletions

View File

@ -19,6 +19,7 @@
#define LLVM_DERIVED_TYPES_H #define LLVM_DERIVED_TYPES_H
#include "llvm/Type.h" #include "llvm/Type.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Support/DataTypes.h" #include "llvm/Support/DataTypes.h"
namespace llvm { namespace llvm {
@ -147,7 +148,7 @@ class FunctionType : public DerivedType {
FunctionType(const FunctionType &); // Do not implement FunctionType(const FunctionType &); // Do not implement
const FunctionType &operator=(const FunctionType &); // Do not implement const FunctionType &operator=(const FunctionType &); // Do not implement
FunctionType(const Type *Result, const std::vector<const Type*> &Params, FunctionType(const Type *Result, ArrayRef<const Type*> Params,
bool IsVarArgs); bool IsVarArgs);
public: public:
@ -156,7 +157,7 @@ public:
/// ///
static FunctionType *get( static FunctionType *get(
const Type *Result, ///< The result type const Type *Result, ///< The result type
const std::vector<const Type*> &Params, ///< The types of the parameters ArrayRef<const Type*> Params, ///< The types of the parameters
bool isVarArg ///< Whether this is a variable argument length function bool isVarArg ///< Whether this is a variable argument length function
); );
@ -237,14 +238,13 @@ class StructType : public CompositeType {
friend class TypeMap<StructValType, StructType>; friend class TypeMap<StructValType, StructType>;
StructType(const StructType &); // Do not implement StructType(const StructType &); // Do not implement
const StructType &operator=(const StructType &); // Do not implement const StructType &operator=(const StructType &); // Do not implement
StructType(LLVMContext &C, StructType(LLVMContext &C, ArrayRef<const Type*> Types, bool isPacked);
const std::vector<const Type*> &Types, bool isPacked);
public: public:
/// StructType::get - This static method is the primary way to create a /// StructType::get - This static method is the primary way to create a
/// StructType. /// StructType.
/// ///
static StructType *get(LLVMContext &Context, static StructType *get(LLVMContext &Context,
const std::vector<const Type*> &Params, ArrayRef<const Type*> Params,
bool isPacked=false); bool isPacked=false);
/// StructType::get - Create an empty structure type. /// StructType::get - Create an empty structure type.

View File

@ -17,6 +17,7 @@
#include "llvm/Assembly/Writer.h" #include "llvm/Assembly/Writer.h"
#include "llvm/LLVMContext.h" #include "llvm/LLVMContext.h"
#include "llvm/Metadata.h" #include "llvm/Metadata.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/SCCIterator.h" #include "llvm/ADT/SCCIterator.h"
@ -460,7 +461,7 @@ bool FunctionType::isValidArgumentType(const Type *ArgTy) {
} }
FunctionType::FunctionType(const Type *Result, FunctionType::FunctionType(const Type *Result,
const std::vector<const Type*> &Params, ArrayRef<const Type*> Params,
bool IsVarArgs) bool IsVarArgs)
: DerivedType(Result->getContext(), FunctionTyID), isVarArgs(IsVarArgs) { : DerivedType(Result->getContext(), FunctionTyID), isVarArgs(IsVarArgs) {
ContainedTys = reinterpret_cast<PATypeHandle*>(this+1); ContainedTys = reinterpret_cast<PATypeHandle*>(this+1);
@ -483,7 +484,7 @@ FunctionType::FunctionType(const Type *Result,
} }
StructType::StructType(LLVMContext &C, StructType::StructType(LLVMContext &C,
const std::vector<const Type*> &Types, bool isPacked) ArrayRef<const Type*> Types, bool isPacked)
: CompositeType(C, StructTyID) { : CompositeType(C, StructTyID) {
ContainedTys = reinterpret_cast<PATypeHandle*>(this + 1); ContainedTys = reinterpret_cast<PATypeHandle*>(this + 1);
NumContainedTys = Types.size(); NumContainedTys = Types.size();
@ -838,7 +839,7 @@ FunctionValType FunctionValType::get(const FunctionType *FT) {
// FunctionType::get - The factory function for the FunctionType class... // FunctionType::get - The factory function for the FunctionType class...
FunctionType *FunctionType::get(const Type *ReturnType, FunctionType *FunctionType::get(const Type *ReturnType,
const std::vector<const Type*> &Params, ArrayRef<const Type*> Params,
bool isVarArg) { bool isVarArg) {
FunctionValType VT(ReturnType, Params, isVarArg); FunctionValType VT(ReturnType, Params, isVarArg);
FunctionType *FT = 0; FunctionType *FT = 0;
@ -915,7 +916,7 @@ bool VectorType::isValidElementType(const Type *ElemTy) {
// //
StructType *StructType::get(LLVMContext &Context, StructType *StructType::get(LLVMContext &Context,
const std::vector<const Type*> &ETypes, ArrayRef<const Type*> ETypes,
bool isPacked) { bool isPacked) {
StructValType STV(ETypes, isPacked); StructValType STV(ETypes, isPacked);
StructType *ST = 0; StructType *ST = 0;

View File

@ -15,6 +15,7 @@
#ifndef LLVM_TYPESCONTEXT_H #ifndef LLVM_TYPESCONTEXT_H
#define LLVM_TYPESCONTEXT_H #define LLVM_TYPESCONTEXT_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include <map> #include <map>
@ -157,8 +158,8 @@ class StructValType {
std::vector<const Type*> ElTypes; std::vector<const Type*> ElTypes;
bool packed; bool packed;
public: public:
StructValType(const std::vector<const Type*> &args, bool isPacked) StructValType(ArrayRef<const Type*> args, bool isPacked)
: ElTypes(args), packed(isPacked) {} : ElTypes(args.vec()), packed(isPacked) {}
static StructValType get(const StructType *ST) { static StructValType get(const StructType *ST) {
std::vector<const Type *> ElTypes; std::vector<const Type *> ElTypes;
@ -187,8 +188,8 @@ class FunctionValType {
std::vector<const Type*> ArgTypes; std::vector<const Type*> ArgTypes;
bool isVarArg; bool isVarArg;
public: public:
FunctionValType(const Type *ret, const std::vector<const Type*> &args, FunctionValType(const Type *ret, ArrayRef<const Type*> args, bool isVA)
bool isVA) : RetTy(ret), ArgTypes(args), isVarArg(isVA) {} : RetTy(ret), ArgTypes(args.vec()), isVarArg(isVA) {}
static FunctionValType get(const FunctionType *FT); static FunctionValType get(const FunctionType *FT);