[cfe-commits] r121617 - in /cfe/trunk: lib/Sema/SemaDeclObjC.cpp test/SemaObjC/property-in-class-extension.m
Fariborz Jahanian
fjahanian at apple.com
Sat Dec 11 10:39:38 PST 2010
Author: fjahanian
Date: Sat Dec 11 12:39:37 2010
New Revision: 121617
URL: http://llvm.org/viewvc/llvm-project?rev=121617&view=rev
Log:
Enhance my implementation of //rdar ://8747333 in r121597 to allow
for declaration of property setter/getter in forward
class extensions and also skip over
propeties which are @dynamic.
Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.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=121617&r1=121616&r2=121617&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sat Dec 11 12:39:37 2010
@@ -1525,25 +1525,6 @@
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)) {
@@ -1560,6 +1541,38 @@
if (ObjCImplementationDecl *IC=dyn_cast<ObjCImplementationDecl>(ClassDecl)) {
IC->setAtEndRange(AtEnd);
if (ObjCInterfaceDecl* IDecl = IC->getClassInterface()) {
+ // 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 =
+ IDecl->getFirstClassExtension();
+ ClsExtDecl; ClsExtDecl = ClsExtDecl->getNextClassExtension()) {
+ for (ObjCContainerDecl::prop_iterator I = ClsExtDecl->prop_begin(),
+ E = ClsExtDecl->prop_end(); I != E; ++I) {
+ ObjCPropertyDecl *Property = (*I);
+ // Skip over properties declared @dynamic
+ if (const ObjCPropertyImplDecl *PIDecl
+ = IC->FindPropertyImplDecl(Property->getIdentifier()))
+ if (PIDecl->getPropertyImplementation()
+ == ObjCPropertyImplDecl::Dynamic)
+ continue;
+
+ for (const ObjCCategoryDecl *CExtDecl =
+ IDecl->getFirstClassExtension();
+ CExtDecl; CExtDecl = CExtDecl->getNextClassExtension()) {
+ if (ObjCMethodDecl *GetterMethod =
+ CExtDecl->getInstanceMethod(Property->getGetterName()))
+ GetterMethod->setSynthesized(true);
+ if (!Property->isReadOnly())
+ if (ObjCMethodDecl *SetterMethod =
+ CExtDecl->getInstanceMethod(Property->getSetterName()))
+ SetterMethod->setSynthesized(true);
+ }
+ }
+ }
+
if (LangOpts.ObjCNonFragileABI2)
DefaultSynthesizeProperties(S, IC, IDecl);
ImplMethodsVsClassMethods(S, IC, IDecl);
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=121617&r1=121616&r2=121617&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property-in-class-extension.m (original)
+++ cfe/trunk/test/SemaObjC/property-in-class-extension.m Sat Dec 11 12:39:37 2010
@@ -19,6 +19,7 @@
@private
NSObject *_bar;
NSObject *_baz;
+ NSObject *_bam;
}
- (NSObject *)baz;
@end
@@ -30,10 +31,20 @@
@interface rdar8747333 ()
@property (readwrite, assign) NSObject *bar;
@property (readwrite, assign) NSObject *baz;
+ at property (readwrite, assign) NSObject *bam;
+ at property (readwrite, assign) NSObject *warn;
@end
- at implementation rdar8747333
+ at interface rdar8747333 ()
+- (NSObject *)bam;
+- (NSObject *)warn; // expected-note {{method definition for 'warn' not found}}
+- (void)setWarn : (NSObject *)val; // expected-note {{method definition for 'setWarn:' not found}}
+ at end
+
+ at implementation rdar8747333 // expected-warning {{incomplete implementation}}
@synthesize bar = _bar;
@synthesize baz = _baz;
+ at synthesize bam = _bam;
+ at dynamic warn;
@end
More information about the cfe-commits
mailing list