aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-02-20 18:43:26 +0000
committerChris Lattner <sabre@nondot.org>2009-02-20 18:43:26 +0000
commit89951a86b594513c2a013532ed45d197413b1087 (patch)
tree883acd05d33e09e7e1e87cbdf7d029ea5d522f44 /lib
parent69ab26a8623141f35e86817cfc6e0fbe7639a40f (diff)
remove some more methods from objc decls, using the iterator
interfaces more consistently. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65138 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/ASTContext.cpp13
-rw-r--r--lib/CodeGen/CGObjC.cpp11
-rw-r--r--lib/Sema/SemaDeclAttr.cpp19
-rw-r--r--lib/Sema/SemaDeclObjC.cpp25
-rw-r--r--lib/Sema/SemaExprObjC.cpp2
-rw-r--r--lib/Sema/SemaType.cpp11
6 files changed, 40 insertions, 41 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index b8c74e1396..9ed6251089 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -1858,10 +1858,10 @@ void ASTContext::getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl,
// The first two arguments (self and _cmd) are pointers; account for
// their size.
int ParmOffset = 2 * PtrSize;
- int NumOfParams = Decl->getNumParams();
- for (int i = 0; i < NumOfParams; i++) {
- QualType PType = Decl->getParamDecl(i)->getType();
- int sz = getObjCEncodingTypeSize (PType);
+ for (ObjCMethodDecl::param_iterator PI = Decl->param_begin(),
+ E = Decl->param_end(); PI != E; ++PI) {
+ QualType PType = (*PI)->getType();
+ int sz = getObjCEncodingTypeSize(PType);
assert (sz > 0 && "getObjCEncodingForMethodDecl - Incomplete param type");
ParmOffset += sz;
}
@@ -1871,8 +1871,9 @@ void ASTContext::getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl,
// Argument types.
ParmOffset = 2 * PtrSize;
- for (int i = 0; i < NumOfParams; i++) {
- ParmVarDecl *PVDecl = Decl->getParamDecl(i);
+ for (ObjCMethodDecl::param_iterator PI = Decl->param_begin(),
+ E = Decl->param_end(); PI != E; ++PI) {
+ ParmVarDecl *PVDecl = *PI;
QualType PType = PVDecl->getOriginalType();
if (const ArrayType *AT =
dyn_cast<ArrayType>(PType->getCanonicalTypeInternal()))
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp
index 9adcc358f8..dd0292ea4d 100644
--- a/lib/CodeGen/CGObjC.cpp
+++ b/lib/CodeGen/CGObjC.cpp
@@ -115,10 +115,9 @@ void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD,
Args.push_back(std::make_pair(OMD->getCmdDecl(),
OMD->getCmdDecl()->getType()));
- for (unsigned i = 0, e = OMD->getNumParams(); i != e; ++i) {
- ParmVarDecl *IPD = OMD->getParamDecl(i);
- Args.push_back(std::make_pair(IPD, IPD->getType()));
- }
+ for (ObjCMethodDecl::param_iterator PI = OMD->param_begin(),
+ E = OMD->param_end(); PI != E; ++PI)
+ Args.push_back(std::make_pair(*PI, (*PI)->getType()));
StartFunction(OMD, OMD->getResultType(), Fn, Args, OMD->getLocEnd());
}
@@ -254,7 +253,7 @@ void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP,
llvm::Value *SelfAsId =
Builder.CreateBitCast(LoadObjCSelf(), Types.ConvertType(IdTy));
llvm::Value *Offset = EmitIvarOffset(IMP->getClassInterface(), Ivar);
- llvm::Value *Arg = LocalDeclMap[OMD->getParamDecl(0)];
+ llvm::Value *Arg = LocalDeclMap[*OMD->param_begin()];
llvm::Value *ArgAsId =
Builder.CreateBitCast(Builder.CreateLoad(Arg, "arg"),
Types.ConvertType(IdTy));
@@ -280,7 +279,7 @@ void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP,
ValueDecl *Self = OMD->getSelfDecl();
ObjCIvarDecl *Ivar = PID->getPropertyIvarDecl();
DeclRefExpr Base(Self, Self->getType(), Loc);
- ParmVarDecl *ArgDecl = OMD->getParamDecl(0);
+ ParmVarDecl *ArgDecl = *OMD->param_begin();
DeclRefExpr Arg(ArgDecl, ArgDecl->getType(), Loc);
ObjCInterfaceDecl *OI = IMP->getClassInterface();
ObjCIvarRefExpr IvarRef(Ivar, Ivar->getType(), Loc, &Base,
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 2ceea33d07..ce38edd7c5 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -67,21 +67,16 @@ static bool hasFunctionProto(Decl *d) {
/// arguments. It is an error to call this on a K&R function (use
/// hasFunctionProto first).
static unsigned getFunctionOrMethodNumArgs(Decl *d) {
- if (const FunctionType *FnTy = getFunctionType(d)) {
- const FunctionTypeProto *proto = cast<FunctionTypeProto>(FnTy);
- return proto->getNumArgs();
- } else {
- return cast<ObjCMethodDecl>(d)->getNumParams();
- }
+ if (const FunctionType *FnTy = getFunctionType(d))
+ return cast<FunctionTypeProto>(FnTy)->getNumArgs();
+ return cast<ObjCMethodDecl>(d)->param_size();
}
static QualType getFunctionOrMethodArgType(Decl *d, unsigned Idx) {
- if (const FunctionType *FnTy = getFunctionType(d)) {
- const FunctionTypeProto *proto = cast<FunctionTypeProto>(FnTy);
- return proto->getArgType(Idx);
- } else {
- return cast<ObjCMethodDecl>(d)->getParamDecl(Idx)->getType();
- }
+ if (const FunctionType *FnTy = getFunctionType(d))
+ return cast<FunctionTypeProto>(FnTy)->getArgType(Idx);
+
+ return cast<ObjCMethodDecl>(d)->param_begin()[Idx]->getType();
}
static bool isFunctionOrMethodVariadic(Decl *d) {
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index b890637767..65cd4b4e54 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -46,11 +46,10 @@ void Sema::ObjCActOnStartOfMethodDef(Scope *FnBodyScope, DeclTy *D) {
PushOnScopeChains(MDecl->getCmdDecl(), FnBodyScope);
// Introduce all of the other parameters into this scope.
- for (unsigned i = 0, e = MDecl->getNumParams(); i != e; ++i) {
- ParmVarDecl *PDecl = MDecl->getParamDecl(i);
- if (PDecl->getIdentifier())
- PushOnScopeChains(PDecl, FnBodyScope);
- }
+ for (ObjCMethodDecl::param_iterator PI = MDecl->param_begin(),
+ E = MDecl->param_end(); PI != E; ++PI)
+ if ((*PI)->getIdentifier())
+ PushOnScopeChains(*PI, FnBodyScope);
}
Sema::DeclTy *Sema::
@@ -992,9 +991,15 @@ bool Sema::MatchTwoMethodDeclarations(const ObjCMethodDecl *Method,
if (Context.getTypeInfo(T1) != Context.getTypeInfo(T2))
return false;
}
- for (unsigned i = 0, e = Method->getNumParams(); i != e; ++i) {
- T1 = Context.getCanonicalType(Method->getParamDecl(i)->getType());
- T2 = Context.getCanonicalType(PrevMethod->getParamDecl(i)->getType());
+
+ ObjCMethodDecl::param_iterator ParamI = Method->param_begin(),
+ E = Method->param_end();
+ ObjCMethodDecl::param_iterator PrevI = PrevMethod->param_begin();
+
+ for (; ParamI != E; ++ParamI, ++PrevI) {
+ assert(PrevI != PrevMethod->param_end() && "Param mismatch");
+ T1 = Context.getCanonicalType((*ParamI)->getType());
+ T2 = Context.getCanonicalType((*PrevI)->getType());
if (T1 != T2) {
// The result types are different.
if (!matchBasedOnSizeAndAlignment)
@@ -1103,8 +1108,8 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
if (Context.getCanonicalType(SetterMethod->getResultType())
!= Context.VoidTy)
Diag(SetterMethod->getLocation(), diag::err_setter_type_void);
- if (SetterMethod->getNumParams() != 1 ||
- (SetterMethod->getParamDecl(0)->getType() != property->getType())) {
+ if (SetterMethod->param_size() != 1 ||
+ ((*SetterMethod->param_begin())->getType() != property->getType())) {
Diag(property->getLocation(),
diag::err_accessor_property_type_mismatch)
<< property->getDeclName()
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 25b41c64de..19dc3821c7 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -154,7 +154,7 @@ bool Sema::CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs,
Expr *argExpr = Args[i];
assert(argExpr && "CheckMessageArgumentTypes(): missing expression");
- QualType lhsType = Method->getParamDecl(i)->getType();
+ QualType lhsType = Method->param_begin()[i]->getType();
QualType rhsType = argExpr->getType();
// If necessary, apply function/array conversion. C99 6.7.5.3p[7,8].
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 02ba807758..252cd2d533 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -662,7 +662,7 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S, unsigned Skip) {
/// ObjCGetTypeForMethodDefinition - Builds the type for a method definition
/// declarator
QualType Sema::ObjCGetTypeForMethodDefinition(DeclTy *D) {
- ObjCMethodDecl *MDecl = dyn_cast<ObjCMethodDecl>(static_cast<Decl *>(D));
+ ObjCMethodDecl *MDecl = cast<ObjCMethodDecl>(static_cast<Decl *>(D));
QualType T = MDecl->getResultType();
llvm::SmallVector<QualType, 16> ArgTys;
@@ -671,14 +671,13 @@ QualType Sema::ObjCGetTypeForMethodDefinition(DeclTy *D) {
QualType selfTy = Context.getObjCInterfaceType(MDecl->getClassInterface());
selfTy = Context.getPointerType(selfTy);
ArgTys.push_back(selfTy);
- }
- else
+ } else
ArgTys.push_back(Context.getObjCIdType());
ArgTys.push_back(Context.getObjCSelType());
- for (int i = 0, e = MDecl->getNumParams(); i != e; ++i) {
- ParmVarDecl *PDecl = MDecl->getParamDecl(i);
- QualType ArgTy = PDecl->getType();
+ for (ObjCMethodDecl::param_iterator PI = MDecl->param_begin(),
+ E = MDecl->param_end(); PI != E; ++PI) {
+ QualType ArgTy = (*PI)->getType();
assert(!ArgTy.isNull() && "Couldn't parse type?");
// Perform the default function/array conversion (C99 6.7.5.3p[7,8]).
// This matches the conversion that is done in