[cfe-commits] r48407 - in /cfe/trunk: Driver/ASTConsumers.cpp Driver/RewriteTest.cpp include/clang/AST/DeclObjC.h lib/Sema/SemaDeclObjC.cpp lib/Sema/SemaType.cpp
Chris Lattner
sabre at nondot.org
Sat Mar 15 18:07:14 PDT 2008
Author: lattner
Date: Sat Mar 15 20:07:14 2008
New Revision: 48407
URL: http://llvm.org/viewvc/llvm-project?rev=48407&view=rev
Log:
Make the parameter count of ObjCMethodDecl unsigned, you
can't have negative arguments.
Modified:
cfe/trunk/Driver/ASTConsumers.cpp
cfe/trunk/Driver/RewriteTest.cpp
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaType.cpp
Modified: cfe/trunk/Driver/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=48407&r1=48406&r2=48407&view=diff
==============================================================================
--- cfe/trunk/Driver/ASTConsumers.cpp (original)
+++ cfe/trunk/Driver/ASTConsumers.cpp Sat Mar 15 20:07:14 2008
@@ -182,7 +182,7 @@
// 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();
Modified: cfe/trunk/Driver/RewriteTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=48407&r1=48406&r2=48407&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Sat Mar 15 20:07:14 2008
@@ -691,7 +691,7 @@
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 @@
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();
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=48407&r1=48406&r2=48407&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Sat Mar 15 20:07:14 2008
@@ -77,7 +77,7 @@
/// 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 @@
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 @@
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 @@
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];
}
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=48407&r1=48406&r2=48407&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sat Mar 15 20:07:14 2008
@@ -61,7 +61,7 @@
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 @@
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())
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=48407&r1=48406&r2=48407&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Sat Mar 15 20:07:14 2008
@@ -383,7 +383,7 @@
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?");
More information about the cfe-commits
mailing list