[cfe-commits] r61988 - in /cfe/trunk: Driver/ASTConsumers.cpp include/clang/AST/DeclBase.h include/clang/AST/DeclObjC.h lib/AST/DeclBase.cpp lib/AST/DeclObjC.cpp lib/AST/TranslationUnit.cpp lib/CodeGen/CGObjCMac.cpp lib/Sema/SemaDeclObjC.cpp

Steve Naroff snaroff at apple.com
Fri Jan 9 07:36:26 PST 2009


Author: snaroff
Date: Fri Jan  9 09:36:25 2009
New Revision: 61988

URL: http://llvm.org/viewvc/llvm-project?rev=61988&view=rev
Log:
Move property API's up to ObjCContainerDecl (removing a lot of duplicate code).
Add isa/cast/dyncast support for ObjCContainerDecl.
Renamed classprop_iterator/begin/end to prop_iterator/begin/end (the class prefix was confusing).
More simplifications to Sema::ActOnAtEnd()...
Added/changed some FIXME's as a result of the above work.

Modified:
    cfe/trunk/Driver/ASTConsumers.cpp
    cfe/trunk/include/clang/AST/DeclBase.h
    cfe/trunk/include/clang/AST/DeclObjC.h
    cfe/trunk/lib/AST/DeclBase.cpp
    cfe/trunk/lib/AST/DeclObjC.cpp
    cfe/trunk/lib/AST/TranslationUnit.cpp
    cfe/trunk/lib/CodeGen/CGObjCMac.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

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

==============================================================================
--- cfe/trunk/Driver/ASTConsumers.cpp (original)
+++ cfe/trunk/Driver/ASTConsumers.cpp Fri Jan  9 09:36:25 2009
@@ -306,8 +306,8 @@
     Out << "}\n";
   }
   
-  for (ObjCInterfaceDecl::classprop_iterator I = OID->classprop_begin(),
-       E = OID->classprop_end(); I != E; ++I)
+  for (ObjCInterfaceDecl::prop_iterator I = OID->prop_begin(),
+       E = OID->prop_end(); I != E; ++I)
     PrintObjCPropertyDecl(*I);
   bool eol_needed = false;
   for (ObjCInterfaceDecl::classmeth_iterator I = OID->classmeth_begin(),
@@ -325,8 +325,8 @@
 void DeclPrinter::PrintObjCProtocolDecl(ObjCProtocolDecl *PID) {
   Out << "@protocol " << PID->getNameAsString() << '\n';
   
-  for (ObjCProtocolDecl::classprop_iterator I = PID->classprop_begin(),
-       E = PID->classprop_end(); I != E; ++I)
+  for (ObjCProtocolDecl::prop_iterator I = PID->prop_begin(),
+       E = PID->prop_end(); I != E; ++I)
     PrintObjCPropertyDecl(*I);
   Out << "@end\n";
   // FIXME: implement the rest...
@@ -348,8 +348,8 @@
       << PID->getClassInterface()->getNameAsString()
       << '(' << PID->getNameAsString() << ");\n";
   // Output property declarations.
-  for (ObjCCategoryDecl::classprop_iterator I = PID->classprop_begin(),
-       E = PID->classprop_end(); I != E; ++I)
+  for (ObjCCategoryDecl::prop_iterator I = PID->prop_begin(),
+       E = PID->prop_end(); I != E; ++I)
     PrintObjCPropertyDecl(*I);
   Out << "@end\n";
   

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

==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Fri Jan  9 09:36:25 2009
@@ -81,10 +81,10 @@
   	         NonTypeTemplateParm,
              LinkageSpec, // [DeclContext]
              ObjCMethod,  // [DeclContext]
-    //       ObjCContainerDecl // [DeclContext]
-               ObjCCategory,
-               ObjCProtocol,
-               ObjCInterface,
+           ObjCContainer, // [DeclContext]
+             ObjCCategory,
+             ObjCProtocol,
+             ObjCInterface,
              ObjCCategoryImpl,  // [DeclContext]
              ObjCImplementation, // [DeclContext]
              ObjCProperty,
@@ -97,15 +97,16 @@
   
     // For each non-leaf class, we now define a mapping to the first/last member
     // of the class, to allow efficient classof.
-    NamedFirst     = OverloadedFunction , NamedLast     = ObjCPropertyImpl,
-    FieldFirst     = Field        , FieldLast     = ObjCAtDefsField,
-    ScopedFirst    = Field        , ScopedLast    = ObjCPropertyImpl,
-    TypeFirst      = Typedef      , TypeLast      = TemplateTypeParm,
-    TagFirst       = Enum         , TagLast       = CXXRecord,
-    RecordFirst    = Record       , RecordLast    = CXXRecord,
-    ValueFirst     = EnumConstant , ValueLast     = NonTypeTemplateParm,
-    FunctionFirst  = Function     , FunctionLast  = CXXConversion,
-    VarFirst       = Var          , VarLast       = NonTypeTemplateParm
+    NamedFirst    = OverloadedFunction, NamedLast   = NonTypeTemplateParm,
+    ObjCContainerFirst = ObjCContainer, ObjCContainerLast = ObjCInterface,
+    FieldFirst         = Field        , FieldLast     = ObjCAtDefsField,
+    ScopedFirst        = Field        , ScopedLast    = ObjCPropertyImpl,
+    TypeFirst          = Typedef      , TypeLast      = TemplateTypeParm,
+    TagFirst           = Enum         , TagLast       = CXXRecord,
+    RecordFirst        = Record       , RecordLast    = CXXRecord,
+    ValueFirst         = EnumConstant , ValueLast     = NonTypeTemplateParm,
+    FunctionFirst      = Function     , FunctionLast  = CXXConversion,
+    VarFirst           = Var          , VarLast       = NonTypeTemplateParm
   };
 
   /// IdentifierNamespace - According to C99 6.2.3, there are four namespaces,

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

==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Fri Jan  9 09:36:25 2009
@@ -248,22 +248,46 @@
 /// Current sub-classes are ObjCInterfaceDecl, ObjCCategoryDecl, and
 /// ObjCProtocolDecl. 
 /// FIXME: Use for ObjC implementation decls.
-/// FIXME: Consider properties.
 /// FIXME: It would be nice to reduce amount of "boilerplate" iterator code
 /// below. For now, the iterators are modeled after RecordDecl::field_iterator().
 /// If DeclContext ends up providing some support for creating more strongly 
 /// typed iterators, the code below should be reduced considerably.
+/// FIXME: Convert property implementation to DeclContext::addDecl(). Holding
+/// off until we have an iterator adaptor that plays with DeclContext.
 ///
 class ObjCContainerDecl : public ScopedDecl, public DeclContext {
+  /// class properties
+  ObjCPropertyDecl **PropertyDecl;  // Null if no property
+  unsigned NumPropertyDecl;  // 0 if none.
+  
   SourceLocation AtEndLoc; // marks the end of the method container.
 public:
 
   ObjCContainerDecl(Kind DK, DeclContext *DC, SourceLocation L, 
                     IdentifierInfo *Id)
-    : ScopedDecl(DK, DC, L, Id), DeclContext(DK) {}
+    : ScopedDecl(DK, DC, L, Id), DeclContext(DK),
+      PropertyDecl(0), NumPropertyDecl(0) {}
 
   virtual ~ObjCContainerDecl();
+
+  void addProperties(ObjCPropertyDecl **Properties, unsigned NumProperties);
+  
+  // FIXME: Replace with appropriate lookup. Currently used by interfaces and
+  // categories.
+  void mergeProperties(ObjCPropertyDecl **Properties, unsigned NumProperties);
+  
+  typedef ObjCPropertyDecl * const * prop_iterator;
+  prop_iterator prop_begin() const { return PropertyDecl; }
+  prop_iterator prop_end() const {
+    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.
   class method_iterator {
   public:
@@ -420,13 +444,27 @@
   ObjCMethodDecl *getInstanceMethod(Selector Sel) const;
   ObjCMethodDecl *getClassMethod(Selector Sel) const;
   
-  // Get the number of instance/class methods.
+  // Get the number of instance/class methods. These methods are slow, O(n).
   unsigned getNumInstanceMethods() const;
   unsigned getNumClassMethods() const;
   
   // Marks the end of the container.
   SourceLocation getAtEndLoc() const { return AtEndLoc; }
   void setAtEndLoc(SourceLocation L) { AtEndLoc = L; }
+  
+  // Implement isa/cast/dyncast/etc.
+  static bool classof(const Decl *D) {
+    return D->getKind() >= ObjCContainerFirst && 
+           D->getKind() <= ObjCContainerLast;
+  }
+  static bool classof(const ObjCContainerDecl *D) { return true; }
+
+  static DeclContext *castToDeclContext(const ObjCContainerDecl *D) {
+    return static_cast<DeclContext *>(const_cast<ObjCContainerDecl*>(D));
+  }
+  static ObjCContainerDecl *castFromDeclContext(const DeclContext *DC) {
+    return static_cast<ObjCContainerDecl *>(const_cast<DeclContext*>(DC));
+  }
 };
 
 /// ObjCInterfaceDecl - Represents an ObjC class declaration. For example:
@@ -469,10 +507,6 @@
   /// List of categories defined for this class.
   ObjCCategoryDecl *CategoryList;
     
-  /// class properties
-  ObjCPropertyDecl **PropertyDecl;  // Null if no property
-  unsigned NumPropertyDecl;  // 0 if none.
-  
   bool ForwardDecl:1; // declared with @class.
   bool InternalInterface:1; // true - no @interface for @implementation
   
@@ -485,7 +519,7 @@
     : ObjCContainerDecl(ObjCInterface, DC, atLoc, Id),
       TypeForDecl(0), SuperClass(0),
       Ivars(0), NumIvars(0),
-      CategoryList(0), PropertyDecl(0), NumPropertyDecl(0),
+      CategoryList(0), 
       ForwardDecl(FD), InternalInterface(isInternal),
       ClassLoc(CLoc) {
       }
@@ -507,7 +541,6 @@
     return ReferencedProtocols; 
   }
   
-  ObjCPropertyDecl *FindPropertyDeclaration(IdentifierInfo *PropertyId) const;
   ObjCCategoryDecl *FindCategoryDeclaration(IdentifierInfo *CategoryId) const;
   ObjCIvarDecl *FindIvarDeclaration(IdentifierInfo *IvarId) const;
   bool isPropertyReadonly(ObjCPropertyDecl *PropertyDecl) const;
@@ -533,16 +566,6 @@
   FieldDecl *lookupFieldDeclForIvar(ASTContext &Context, 
                                     const ObjCIvarDecl *ivar);
 
-  void addProperties(ObjCPropertyDecl **Properties, unsigned NumProperties);
-  
-  void mergeProperties(ObjCPropertyDecl **Properties, unsigned NumProperties);
-  
-  typedef ObjCPropertyDecl * const * classprop_iterator;
-  classprop_iterator classprop_begin() const { return PropertyDecl; }
-  classprop_iterator classprop_end() const {
-    return PropertyDecl+NumPropertyDecl;
-  }
-  
   bool isForwardDecl() const { return ForwardDecl; }
   void setForwardDecl(bool val) { ForwardDecl = val; }
   
@@ -587,11 +610,6 @@
   void setSuperClassLoc(SourceLocation Loc) { SuperClassLoc = Loc; }
   SourceLocation getSuperClassLoc() const { return SuperClassLoc; }
     
-  unsigned getNumPropertyDecl() const { return NumPropertyDecl; }
-  
-  ObjCPropertyDecl * const * getPropertyDecl() const { return PropertyDecl; }
-  ObjCPropertyDecl **getPropertyDecl() { return PropertyDecl; }
-
   /// ImplicitInterfaceDecl - check that this is an implicitely declared
   /// ObjCInterfaceDecl node. This is for legacy objective-c @implementation
   /// declaration without an @interface declaration.
@@ -743,21 +761,6 @@
     ReferencedProtocols.set(List, NumRPs);
   }
   
-  ObjCPropertyDecl *FindPropertyDeclaration(IdentifierInfo *PropertyId) const;
-  
-  unsigned getNumPropertyDecl() const { return NumPropertyDecl; }
-  
-  ObjCPropertyDecl * const * getPropertyDecl() const { return PropertyDecl; }
-  ObjCPropertyDecl **getPropertyDecl() { return PropertyDecl; }
-  
-  void addProperties(ObjCPropertyDecl **Properties, unsigned NumProperties);
-
-  typedef ObjCPropertyDecl * const * classprop_iterator;
-  classprop_iterator classprop_begin() const { return PropertyDecl; }
-  classprop_iterator classprop_end() const {
-    return PropertyDecl+NumPropertyDecl;
-  }
-
   // Lookup a method. First, we search locally. If a method isn't
   // found, we search referenced protocols and class categories.
   ObjCMethodDecl *lookupInstanceMethod(Selector Sel);
@@ -944,22 +947,6 @@
   protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();}
   protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
   
-  unsigned getNumPropertyDecl() const { return NumPropertyDecl; }
-  
-  ObjCPropertyDecl * const * getPropertyDecl() const { return PropertyDecl; }
-  
-  void addProperties(ObjCPropertyDecl **Properties, unsigned NumProperties);
-
-  void mergeProperties(ObjCPropertyDecl **Properties, unsigned NumProperties);
-
-  ObjCPropertyDecl *FindPropertyDeclaration(IdentifierInfo *PropertyId) const;
-  
-  typedef ObjCPropertyDecl * const * classprop_iterator;
-  classprop_iterator classprop_begin() const { return PropertyDecl; }
-  classprop_iterator classprop_end() const {
-    return PropertyDecl+NumPropertyDecl;
-  }
-    
   ObjCCategoryDecl *getNextClassCategory() const { return NextClassCategory; }
   void insertNextClassCategory() {
     NextClassCategory = ClassInterface->getCategoryList();

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

==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Fri Jan  9 09:36:25 2009
@@ -224,6 +224,7 @@
   case Field:               nFieldDecls++; break;
   case Record:              nSUC++; break;
   case Enum:                nEnumDecls++; break;
+  case ObjCContainer:       break; // is abstract...no need to account for.
   case ObjCInterface:       nInterfaceDecls++; break;
   case ObjCClass:           nClassDecls++; break;
   case ObjCMethod:          nMethodDecls++; break;

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

==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Fri Jan  9 09:36:25 2009
@@ -62,11 +62,11 @@
 }
 
 ObjCContainerDecl::~ObjCContainerDecl() {
+  delete [] PropertyDecl;
 }
 
 ObjCInterfaceDecl::~ObjCInterfaceDecl() {
   delete [] Ivars;
-  delete [] PropertyDecl;
   // FIXME: CategoryList?
 }
 
@@ -274,37 +274,6 @@
   return true;
 }
 
-/// FindPropertyDeclaration - Finds declaration of the property given its name
-/// in 'PropertyId' and returns it. It returns 0, if not found.
-///
-ObjCPropertyDecl *
-  ObjCInterfaceDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const {
-  for (ObjCInterfaceDecl::classprop_iterator I = classprop_begin(),
-       E = classprop_end(); I != E; ++I) {
-    ObjCPropertyDecl *property = *I;
-    if (property->getIdentifier() == PropertyId)
-      return property;
-  }
-  // Look through categories.
-  for (ObjCCategoryDecl *Category = getCategoryList();
-       Category; Category = Category->getNextClassCategory()) {
-    ObjCPropertyDecl *property = Category->FindPropertyDeclaration(PropertyId);
-    if (property)
-      return property;
-  }
-  // Look through protocols.
-  for (ObjCInterfaceDecl::protocol_iterator I = protocol_begin(),
-       E = protocol_end(); I != E; ++I) {
-    ObjCProtocolDecl *Protocol = *I;
-    ObjCPropertyDecl *property = Protocol->FindPropertyDeclaration(PropertyId);
-    if (property)
-      return property;
-  }
-  if (getSuperClass())
-    return getSuperClass()->FindPropertyDeclaration(PropertyId);
-  return 0;
-}
-
 /// FindCategoryDeclaration - Finds category declaration in the list of
 /// categories for this class and returns it. Name of the category is passed
 /// in 'CategoryId'. If category not found, return 0;
@@ -377,43 +346,6 @@
   }
 }
 
-/// addProperties - Insert property declaration AST nodes into
-/// ObjCInterfaceDecl's PropertyDecl field.
-///
-void ObjCInterfaceDecl::addProperties(ObjCPropertyDecl **Properties, 
-                                      unsigned NumProperties) {
-  if (NumProperties == 0) return;
-  
-  NumPropertyDecl = NumProperties;
-  PropertyDecl = new ObjCPropertyDecl*[NumProperties];
-  memcpy(PropertyDecl, Properties, NumProperties*sizeof(ObjCPropertyDecl*));
-}                                   
-
-/// mergeProperties - Adds properties to the end of list of current properties
-/// for this class.
-
-void ObjCInterfaceDecl::mergeProperties(ObjCPropertyDecl **Properties, 
-                                        unsigned NumNewProperties) {
-  if (NumNewProperties == 0) return;
-  
-  if (PropertyDecl) {
-    ObjCPropertyDecl **newPropertyDecl =  
-      new ObjCPropertyDecl*[NumNewProperties + NumPropertyDecl];
-    ObjCPropertyDecl **buf = newPropertyDecl;
-    // put back original properties in buffer.
-    memcpy(buf, PropertyDecl, NumPropertyDecl*sizeof(ObjCPropertyDecl*));
-    // Add new properties to this buffer.
-    memcpy(buf+NumPropertyDecl, Properties, 
-           NumNewProperties*sizeof(ObjCPropertyDecl*));
-    delete[] PropertyDecl;
-    PropertyDecl = newPropertyDecl;
-    NumPropertyDecl += NumNewProperties;
-  }
-  else {
-    addProperties(Properties, NumNewProperties);
-  }
-}
-
 // Get the local instance method declared in this interface.
 // FIXME: handle overloading, instance & class methods can have the same name.
 ObjCMethodDecl *ObjCContainerDecl::getInstanceMethod(Selector Sel) const {
@@ -447,9 +379,9 @@
 }
 
 /// mergeProperties - Adds properties to the end of list of current properties
-/// for this category.
+/// for this class.
 
-void ObjCCategoryDecl::mergeProperties(ObjCPropertyDecl **Properties, 
+void ObjCContainerDecl::mergeProperties(ObjCPropertyDecl **Properties, 
                                         unsigned NumNewProperties) {
   if (NumNewProperties == 0) return;
   
@@ -472,22 +404,10 @@
 }
 
 /// addProperties - Insert property declaration AST nodes into
-/// ObjCProtocolDecl's PropertyDecl field.
-///
-void ObjCProtocolDecl::addProperties(ObjCPropertyDecl **Properties, 
-                                     unsigned NumProperties) {
-  if (NumProperties == 0) return;
-  
-  NumPropertyDecl = NumProperties;
-  PropertyDecl = new ObjCPropertyDecl*[NumProperties];
-  memcpy(PropertyDecl, Properties, NumProperties*sizeof(ObjCPropertyDecl*));
-}
-
-/// addProperties - Insert property declaration AST nodes into
-/// ObjCCategoryDecl's PropertyDecl field.
+/// ObjCContainerDecl's PropertyDecl field.
 ///
-void ObjCCategoryDecl::addProperties(ObjCPropertyDecl **Properties, 
-                                     unsigned NumProperties) {
+void ObjCContainerDecl::addProperties(ObjCPropertyDecl **Properties, 
+                                      unsigned NumProperties) {
   if (NumProperties == 0) return;
   
   NumPropertyDecl = NumProperties;
@@ -499,26 +419,31 @@
 /// in 'PropertyId' and returns it. It returns 0, if not found.
 ///
 ObjCPropertyDecl *
-ObjCCategoryDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const {
-  for (ObjCCategoryDecl::classprop_iterator I = classprop_begin(),
-       E = classprop_end(); I != E; ++I) {
+ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const {
+  for (prop_iterator I = prop_begin(), E = prop_end(); I != E; ++I) {
     ObjCPropertyDecl *property = *I;
     if (property->getIdentifier() == PropertyId)
       return property;
   }
-  return 0;
-}
-
-/// FindPropertyDeclaration - Finds declaration of the property given its name
-/// in 'PropertyId' and returns it. It returns 0, if not found.
-///
-ObjCPropertyDecl *
-ObjCProtocolDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const {
-  for (ObjCProtocolDecl::classprop_iterator I = classprop_begin(),
-       E = classprop_end(); I != E; ++I) {
-    ObjCPropertyDecl *property = *I;
-    if (property->getIdentifier() == PropertyId)
-      return property;
+  const ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(this);
+  if (OID) {
+    // Look through categories.
+    for (ObjCCategoryDecl *Category = OID->getCategoryList();
+         Category; Category = Category->getNextClassCategory()) {
+      ObjCPropertyDecl *property = Category->FindPropertyDeclaration(PropertyId);
+      if (property)
+        return property;
+    }
+    // Look through protocols.
+    for (ObjCInterfaceDecl::protocol_iterator I = OID->protocol_begin(),
+         E = OID->protocol_end(); I != E; ++I) {
+      ObjCProtocolDecl *Protocol = *I;
+      ObjCPropertyDecl *property = Protocol->FindPropertyDeclaration(PropertyId);
+      if (property)
+        return property;
+    }
+    if (OID->getSuperClass())
+      return OID->getSuperClass()->FindPropertyDeclaration(PropertyId);
   }
   return 0;
 }

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

==============================================================================
--- cfe/trunk/lib/AST/TranslationUnit.cpp (original)
+++ cfe/trunk/lib/AST/TranslationUnit.cpp Fri Jan  9 09:36:25 2009
@@ -46,8 +46,8 @@
       //  eventually be fixed when the ownership of ObjCPropertyDecls gets
       //  cleaned up.
       if (ObjCInterfaceDecl* IDecl = dyn_cast<ObjCInterfaceDecl>(*I))
-        for (ObjCInterfaceDecl::classprop_iterator ID=IDecl->classprop_begin(),
-             ED=IDecl->classprop_end(); ID!=ED; ++ID) {
+        for (ObjCInterfaceDecl::prop_iterator ID=IDecl->prop_begin(),
+             ED=IDecl->prop_end(); ID!=ED; ++ID) {
           if (!*ID || Killed.count(*ID)) continue;
           Killed.insert(*ID);
           (*ID)->Destroy(*Context);
@@ -59,8 +59,8 @@
       //  eventually be fixed when the ownership of ObjCPropertyDecls gets
       //  cleaned up.
       if (ObjCProtocolDecl* PDecl = dyn_cast<ObjCProtocolDecl>(*I))
-        for (ObjCProtocolDecl::classprop_iterator ID=PDecl->classprop_begin(),
-             ED=PDecl->classprop_end(); ID!=ED; ++ID) {
+        for (ObjCProtocolDecl::prop_iterator ID=PDecl->prop_begin(),
+             ED=PDecl->prop_end(); ID!=ED; ++ID) {
           if (!*ID || Killed.count(*ID)) continue;
           Killed.insert(*ID);
           (*ID)->Destroy(*Context);

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=61988&r1=61987&r2=61988&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Fri Jan  9 09:36:25 2009
@@ -782,8 +782,8 @@
   Values[3] = EmitPropertyList("\01L_OBJC_$_PROP_PROTO_LIST_" + 
                                    PD->getNameAsString(),
                                0,
-                               PD->classprop_begin(),
-                               PD->classprop_end());
+                               PD->prop_begin(),
+                               PD->prop_end());
 
   // Return null if no extension bits are used.
   if (Values[1]->isNullValue() && Values[2]->isNullValue() && 
@@ -1002,8 +1002,8 @@
   if (Category) {
     Values[6] = EmitPropertyList(std::string("\01L_OBJC_$_PROP_LIST_") + ExtName,
                                  OCD,
-                                 Category->classprop_begin(),
-                                 Category->classprop_end());
+                                 Category->prop_begin(),
+                                 Category->prop_end());
   } else {
     Values[6] = llvm::Constant::getNullValue(ObjCTypes.PropertyListPtrTy);
   }
@@ -1279,8 +1279,8 @@
   Values[1] = llvm::Constant::getNullValue(ObjCTypes.Int8PtrTy);
   Values[2] = EmitPropertyList("\01L_OBJC_$_PROP_LIST_" + ID->getNameAsString(),
                                ID,
-                               ID->getClassInterface()->classprop_begin(),
-                               ID->getClassInterface()->classprop_end());
+                               ID->getClassInterface()->prop_begin(),
+                               ID->getClassInterface()->prop_end());
 
   // Return null if no extension bits are used.
   if (Values[1]->isNullValue() && Values[2]->isNullValue())

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=61988&r1=61987&r2=61988&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Jan  9 09:36:25 2009
@@ -320,12 +320,12 @@
   if (!SDecl)
     return;
   // FIXME: O(N^2)
-  for (ObjCInterfaceDecl::classprop_iterator S = SDecl->classprop_begin(),
-       E = SDecl->classprop_end(); S != E; ++S) {
+  for (ObjCInterfaceDecl::prop_iterator S = SDecl->prop_begin(),
+       E = SDecl->prop_end(); S != E; ++S) {
     ObjCPropertyDecl *SuperPDecl = (*S);
     // Does property in super class has declaration in current class?
-    for (ObjCInterfaceDecl::classprop_iterator I = IDecl->classprop_begin(),
-         E = IDecl->classprop_end(); I != E; ++I) {
+    for (ObjCInterfaceDecl::prop_iterator I = IDecl->prop_begin(),
+         E = IDecl->prop_end(); I != E; ++I) {
       ObjCPropertyDecl *PDecl = (*I);
       if (SuperPDecl->getIdentifier() == PDecl->getIdentifier())
           DiagnosePropertyMismatch(PDecl, SuperPDecl, 
@@ -346,12 +346,12 @@
     // Category
     ObjCCategoryDecl *CatDecl = static_cast<ObjCCategoryDecl*>(CDecl);
     assert (CatDecl && "MergeOneProtocolPropertiesIntoClass");
-    for (ObjCProtocolDecl::classprop_iterator P = PDecl->classprop_begin(),
-         E = PDecl->classprop_end(); P != E; ++P) {
+    for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(),
+         E = PDecl->prop_end(); P != E; ++P) {
       ObjCPropertyDecl *Pr = (*P);
-      ObjCCategoryDecl::classprop_iterator CP, CE;
+      ObjCCategoryDecl::prop_iterator CP, CE;
       // Is this property already in  category's list of properties?
-      for (CP = CatDecl->classprop_begin(), CE = CatDecl->classprop_end(); 
+      for (CP = CatDecl->prop_begin(), CE = CatDecl->prop_end(); 
            CP != CE; ++CP)
         if ((*CP)->getIdentifier() == Pr->getIdentifier())
           break;
@@ -365,12 +365,12 @@
     CatDecl->mergeProperties(&mergeProperties[0], mergeProperties.size());
     return;
   }
-  for (ObjCProtocolDecl::classprop_iterator P = PDecl->classprop_begin(),
-       E = PDecl->classprop_end(); P != E; ++P) {
+  for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(),
+       E = PDecl->prop_end(); P != E; ++P) {
     ObjCPropertyDecl *Pr = (*P);
-    ObjCInterfaceDecl::classprop_iterator CP, CE;
+    ObjCInterfaceDecl::prop_iterator CP, CE;
     // Is this property already in  class's list of properties?
-    for (CP = IDecl->classprop_begin(), CE = IDecl->classprop_end(); 
+    for (CP = IDecl->prop_begin(), CE = IDecl->prop_end(); 
          CP != CE; ++CP)
       if ((*CP)->getIdentifier() == Pr->getIdentifier())
         break;
@@ -1153,19 +1153,13 @@
         isa<ObjCInterfaceDecl>(ClassDecl) || isa<ObjCCategoryDecl>(ClassDecl)
          || isa<ObjCProtocolDecl>(ClassDecl);
   bool checkIdenticalMethods = isa<ObjCImplementationDecl>(ClassDecl);
-  
-  
+
   if (pNum != 0) {
-    if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(ClassDecl))
-      IDecl->addProperties((ObjCPropertyDecl**)allProperties, pNum);
-    else if (ObjCCategoryDecl *CDecl = dyn_cast<ObjCCategoryDecl>(ClassDecl))
+    if (ObjCContainerDecl *CDecl = dyn_cast<ObjCContainerDecl>(ClassDecl))
       CDecl->addProperties((ObjCPropertyDecl**)allProperties, pNum);
-    else if (ObjCProtocolDecl *PDecl = dyn_cast<ObjCProtocolDecl>(ClassDecl))
-      PDecl->addProperties((ObjCPropertyDecl**)allProperties, pNum);
     else
       assert(false && "ActOnAtEnd - property declaration misplaced");
   }
-
   DeclContext *DC = dyn_cast<DeclContext>(ClassDecl);
   assert(DC && "Missing DeclContext");
 
@@ -1218,38 +1212,29 @@
     // super class.
     ComparePropertiesInBaseAndSuper(I);
     MergeProtocolPropertiesIntoClass(I, I);
-    for (ObjCInterfaceDecl::classprop_iterator i = I->classprop_begin(),
-         e = I->classprop_end(); i != e; ++i) {
-      ProcessPropertyDecl((*i), I);
-    }
-    I->setAtEndLoc(AtEndLoc);
-  } else if (ObjCProtocolDecl *P = dyn_cast<ObjCProtocolDecl>(ClassDecl)) {
-    for (ObjCProtocolDecl::classprop_iterator i = P->classprop_begin(),
-         e = P->classprop_end(); i != e; ++i) {
-      ProcessPropertyDecl((*i), P);
-    }
-    P->setAtEndLoc(AtEndLoc);
-  }
-  else if (ObjCCategoryDecl *C = dyn_cast<ObjCCategoryDecl>(ClassDecl)) {
+  } else if (ObjCCategoryDecl *C = dyn_cast<ObjCCategoryDecl>(ClassDecl)) {
     // Categories are used to extend the class by declaring new methods.
     // By the same token, they are also used to add new properties. No 
     // need to compare the added property to those in the class.
 
     // Merge protocol properties into category
     MergeProtocolPropertiesIntoClass(C, C);
-    for (ObjCCategoryDecl::classprop_iterator i = C->classprop_begin(),
-         e = C->classprop_end(); i != e; ++i) {
-      ProcessPropertyDecl((*i), C);
-    }
-    C->setAtEndLoc(AtEndLoc);
   }
-  else if (ObjCImplementationDecl *IC = 
-                dyn_cast<ObjCImplementationDecl>(ClassDecl)) {
+  if (ObjCContainerDecl *CDecl = dyn_cast<ObjCContainerDecl>(ClassDecl)) {
+    // ProcessPropertyDecl is responsible for diagnosing conflicts with any
+    // user-defined setter/getter. It also synthesizes setter/getter methods
+    // and adds them to the DeclContext and global method pools.
+    for (ObjCContainerDecl::prop_iterator i = CDecl->prop_begin(),
+                                          e = CDecl->prop_end(); i != e; ++i)
+      ProcessPropertyDecl((*i), CDecl);
+    CDecl->setAtEndLoc(AtEndLoc);
+  }
+  if (ObjCImplementationDecl *IC=dyn_cast<ObjCImplementationDecl>(ClassDecl)) {
     IC->setLocEnd(AtEndLoc);
     if (ObjCInterfaceDecl* IDecl = getObjCInterfaceDecl(IC->getIdentifier()))
       ImplMethodsVsClassMethods(IC, IDecl);
-  } else {
-    ObjCCategoryImplDecl* CatImplClass = cast<ObjCCategoryImplDecl>(ClassDecl);
+  } else if (ObjCCategoryImplDecl* CatImplClass = 
+                                   dyn_cast<ObjCCategoryImplDecl>(ClassDecl)) {
     CatImplClass->setLocEnd(AtEndLoc);
     ObjCInterfaceDecl* IDecl = CatImplClass->getClassInterface();
     // Find category interface decl and then check that all methods declared





More information about the cfe-commits mailing list