]> granicus.if.org Git - clang/commitdiff
clean up iteration over propertydecls.
authorChris Lattner <sabre@nondot.org>
Mon, 17 Mar 2008 01:24:41 +0000 (01:24 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 17 Mar 2008 01:24:41 +0000 (01:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48435 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/ASTConsumers.cpp
include/clang/AST/DeclObjC.h

index da20557b1d45ea89cbf110c2d054952344f48dc5..d58eca5d35a43614d00c9142c92bc7a95e1b4a41 100644 (file)
@@ -311,13 +311,14 @@ void DeclPrinter::PrintObjCInterfaceDecl(ObjCInterfaceDecl *OID) {
         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";
     }
index e74d5b4676f0f3860120d25c131d2739bc61f55f..c50eaddac858a29d4f9f737cb37f0427544d7c44 100644 (file)
@@ -895,15 +895,17 @@ public:
   
 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 @@ private:
 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) {