From a5674258f5e6f74f1c0ed3ece4d64fbb1b9afb11 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 17 Mar 2008 01:24:41 +0000 Subject: [PATCH] clean up iteration over propertydecls. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48435 91177308-0d34-0410-b5e6-96231b3b80d8 --- Driver/ASTConsumers.cpp | 13 ++++++------ include/clang/AST/DeclObjC.h | 41 +++++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/Driver/ASTConsumers.cpp b/Driver/ASTConsumers.cpp index da20557b1d..d58eca5d35 100644 --- a/Driver/ASTConsumers.cpp +++ b/Driver/ASTConsumers.cpp @@ -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"; } diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index e74d5b4676..c50eaddac8 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -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) { -- 2.40.0