[cfe-commits] r62034 - in /cfe/trunk: Driver/RewriteObjC.cpp include/clang/AST/DeclObjC.h lib/AST/DeclObjC.cpp

Steve Naroff snaroff at apple.com
Sat Jan 10 17:06:10 PST 2009


Author: snaroff
Date: Sat Jan 10 19:06:09 2009
New Revision: 62034

URL: http://llvm.org/viewvc/llvm-project?rev=62034&view=rev
Log:
A few property related cleanups to ObjCContainerDecl AST.

Modified:
    cfe/trunk/Driver/RewriteObjC.cpp
    cfe/trunk/include/clang/AST/DeclObjC.h
    cfe/trunk/lib/AST/DeclObjC.cpp

Modified: cfe/trunk/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteObjC.cpp?rev=62034&r1=62033&r2=62034&view=diff

==============================================================================
--- cfe/trunk/Driver/RewriteObjC.cpp (original)
+++ cfe/trunk/Driver/RewriteObjC.cpp Sat Jan 10 19:06:09 2009
@@ -230,7 +230,7 @@
     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::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 @@
   }
   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);

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=62034&r1=62033&r2=62034&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Sat Jan 10 19:06:09 2009
@@ -276,10 +276,6 @@
     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 @@
   // 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; }

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=62034&r1=62033&r2=62034&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Sat Jan 10 19:06:09 2009
@@ -383,6 +383,12 @@
     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.





More information about the cfe-commits mailing list