From 3668cb2d3c0437c4f339a1596cab9e82b6af93c7 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Mon, 2 Feb 2009 23:43:58 +0000 Subject: [PATCH] Change CGFunctionInfo args iterator to not include the return type. llvm-svn: 63571 --- clang/lib/CodeGen/CGCall.cpp | 28 ++++++++++++++-------------- clang/lib/CodeGen/CGCall.h | 10 ++++------ 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 7e2592206e0b..898c780aaecc 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -97,11 +97,11 @@ CGFunctionInfo::CGFunctionInfo(QualType ResTy, ArgTypes.insert(ArgTypes.end(), ArgTys.begin(), ArgTys.end()); } -ArgTypeIterator CGFunctionInfo::argtypes_begin() const { - return ArgTypes.begin(); +CGFunctionInfo::arg_iterator CGFunctionInfo::arg_begin() const { + return ArgTypes.begin()+1; } -ArgTypeIterator CGFunctionInfo::argtypes_end() const { +CGFunctionInfo::arg_iterator CGFunctionInfo::arg_end() const { return ArgTypes.end(); } @@ -965,8 +965,7 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI, bool IsVariadic) { const llvm::Type *ResultType = 0; - ArgTypeIterator begin = FI.argtypes_begin(), end = FI.argtypes_end(); - QualType RetTy = *begin; + QualType RetTy = FI.getReturnType(); ABIArgInfo RetAI = getABIReturnInfo(RetTy, *this); switch (RetAI.getKind()) { case ABIArgInfo::ByVal: @@ -997,9 +996,10 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI, bool IsVariadic) { break; } - for (++begin; begin != end; ++begin) { - ABIArgInfo AI = getABIArgumentInfo(*begin, *this); - const llvm::Type *Ty = ConvertType(*begin); + for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end(); + it != ie; ++it) { + ABIArgInfo AI = getABIArgumentInfo(*it, *this); + const llvm::Type *Ty = ConvertType(*it); switch (AI.getKind()) { case ABIArgInfo::Ignore: @@ -1020,7 +1020,7 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI, bool IsVariadic) { break; case ABIArgInfo::Expand: - GetExpandedTypes(*begin, ArgTys); + GetExpandedTypes(*it, ArgTys); break; } } @@ -1028,7 +1028,7 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI, bool IsVariadic) { return llvm::FunctionType::get(ResultType, ArgTys, IsVariadic); } -void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &Info, +void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, const Decl *TargetDecl, AttributeListType &PAL) { unsigned FuncAttrs = 0; @@ -1045,8 +1045,7 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &Info, FuncAttrs |= llvm::Attribute::ReadNone; } - ArgTypeIterator begin = Info.argtypes_begin(), end = Info.argtypes_end(); - QualType RetTy = *begin; + QualType RetTy = FI.getReturnType(); unsigned Index = 1; ABIArgInfo RetAI = getABIReturnInfo(RetTy, getTypes()); switch (RetAI.getKind()) { @@ -1078,8 +1077,9 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &Info, if (RetAttrs) PAL.push_back(llvm::AttributeWithIndex::get(0, RetAttrs)); - for (++begin; begin != end; ++begin) { - QualType ParamType = *begin; + for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end(); + it != ie; ++it) { + QualType ParamType = *it; unsigned Attributes = 0; ABIArgInfo AI = getABIArgumentInfo(ParamType, getTypes()); diff --git a/clang/lib/CodeGen/CGCall.h b/clang/lib/CodeGen/CGCall.h index f8fb32b15a4e..aaab36ca83ec 100644 --- a/clang/lib/CodeGen/CGCall.h +++ b/clang/lib/CodeGen/CGCall.h @@ -47,21 +47,19 @@ namespace CodeGen { typedef llvm::SmallVector, 16> FunctionArgList; - // FIXME: This should be a better iterator type so that we can avoid - // construction of the ArgTypes smallvectors. - typedef llvm::SmallVector::const_iterator ArgTypeIterator; - /// CGFunctionInfo - Class to encapsulate the information about a /// function definition. class CGFunctionInfo { llvm::SmallVector ArgTypes; public: + typedef llvm::SmallVector::const_iterator arg_iterator; + CGFunctionInfo(QualType ResTy, const llvm::SmallVector &ArgTys); - ArgTypeIterator argtypes_begin() const; - ArgTypeIterator argtypes_end() const; + arg_iterator arg_begin() const; + arg_iterator arg_end() const; QualType getReturnType() const { return ArgTypes[0]; } };