]> granicus.if.org Git - clang/commitdiff
This patch removes mergeProperties and does the property lookup
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 9 Jan 2009 21:04:52 +0000 (21:04 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 9 Jan 2009 21:04:52 +0000 (21:04 +0000)
in designated protocols lazily.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62007 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclObjC.h
lib/AST/DeclObjC.cpp
lib/Sema/SemaDeclObjC.cpp
test/SemaObjC/property-4.m

index c9c8958981e86a84afca7d06a178c379f25a3863..561a0142e9bfdad2c62a73e68cc976fb55ec65be 100644 (file)
@@ -270,10 +270,6 @@ public:
 
   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 {
@@ -640,7 +636,7 @@ public:
   // found, we search referenced protocols and class categories.
   ObjCMethodDecl *lookupInstanceMethod(Selector Sel);
   ObjCMethodDecl *lookupClassMethod(Selector Sel);
-  
+
   bool isForwardDecl() const { return isForwardProtoDecl; }
   void setForwardDecl(bool val) { isForwardProtoDecl = val; }
 
index 98d7164ba35e9dafb5e70de5f7b57afba7373a71..56da9a6dfa9e4cc3acc0de12f5f898f5c9a183ee 100644 (file)
@@ -378,31 +378,6 @@ unsigned ObjCContainerDecl::getNumClassMethods() const {
   return sum;
 }
 
-/// mergeProperties - Adds properties to the end of list of current properties
-/// for this class.
-
-void ObjCContainerDecl::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);
-  }
-}
-
 /// addProperties - Insert property declaration AST nodes into
 /// ObjCContainerDecl's PropertyDecl field.
 ///
@@ -425,6 +400,16 @@ ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const {
     if (property->getIdentifier() == PropertyId)
       return property;
   }
+  const ObjCProtocolDecl *PID = dyn_cast<ObjCProtocolDecl>(this);
+  if (PID) {
+    for (ObjCProtocolDecl::protocol_iterator P = PID->protocol_begin(), 
+         E = PID->protocol_end(); 
+         P != E; ++P)
+      if (ObjCPropertyDecl *property = 
+            (*P)->FindPropertyDeclaration(PropertyId))
+        return property;
+  }
+  
   const ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(this);
   if (OID) {
     // Look through categories.
index 49a8c835c5c058455a3da9592e971244f9ac4558..d47f98af25f9acaee6a9d41476ee3702dea2e1f4 100644 (file)
@@ -340,7 +340,6 @@ Sema::ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl *IDecl) {
 void
 Sema::MergeOneProtocolPropertiesIntoClass(Decl *CDecl,
                                           ObjCProtocolDecl *PDecl) {
-  llvm::SmallVector<ObjCPropertyDecl*, 16> mergeProperties;
   ObjCInterfaceDecl *IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(CDecl);
   if (!IDecl) {
     // Category
@@ -355,14 +354,10 @@ Sema::MergeOneProtocolPropertiesIntoClass(Decl *CDecl,
            CP != CE; ++CP)
         if ((*CP)->getIdentifier() == Pr->getIdentifier())
           break;
-      if (CP == CE)
-        // Add this property to list of properties for thie class.
-        mergeProperties.push_back(Pr);
-      else
+      if (CP != CE)
         // Property protocol already exist in class. Diagnose any mismatch.
         DiagnosePropertyMismatch((*CP), Pr, PDecl->getIdentifier());
     }
-    CatDecl->mergeProperties(&mergeProperties[0], mergeProperties.size());
     return;
   }
   for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(),
@@ -374,14 +369,10 @@ Sema::MergeOneProtocolPropertiesIntoClass(Decl *CDecl,
          CP != CE; ++CP)
       if ((*CP)->getIdentifier() == Pr->getIdentifier())
         break;
-    if (CP == CE)
-      // Add this property to list of properties for thie class.
-      mergeProperties.push_back(Pr);
-    else
+    if (CP != CE)
       // Property protocol already exist in class. Diagnose any mismatch.
       DiagnosePropertyMismatch((*CP), Pr, PDecl->getIdentifier());
     }
-  IDecl->mergeProperties(&mergeProperties[0], mergeProperties.size());
 }
 
 /// MergeProtocolPropertiesIntoClass - This routine merges properties
index 0fcc67d05d0d0e71a196c54b797c6b89d244fe37..b3000967fc1d2db6d29d39bde8917871a97addb7 100644 (file)
@@ -24,7 +24,6 @@
    int newO;
    int oldO;
 }
-@property (retain) id MayCauseError;  // expected-warning {{property 'MayCauseError' 'copy' attribute does not match the property inherited from 'GCObject'}} \
-                                     expected-warning {{property 'MayCauseError' 'copy' attribute does not match the property inherited from 'ProtocolObject'}}
+@property (retain) id MayCauseError;  // expected-warning {{property 'MayCauseError' 'copy' attribute does not match the property inherited from 'ProtocolObject'}}
 @end