Procházet zdrojové kódy

ObjC: add getter/setter for class properties to global pool.

rdar://problem/25323072


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@264196 91177308-0d34-0410-b5e6-96231b3b80d8
Manman Ren před 9 roky
rodič
revize
42f05409f6

+ 5 - 0
lib/Sema/SemaObjCProperty.cpp

@@ -2308,6 +2308,11 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property) {
       AddInstanceMethodToGlobalPool(GetterMethod);
       AddInstanceMethodToGlobalPool(GetterMethod);
     if (SetterMethod)
     if (SetterMethod)
       AddInstanceMethodToGlobalPool(SetterMethod);
       AddInstanceMethodToGlobalPool(SetterMethod);
+  } else {
+    if (GetterMethod)
+      AddFactoryMethodToGlobalPool(GetterMethod);
+    if (SetterMethod)
+      AddFactoryMethodToGlobalPool(SetterMethod);
   }
   }
 
 
   ObjCInterfaceDecl *CurrentClass = dyn_cast<ObjCInterfaceDecl>(CD);
   ObjCInterfaceDecl *CurrentClass = dyn_cast<ObjCInterfaceDecl>(CD);

+ 8 - 0
test/SemaObjC/objc-class-property.m

@@ -33,3 +33,11 @@ int test() {
   A *a = [[A alloc] init];
   A *a = [[A alloc] init];
   return a.x + A.c;
   return a.x + A.c;
 }
 }
+
+void message_id(id me) {
+  [me y];
+}
+
+void message_class(Class me) {
+  [me c2];
+}