]> granicus.if.org Git - clang/commitdiff
Make the parameter count of ObjCMethodDecl unsigned, you
authorChris Lattner <sabre@nondot.org>
Sun, 16 Mar 2008 01:07:14 +0000 (01:07 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 16 Mar 2008 01:07:14 +0000 (01:07 +0000)
can't have negative arguments.

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

Driver/ASTConsumers.cpp
Driver/RewriteTest.cpp
include/clang/AST/DeclObjC.h
lib/Sema/SemaDeclObjC.cpp
lib/Sema/SemaType.cpp

index e6a1ae4b70e12090e14b63f31abcb46996515bf7..dcbe6796c00554ba784d32df6d334fb7ad3434c3 100644 (file)
@@ -182,7 +182,7 @@ void DeclPrinter::PrintObjCMethodDecl(ObjCMethodDecl *OMD) {
   // FIXME: just print original selector name!
   Out << OMD->getSelector().getName();
   
-  for (int i = 0; i < OMD->getNumParams(); i++) {
+  for (unsigned i = 0, e = OMD->getNumParams(); i != e; ++i) {
     ParmVarDecl *PDecl = OMD->getParamDecl(i);
     // FIXME: selector is missing here!    
     Out << " :(" << PDecl->getType().getAsString() << ") " << PDecl->getName(); 
index 8d19334eb80fef164c995b7fecc8ddd250f85a05..d72aaf282b2d22a20c2fe941d5dbddb4d7f3b1fe 100644 (file)
@@ -691,7 +691,7 @@ void RewriteTest::RewriteObjCMethodDecl(ObjCMethodDecl *OMD,
   ResultStr += " _cmd";
   
   // Method arguments.
-  for (int i = 0; i < OMD->getNumParams(); i++) {
+  for (unsigned i = 0; i < OMD->getNumParams(); i++) {
     ParmVarDecl *PDecl = OMD->getParamDecl(i);
     ResultStr += ", ";
     if (PDecl->getType()->isObjCQualifiedIdType())
@@ -2048,7 +2048,7 @@ Stmt *RewriteTest::SynthMessageExpr(ObjCMessageExpr *Exp) {
   ArgTypes.push_back(Context->getObjCSelType());
   if (ObjCMethodDecl *mDecl = Exp->getMethodDecl()) {
     // Push any user argument types.
-    for (int i = 0; i < mDecl->getNumParams(); i++) {
+    for (unsigned i = 0; i < mDecl->getNumParams(); i++) {
       QualType t = mDecl->getParamDecl(i)->getType()->isObjCQualifiedIdType()
                      ? Context->getObjCIdType() 
                      : mDecl->getParamDecl(i)->getType();
index 5e85f9cccf940affefc7354a2e66b8b57f05127b..290d99efaceeef912d17f76e84d893d4a4facead 100644 (file)
@@ -77,7 +77,7 @@ private:
   /// ParamInfo - new[]'d array of pointers to VarDecls for the formal
   /// parameters of this Method.  This is null if there are no formals.  
   ParmVarDecl **ParamInfo;
-  int NumMethodParams;
+  unsigned NumMethodParams;
   
   /// List of attributes for this method declaration.
   AttributeList *MethodAttrs;
@@ -94,8 +94,7 @@ private:
                  Decl *contextDecl,
                  AttributeList *M = 0, bool isInstance = true,
                  bool isVariadic = false,
-                 ImplementationControl impControl = None,
-                 Decl *PrevDecl = 0)
+                 ImplementationControl impControl = None)
   : Decl(ObjCMethod, beginLoc),
     IsInstance(isInstance), IsVariadic(isVariadic),
     DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None),
@@ -131,9 +130,7 @@ public:
   QualType getResultType() const { return MethodDeclType; }
   
   // Iterator access to formal parameters.
-  unsigned param_size() const {
-    return NumMethodParams == -1 ? 0 : NumMethodParams;
-  }
+  unsigned param_size() const { return NumMethodParams; }
   typedef ParmVarDecl **param_iterator;
   typedef ParmVarDecl * const *param_const_iterator;
   param_iterator param_begin() { return ParamInfo; }
@@ -141,8 +138,8 @@ public:
   param_const_iterator param_begin() const { return ParamInfo; }
   param_const_iterator param_end() const { return ParamInfo+param_size(); }
   
-  int getNumParams() const { return NumMethodParams; }
-  ParmVarDecl *getParamDecl(int i) const {
+  unsigned getNumParams() const { return NumMethodParams; }
+  ParmVarDecl *getParamDecl(unsigned i) const {
     assert(i < getNumParams() && "Illegal param #");
     return ParamInfo[i];
   }  
index a677662f401d014c062b5e313f644e7c84eba640..4dd84d8555e4056cf9ab95731b290208a552af9e 100644 (file)
@@ -61,7 +61,7 @@ void Sema::ObjCActOnStartOfMethodDef(Scope *FnBodyScope, DeclTy *D) {
   PI.TypeInfo = Context.getObjCSelType().getAsOpaquePtr();
   ActOnParamDeclarator(PI, FnBodyScope);
   
-  for (int i = 0; i <  MDecl->getNumParams(); i++) {
+  for (unsigned i = 0, e = MDecl->getNumParams(); i != e; ++i) {
     ParmVarDecl *PDecl = MDecl->getParamDecl(i);
     PI.Ident = PDecl->getIdentifier();
     PI.IdentLoc = PDecl->getLocation(); // user vars have a real location.
@@ -613,7 +613,7 @@ bool Sema::MatchTwoMethodDeclarations(const ObjCMethodDecl *Method,
   if (Method->getResultType().getCanonicalType() !=
       PrevMethod->getResultType().getCanonicalType())
     return false;
-  for (int i = 0; i < Method->getNumParams(); i++) {
+  for (unsigned i = 0, e = Method->getNumParams(); i != e; ++i) {
     ParmVarDecl *ParamDecl = Method->getParamDecl(i);
     ParmVarDecl *PrevParamDecl = PrevMethod->getParamDecl(i);
     if (ParamDecl->getCanonicalType() != PrevParamDecl->getCanonicalType())
index f717b4139a53ce121625fdb7add00b428e112c78..d4cb979563f33cf5f044e62ffcf02cd2fdfe43b6 100644 (file)
@@ -383,7 +383,7 @@ QualType Sema::ObjCGetTypeForMethodDefinition(DeclTy *D) {
     ArgTys.push_back(Context.getObjCIdType());
   ArgTys.push_back(Context.getObjCSelType());
       
-  for (int i = 0; i <  MDecl->getNumParams(); i++) {
+  for (int i = 0, e = MDecl->getNumParams(); i != e; ++i) {
     ParmVarDecl *PDecl = MDecl->getParamDecl(i);
     QualType ArgTy = PDecl->getType();
     assert(!ArgTy.isNull() && "Couldn't parse type?");