[cfe-commits] r68259 - in /cfe/trunk: lib/AST/DeclObjC.cpp lib/Sema/SemaDeclObjC.cpp test/CodeGenObjC/synthesize_ivar-cont-class.m

Fariborz Jahanian fjahanian at apple.com
Wed Apr 1 16:23:55 PDT 2009


Author: fjahanian
Date: Wed Apr  1 18:23:53 2009
New Revision: 68259

URL: http://llvm.org/viewvc/llvm-project?rev=68259&view=rev
Log:
Fix a bug in declaration of property in continuation
class which was exposed by implementation of 
objc2's nonfragile abi code gen.

Added:
    cfe/trunk/test/CodeGenObjC/synthesize_ivar-cont-class.m
Modified:
    cfe/trunk/lib/AST/DeclObjC.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

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

==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Wed Apr  1 18:23:53 2009
@@ -91,6 +91,16 @@
   for (prop_iterator I = prop_begin(), E = prop_end(); I != E; ++I)
     if ((*I)->getIdentifier() == PropertyId)
       return *I;
+  // Also look for property declared in its continuation class.
+  if (const ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(this))
+    for (ObjCCategoryDecl *Categories = OID->getCategoryList();
+         Categories; Categories = Categories->getNextClassCategory())
+      if (!Categories->getIdentifier()) {
+        for (ObjCInterfaceDecl::prop_iterator I = Categories->prop_begin(),
+             E = Categories->prop_end(); I != E; ++I)
+          if ((*I)->getIdentifier() == PropertyId)
+            return *I;
+      }
   
   const ObjCProtocolDecl *PID = dyn_cast<ObjCProtocolDecl>(this);
   if (PID) {

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Apr  1 18:23:53 2009
@@ -1596,28 +1596,26 @@
   // May modify Attributes.
   CheckObjCPropertyAttributes(T, AtLoc, Attributes);
   
+  ObjCMethodDecl *SetterDecl = 0;
   if (ObjCCategoryDecl *CDecl = dyn_cast<ObjCCategoryDecl>(ClassDecl))
     if (!CDecl->getIdentifier()) {
-      // This is an anonymous category. property requires special 
+      // This is a continuation class. property requires special 
       // handling.
       if (ObjCInterfaceDecl *ICDecl = CDecl->getClassInterface()) {
         if (ObjCPropertyDecl *PIDecl =
             ICDecl->FindPropertyDeclaration(FD.D.getIdentifier())) {
           // property 'PIDecl's readonly attribute will be over-ridden
-          // with anonymous category's readwrite property attribute!
+          // with continuation class's readwrite property attribute!
           unsigned PIkind = PIDecl->getPropertyAttributes();
           if (isReadWrite && (PIkind & ObjCPropertyDecl::OBJC_PR_readonly)) {
             if ((Attributes & ObjCPropertyDecl::OBJC_PR_nonatomic) !=
                 (PIkind & ObjCPropertyDecl::OBJC_PR_nonatomic))
               Diag(AtLoc, diag::warn_property_attr_mismatch);
-            PIDecl->makeitReadWriteAttribute();
-            if (Attributes & ObjCDeclSpec::DQ_PR_retain)
-              PIDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_retain);
-            if (Attributes & ObjCDeclSpec::DQ_PR_copy)
-              PIDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_copy);
-            PIDecl->setSetterName(SetterSel);
+            // Make the continuation class property attribute Read/Write
+            Attributes &= ~ObjCPropertyDecl::OBJC_PR_readonly;
+            Attributes |= ObjCPropertyDecl::OBJC_PR_readwrite;    
             // FIXME: use a common routine with addPropertyMethods.
-            ObjCMethodDecl *SetterDecl =
+            SetterDecl =
               ObjCMethodDecl::Create(Context, AtLoc, AtLoc, SetterSel,
                                      Context.VoidTy,
                                      ICDecl,
@@ -1628,12 +1626,13 @@
                                                         FD.D.getIdentifier(),
                                                         T, VarDecl::None, 0);
             SetterDecl->setMethodParams(&Argument, 1, Context);
-            PIDecl->setSetterMethodDecl(SetterDecl);
           }
-          else
-            Diag(AtLoc, diag::err_use_continuation_class) << ICDecl->getDeclName();
-          *isOverridingProperty = true;
-          return DeclPtrTy();
+          else {
+            Diag(AtLoc, 
+                 diag::err_use_continuation_class) << ICDecl->getDeclName();
+            *isOverridingProperty = true;
+            return DeclPtrTy();
+          }
         }
         // No matching property found in the main class. Just fall thru
         // and add property to the anonymous category. It looks like
@@ -1660,6 +1659,7 @@
 
   // Regardless of setter/getter attribute, we save the default getter/setter
   // selector names in anticipation of declaration of setter/getter methods.
+  PDecl->setSetterMethodDecl(SetterDecl);
   PDecl->setGetterName(GetterSel);
   PDecl->setSetterName(SetterSel);
   

Added: cfe/trunk/test/CodeGenObjC/synthesize_ivar-cont-class.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/synthesize_ivar-cont-class.m?rev=68259&view=auto

==============================================================================
--- cfe/trunk/test/CodeGenObjC/synthesize_ivar-cont-class.m (added)
+++ cfe/trunk/test/CodeGenObjC/synthesize_ivar-cont-class.m Wed Apr  1 18:23:53 2009
@@ -0,0 +1,18 @@
+// RUN: clang-cc -triple x86_64-apple-darwin10 -emit-llvm -o %t %s &&
+// RUN: grep '_OBJC_IVAR_$_XCOrganizerDeviceNodeInfo.viewController' %t
+
+ at interface XCOrganizerNodeInfo
+ at property (readonly, retain) id viewController;
+ at end
+
+ at interface XCOrganizerDeviceNodeInfo : XCOrganizerNodeInfo
+ at end
+
+ at interface XCOrganizerDeviceNodeInfo()
+ at property (retain) id viewController;
+ at end
+
+ at implementation XCOrganizerDeviceNodeInfo
+ at synthesize viewController;
+ at end
+





More information about the cfe-commits mailing list