A few property related cleanups to ObjCContainerDecl AST.

llvm-svn: 62034
This commit is contained in:
Steve Naroff 2009-01-11 01:06:09 +00:00
parent aaa679b270
commit 0c0f5bae80
3 changed files with 19 additions and 18 deletions

View File

@ -230,7 +230,7 @@ namespace {
void RewriteProtocolDecl(ObjCProtocolDecl *Dcl);
void RewriteForwardProtocolDecl(ObjCForwardProtocolDecl *Dcl);
void RewriteMethodDeclaration(ObjCMethodDecl *Method);
void RewriteProperties(unsigned nProperties, ObjCPropertyDecl **Properties);
void RewriteProperty(ObjCPropertyDecl *prop);
void RewriteFunctionDecl(FunctionDecl *FD);
void RewriteObjCQualifiedInterfaceTypes(Decl *Dcl);
void RewriteObjCQualifiedInterfaceTypes(Expr *E);
@ -774,16 +774,13 @@ void RewriteObjC::RewriteMethodDeclaration(ObjCMethodDecl *Method) {
}
}
void RewriteObjC::RewriteProperties(unsigned nProperties, ObjCPropertyDecl **Properties)
void RewriteObjC::RewriteProperty(ObjCPropertyDecl *prop)
{
for (unsigned i = 0; i < nProperties; i++) {
ObjCPropertyDecl *Property = Properties[i];
SourceLocation Loc = Property->getLocation();
SourceLocation Loc = prop->getLocation();
ReplaceText(Loc, 0, "// ", 3);
ReplaceText(Loc, 0, "// ", 3);
// FIXME: handle properties that are declared across multiple lines.
}
// FIXME: handle properties that are declared across multiple lines.
}
void RewriteObjC::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) {
@ -1038,8 +1035,9 @@ void RewriteObjC::RewriteInterfaceDecl(ObjCInterfaceDecl *ClassDecl) {
}
SynthesizeObjCInternalStruct(ClassDecl, ResultStr);
RewriteProperties(ClassDecl->getNumPropertyDecl(),
ClassDecl->getPropertyDecl());
for (ObjCInterfaceDecl::prop_iterator I = ClassDecl->prop_begin(),
E = ClassDecl->prop_end(); I != E; ++I)
RewriteProperty(*I);
for (ObjCInterfaceDecl::instmeth_iterator I = ClassDecl->instmeth_begin(),
E = ClassDecl->instmeth_end(); I != E; ++I)
RewriteMethodDeclaration(*I);

View File

@ -276,10 +276,6 @@ public:
return PropertyDecl+NumPropertyDecl;
}
ObjCPropertyDecl * const * getPropertyDecl() const { return PropertyDecl; }
ObjCPropertyDecl **getPropertyDecl() { return PropertyDecl; }
unsigned getNumPropertyDecl() const { return NumPropertyDecl; }
ObjCPropertyDecl *FindPropertyDeclaration(IdentifierInfo *PropertyId) const;
// Iterator access to instance/class methods.
@ -315,9 +311,10 @@ public:
ObjCMethodDecl *getInstanceMethod(Selector Sel) const;
ObjCMethodDecl *getClassMethod(Selector Sel) const;
// Get the number of instance/class methods. These methods are slow, O(n).
// Get the number of methods, properties. These methods are slow, O(n).
unsigned getNumInstanceMethods() const;
unsigned getNumClassMethods() const;
unsigned getNumProperties() const;
// Marks the end of the container.
SourceLocation getAtEndLoc() const { return AtEndLoc; }

View File

@ -383,6 +383,12 @@ unsigned ObjCContainerDecl::getNumClassMethods() const {
sum++;
return sum;
}
unsigned ObjCContainerDecl::getNumProperties() const {
unsigned sum = 0;
for (prop_iterator I=prop_begin(), E=prop_end(); I != E; ++I)
sum++;
return sum;
}
/// addProperties - Insert property declaration AST nodes into
/// ObjCContainerDecl's PropertyDecl field.