[cfe-commits] r65114 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/AST/DeclObjC.cpp lib/CodeGen/CGCall.cpp
Chris Lattner
sabre at nondot.org
Thu Feb 19 22:23:22 PST 2009
Author: lattner
Date: Fri Feb 20 00:23:21 2009
New Revision: 65114
URL: http://llvm.org/viewvc/llvm-project?rev=65114&view=rev
Log:
switch ObjCMethodDecl's parameter list from being explicitly managed to an ObjCList.
Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=65114&r1=65113&r2=65114&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Fri Feb 20 00:23:21 2009
@@ -123,10 +123,9 @@
// Type of this method.
QualType MethodDeclType;
- /// 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;
- unsigned NumMethodParams;
+ /// ParamInfo - List of pointers to VarDecls for the formal parameters of this
+ /// Method.
+ ObjCList<ParmVarDecl> ParamInfo;
/// List of attributes for this method declaration.
SourceLocation EndLoc; // the location of the ';' or '{'.
@@ -155,12 +154,9 @@
IsSynthesized(isSynthesized),
DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None),
MethodDeclType(T),
- ParamInfo(0), NumMethodParams(0),
EndLoc(endLoc), Body(0), SelfDecl(0), CmdDecl(0) {}
- virtual ~ObjCMethodDecl() {
- assert(ParamInfo == 0 && "Destroy not called?");
- }
+ virtual ~ObjCMethodDecl() {}
public:
@@ -198,23 +194,18 @@
QualType getResultType() const { return MethodDeclType; }
// Iterator access to formal parameters.
- unsigned param_size() const { return NumMethodParams; }
- typedef ParmVarDecl **param_iterator;
- typedef ParmVarDecl * const *param_const_iterator;
- param_iterator param_begin() { return ParamInfo; }
- param_iterator param_end() { return ParamInfo+param_size(); }
- param_const_iterator param_begin() const { return ParamInfo; }
- param_const_iterator param_end() const { return ParamInfo+param_size(); }
+ unsigned param_size() const { return ParamInfo.size(); }
+ typedef ObjCList<ParmVarDecl>::iterator param_iterator;
+ param_iterator param_begin() const { return ParamInfo.begin(); }
+ param_iterator param_end() const { return ParamInfo.end(); }
- unsigned getNumParams() const { return NumMethodParams; }
+ unsigned getNumParams() const { return ParamInfo.size(); }
ParmVarDecl *getParamDecl(unsigned i) const {
- assert(i < getNumParams() && "Illegal param #");
return ParamInfo[i];
}
- void setParamDecl(int i, ParmVarDecl *pDecl) {
- ParamInfo[i] = pDecl;
- }
- void setMethodParams(ParmVarDecl **NewParamInfo, unsigned NumParams);
+ void setMethodParams(ParmVarDecl *const *NewParamInfo, unsigned NumParams) {
+ ParamInfo.set(NewParamInfo, NumParams);
+ }
/// createImplicitParams - Used to lazily create the self and cmd
/// implict parameters. This must be called prior to using getSelfDecl()
Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=65114&r1=65113&r2=65114&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Fri Feb 20 00:23:21 2009
@@ -42,8 +42,7 @@
for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I)
if (*I) (*I)->Destroy(C);
- delete [] ParamInfo;
- ParamInfo = 0;
+ ParamInfo.clear();
Decl::Destroy(C);
}
@@ -241,18 +240,6 @@
Context.getObjCSelType());
}
-void ObjCMethodDecl::setMethodParams(ParmVarDecl **NewParamInfo,
- unsigned NumParams) {
- assert(ParamInfo == 0 && "Already has param info!");
-
- // Zero params -> null pointer.
- if (NumParams) {
- ParamInfo = new ParmVarDecl*[NumParams];
- memcpy(ParamInfo, NewParamInfo, sizeof(ParmVarDecl*)*NumParams);
- NumMethodParams = NumParams;
- }
-}
-
/// FindCategoryDeclaration - Finds category declaration in the list of
/// categories for this class and returns it. Name of the category is passed
/// in 'CategoryId'. If category not found, return 0;
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=65114&r1=65113&r2=65114&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Fri Feb 20 00:23:21 2009
@@ -63,7 +63,7 @@
ArgTys.push_back(MD->getSelfDecl()->getType());
ArgTys.push_back(Context.getObjCSelType());
// FIXME: Kill copy?
- for (ObjCMethodDecl::param_const_iterator i = MD->param_begin(),
+ for (ObjCMethodDecl::param_iterator i = MD->param_begin(),
e = MD->param_end(); i != e; ++i)
ArgTys.push_back((*i)->getType());
return getFunctionInfo(MD->getResultType(), ArgTys);
More information about the cfe-commits
mailing list