aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2009-01-11 01:06:09 +0000
committerSteve Naroff <snaroff@apple.com>2009-01-11 01:06:09 +0000
commit6327e0d55c590b3c2766fa76ef1db241a0467df2 (patch)
treeef23b65fe5467309bca0fa63868de4bbd425dbf0
parentde307473448fb3cebcb4c10090728300b53bca03 (diff)
A few property related cleanups to ObjCContainerDecl AST.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62034 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Driver/RewriteObjC.cpp22
-rw-r--r--include/clang/AST/DeclObjC.h9
-rw-r--r--lib/AST/DeclObjC.cpp6
3 files changed, 19 insertions, 18 deletions
diff --git a/Driver/RewriteObjC.cpp b/Driver/RewriteObjC.cpp
index 7ca972c52d..cc66a2c267 100644
--- a/Driver/RewriteObjC.cpp
+++ b/Driver/RewriteObjC.cpp
@@ -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();
-
- ReplaceText(Loc, 0, "// ", 3);
-
- // FIXME: handle properties that are declared across multiple lines.
- }
+ SourceLocation Loc = prop->getLocation();
+
+ ReplaceText(Loc, 0, "// ", 3);
+
+ // 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);
diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h
index 561a0142e9..bf9499be28 100644
--- a/include/clang/AST/DeclObjC.h
+++ b/include/clang/AST/DeclObjC.h
@@ -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.
@@ -314,10 +310,11 @@ public:
// Get the local instance/class method declared in this interface.
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; }
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index f39eec3dc5..bac9f7b344 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -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.