]> granicus.if.org Git - clang/commitdiff
A few property related cleanups to ObjCContainerDecl AST.
authorSteve Naroff <snaroff@apple.com>
Sun, 11 Jan 2009 01:06:09 +0000 (01:06 +0000)
committerSteve Naroff <snaroff@apple.com>
Sun, 11 Jan 2009 01:06:09 +0000 (01:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62034 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/RewriteObjC.cpp
include/clang/AST/DeclObjC.h
lib/AST/DeclObjC.cpp

index 7ca972c52d908192a440391544a8ef5c775fd4b7..cc66a2c267d90e3cb296c352087fe484709ee42a 100644 (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();
-    
-    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);
index 561a0142e9bfdad2c62a73e68cc976fb55ec65be..bf9499be28303dec540fd553c5281e0a195685c4 100644 (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.
@@ -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; }
index f39eec3dc56d0560f407af58bfe9b1b587b0a6e5..bac9f7b3444c762b25001b7b2459757176e59413 100644 (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.