]> granicus.if.org Git - clang/commitdiff
Nonfragile ivar synthesis with property is in a continuation
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 1 Apr 2009 19:37:34 +0000 (19:37 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 1 Apr 2009 19:37:34 +0000 (19:37 +0000)
class.

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

lib/AST/ASTContext.cpp
lib/AST/DeclObjC.cpp
lib/CodeGen/CGObjCMac.cpp
test/CodeGenObjC/synthesize_ivar.m

index fc1e0a2062752ad5a07c1c28d66c79c6705aaf4f..8da7b3aa1dc9a435e094e6eccf2c2df4e223f05e 100644 (file)
@@ -614,6 +614,17 @@ void ASTContext::CollectObjCIvars(const ObjCInterfaceDecl *OI,
     if (ObjCIvarDecl *IV = (*I)->getPropertyIvarDecl())
       Fields.push_back(cast<FieldDecl>(IV));
   }
+  // look into continuation class.
+  for (ObjCCategoryDecl *Categories = OI->getCategoryList();
+       Categories; Categories = Categories->getNextClassCategory())
+    if (!Categories->getIdentifier()) {
+      for (ObjCInterfaceDecl::prop_iterator I = Categories->prop_begin(),
+           E = Categories->prop_end(); I != E; ++I) {
+        if (ObjCIvarDecl *IV = (*I)->getPropertyIvarDecl())
+          Fields.push_back(cast<FieldDecl>(IV));      
+      }
+      break;
+    }
 }
 
 /// addRecordToClass - produces record info. for the class for its
@@ -711,7 +722,18 @@ ASTContext::getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) {
     if (ObjCIvarDecl *Ivar = (*I)->getPropertyIvarDecl())
       NewEntry->LayoutField(Ivar, i++, false, StructPacking, *this);
   }
-
+  // Also continuation class.
+  for (ObjCCategoryDecl *Categories = D->getCategoryList();
+       Categories; Categories = Categories->getNextClassCategory())
+    if (!Categories->getIdentifier()) {
+      for (ObjCInterfaceDecl::prop_iterator I = Categories->prop_begin(),
+           E = Categories->prop_end(); I != E; ++I) {
+        if (ObjCIvarDecl *Ivar = (*I)->getPropertyIvarDecl())
+          NewEntry->LayoutField(Ivar, i++, false, StructPacking, *this);
+      }
+      break;
+    }
+  
   // Finally, round the size of the total struct up to the alignment of the
   // struct itself.
   NewEntry->FinalizeLayout();
index cd1b979dcb0c2e3319d80c55df2b0b8292e8b63b..57bd8eab1efae313a55e66ff66da4344756d1b25 100644 (file)
@@ -147,6 +147,22 @@ ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable(
           return IV;
         }
     }
+    // look into continuation class.
+    for (ObjCCategoryDecl *Categories = ClassDecl->getCategoryList();
+         Categories; Categories = Categories->getNextClassCategory())
+      if (!Categories->getIdentifier()) {
+        for (ObjCInterfaceDecl::prop_iterator I = Categories->prop_begin(),
+             E = Categories->prop_end(); I != E; ++I) {
+          ObjCPropertyDecl *PDecl = (*I);
+          if (ObjCIvarDecl *IV = PDecl->getPropertyIvarDecl())
+            if (IV->getIdentifier() == ID) {
+              clsDeclared = ClassDecl;
+              return IV;
+            }          
+        }
+        break;
+      }
+    
     ClassDecl = ClassDecl->getSuperClass();
   }
   return NULL;
index 6b3ced08bf42a5bd0a8402f2bddf97956c02cd9c..580641643f7add59091b97e63f879714c3a3181f 100644 (file)
@@ -1674,6 +1674,18 @@ static int countInheritedIvars(const ObjCInterfaceDecl *OI) {
     if ((*I)->getPropertyIvarDecl())
       ++count;
   }
+  // look into continuation class.
+  for (ObjCCategoryDecl *Categories = OI->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)->getPropertyIvarDecl())
+          ++count;
+      }
+      break;
+    }
+  }
   return count;
 }
 
@@ -1702,6 +1714,20 @@ static const ObjCInterfaceDecl *getInterfaceDeclForIvar(
       if (IV->getIdentifier() == IVD->getIdentifier())
         return OI;
   }
+  // look into continuation class.
+  for (ObjCCategoryDecl *Categories = OI->getCategoryList();
+       Categories; Categories = Categories->getNextClassCategory()) {
+    if (!Categories->getIdentifier()) {
+      for (ObjCInterfaceDecl::prop_iterator I = Categories->prop_begin(),
+           E = Categories->prop_end(); I != E; ++I) {
+        ObjCPropertyDecl *PDecl = (*I);
+        if (ObjCIvarDecl *IV = PDecl->getPropertyIvarDecl())
+          if (IV->getIdentifier() == IVD->getIdentifier())
+            return OI;
+      }
+      break;
+    }
+  }
   return getInterfaceDeclForIvar(OI->getSuperClass(), IVD);
 }
 
@@ -4566,6 +4592,18 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitIvarList(
        E = OID->prop_end(); I != E; ++I)
     if (ObjCIvarDecl *IV = (*I)->getPropertyIvarDecl())
       OIvars.push_back(IV);
+  // look into continuation class.
+  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 (ObjCIvarDecl *IV = (*I)->getPropertyIvarDecl())
+          OIvars.push_back(IV);
+      }
+      break;
+    }
+    
   unsigned iv = 0;
   for (RecordDecl::field_iterator e = RD->field_end(); i != e; ++i) {
     FieldDecl *Field = *i;
index 8999691fe1ce9fe4ec36e9a2a6bb52395dabf0f7..7646f707bf76192580263a255cd8184885c87cb3 100644 (file)
    return IP;
 }
 @end
+
+// Test for synthesis of ivar for a property
+// declared in continuation class.
+@interface OrganizerViolatorView
+@end
+
+@interface OrganizerViolatorView()
+@property (retain) id bindingInfo;
+@end
+
+@implementation OrganizerViolatorView
+@synthesize bindingInfo;
+@end