[cfe-commits] r121597 - in /cfe/trunk: lib/Sema/SemaDeclObjC.cpp lib/Sema/SemaObjCProperty.cpp test/SemaObjC/property-in-class-extension.m
Fariborz Jahanian
fjahanian at apple.com
Fri Dec 10 15:36:33 PST 2010
Author: fjahanian
Date: Fri Dec 10 17:36:33 2010
New Revision: 121597
URL: http://llvm.org/viewvc/llvm-project?rev=121597&view=rev
Log:
Any property declared in a class extension might have user
declared setter or getter in current class extension or one
of the other class extensions. Mark them as synthesized as
property will be synthesized when property with same name is
seen in the @implementation. This prevents bogus warning
about unimplemented methods to be issued for these methods.
Fixes // rdar://8747333
Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/test/SemaObjC/property-in-class-extension.m
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=121597&r1=121596&r2=121597&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Dec 10 17:36:33 2010
@@ -1522,8 +1522,29 @@
// Compare protocol properties with those in category
CompareProperties(C, C);
- if (C->IsClassExtension())
- DiagnoseClassExtensionDupMethods(C, C->getClassInterface());
+ if (C->IsClassExtension()) {
+ ObjCInterfaceDecl *CCPrimary = C->getClassInterface();
+ DiagnoseClassExtensionDupMethods(C, CCPrimary);
+ for (ObjCContainerDecl::prop_iterator I = C->prop_begin(),
+ E = C->prop_end(); I != E; ++I) {
+ // Any property declared in a class extension might have user
+ // declared setter or getter in current class extension or one
+ // of the other class extensions. Mark them as synthesized as
+ // property will be synthesized when property with same name is
+ // seen in the @implementation.
+ for (const ObjCCategoryDecl *ClsExtDecl =
+ CCPrimary->getFirstClassExtension();
+ ClsExtDecl; ClsExtDecl = ClsExtDecl->getNextClassExtension()) {
+ if (ObjCMethodDecl *GetterMethod =
+ ClsExtDecl->getInstanceMethod((*I)->getGetterName()))
+ GetterMethod->setSynthesized(true);
+ if (!(*I)->isReadOnly())
+ if (ObjCMethodDecl *SetterMethod =
+ ClsExtDecl->getInstanceMethod((*I)->getSetterName()))
+ SetterMethod->setSynthesized(true);
+ }
+ }
+ }
}
if (ObjCContainerDecl *CDecl = dyn_cast<ObjCContainerDecl>(ClassDecl)) {
if (CDecl->getIdentifier())
Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=121597&r1=121596&r2=121597&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Fri Dec 10 17:36:33 2010
@@ -111,6 +111,7 @@
// Create a new ObjCPropertyDecl with the DeclContext being
// the class extension.
+ // FIXME. We should really be using CreatePropertyDecl for this.
ObjCPropertyDecl *PDecl =
ObjCPropertyDecl::Create(Context, DC, FD.D.getIdentifierLoc(),
PropertyId, AtLoc, T);
@@ -118,7 +119,9 @@
PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_readonly);
if (Attributes & ObjCDeclSpec::DQ_PR_readwrite)
PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_readwrite);
-
+ // Set setter/getter selector name. Needed later.
+ PDecl->setGetterName(GetterSel);
+ PDecl->setSetterName(SetterSel);
DC->addDecl(PDecl);
// We need to look in the @interface to see if the @property was
Modified: cfe/trunk/test/SemaObjC/property-in-class-extension.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-in-class-extension.m?rev=121597&r1=121596&r2=121597&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property-in-class-extension.m (original)
+++ cfe/trunk/test/SemaObjC/property-in-class-extension.m Fri Dec 10 17:36:33 2010
@@ -12,4 +12,28 @@
foo.bar = 0; // expected-error {{assigning to property with 'readonly' attribute not allowed}}
}
+// rdar://8747333
+ at class NSObject;
+
+ at interface rdar8747333 {
+ at private
+ NSObject *_bar;
+ NSObject *_baz;
+}
+- (NSObject *)baz;
+ at end
+
+ at interface rdar8747333 ()
+- (NSObject *)bar;
+ at end
+
+ at interface rdar8747333 ()
+ at property (readwrite, assign) NSObject *bar;
+ at property (readwrite, assign) NSObject *baz;
+ at end
+
+ at implementation rdar8747333
+ at synthesize bar = _bar;
+ at synthesize baz = _baz;
+ at end
More information about the cfe-commits
mailing list