[cfe-commits] r48435 - in /cfe/trunk: Driver/ASTConsumers.cpp include/clang/AST/DeclObjC.h

Chris Lattner sabre at nondot.org
Sun Mar 16 18:24:41 PDT 2008


Author: lattner
Date: Sun Mar 16 20:24:41 2008
New Revision: 48435

URL: http://llvm.org/viewvc/llvm-project?rev=48435&view=rev
Log:
clean up iteration over propertydecls.

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

Modified: cfe/trunk/Driver/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=48435&r1=48434&r2=48435&view=diff

==============================================================================
--- cfe/trunk/Driver/ASTConsumers.cpp (original)
+++ cfe/trunk/Driver/ASTConsumers.cpp Sun Mar 16 20:24:41 2008
@@ -311,13 +311,14 @@
         Out << " )";
       }
       
-      ObjCIvarDecl *const *IDecl = PDecl->getPropertyDecls();
+      ObjCPropertyDecl::propdecl_iterator
+        I = PDecl->propdecl_begin(), E = PDecl->propdecl_end();
       
-      Out << ' ' << IDecl[0]->getType().getAsString()
-          << ' ' << IDecl[0]->getName();
-      
-      for (unsigned j = 1; j < PDecl->getNumPropertyDecls(); j++)
-        Out << ", " << IDecl[j]->getName();
+      Out << ' ' << (*I)->getType().getAsString()
+          << ' ' << (*I)->getName();
+    
+      for (++I; I != E; ++I)
+        Out << ", " << (*I)->getName();
 
       Out << ";\n";
     }

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

==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Sun Mar 16 20:24:41 2008
@@ -895,15 +895,17 @@
   
 class ObjCPropertyDecl : public Decl {
 public:
-  enum PropertyAttributeKind { OBJC_PR_noattr = 0x0, 
-                       OBJC_PR_readonly = 0x01, 
-                       OBJC_PR_getter = 0x02,
-                       OBJC_PR_assign = 0x04, 
-                       OBJC_PR_readwrite = 0x08, 
-                       OBJC_PR_retain = 0x10,
-                       OBJC_PR_copy = 0x20, 
-                       OBJC_PR_nonatomic = 0x40,
-                       OBJC_PR_setter = 0x80 };
+  enum PropertyAttributeKind {
+    OBJC_PR_noattr    = 0x00, 
+    OBJC_PR_readonly  = 0x01, 
+    OBJC_PR_getter    = 0x02,
+    OBJC_PR_assign    = 0x04, 
+    OBJC_PR_readwrite = 0x08, 
+    OBJC_PR_retain    = 0x10,
+    OBJC_PR_copy      = 0x20, 
+    OBJC_PR_nonatomic = 0x40,
+    OBJC_PR_setter    = 0x80
+  };
 private:
   // List of property name declarations
   // FIXME: Property is not an ivar.
@@ -920,24 +922,29 @@
 public:
   static ObjCPropertyDecl *Create(ASTContext &C, SourceLocation L);
   
-  ObjCIvarDecl *const* getPropertyDecls() const { return PropertyDecls; }
-  unsigned getNumPropertyDecls() const { return NumPropertyDecls; }
+  typedef ObjCIvarDecl * const *propdecl_iterator;
+  propdecl_iterator propdecl_begin() const { return PropertyDecls; }
+  propdecl_iterator propdecl_end() const {
+    return PropertyDecls+NumPropertyDecls; 
+  }
+  unsigned propdecl_size() const { return NumPropertyDecls; }
+  bool propdecl_empty() const { return NumPropertyDecls == 0; }
 
+  /// setPropertyDeclLists - Set the property decl list to the specified array
+  /// of decls.
   void setPropertyDeclLists(ObjCIvarDecl **Properties, unsigned NumProp);
   
-  const PropertyAttributeKind getPropertyAttributes() const {
+  PropertyAttributeKind getPropertyAttributes() const {
     return PropertyAttributeKind(PropertyAttributes);
   }
   void setPropertyAttributes(PropertyAttributeKind PRVal) { 
-    PropertyAttributes =  (PropertyAttributeKind) (PropertyAttributes | PRVal);
+    PropertyAttributes |= PRVal;
   }
   
-  const IdentifierInfo *getGetterName() const { return GetterName; }
-  IdentifierInfo *getGetterName() { return GetterName; }
+  IdentifierInfo *getGetterName() const { return GetterName; }
   void setGetterName(IdentifierInfo *Id) { GetterName = Id; }
   
-  const IdentifierInfo *getSetterName() const { return SetterName; }
-  IdentifierInfo *getSetterName() { return SetterName; }
+  IdentifierInfo *getSetterName() const { return SetterName; }
   void setSetterName(IdentifierInfo *Id) { SetterName = Id; }
   
   static bool classof(const Decl *D) {





More information about the cfe-commits mailing list