mirror of
https://github.com/intel/llvm.git
synced 2026-01-20 01:58:44 +08:00
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. llvm-svn: 121617
This commit is contained in:
@@ -1525,25 +1525,6 @@ void Sema::ActOnAtEnd(Scope *S, SourceRange AtEnd,
|
||||
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 @@ void Sema::ActOnAtEnd(Scope *S, SourceRange AtEnd,
|
||||
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);
|
||||
|
||||
@@ -19,6 +19,7 @@ void FUNC () {
|
||||
@private
|
||||
NSObject *_bar;
|
||||
NSObject *_baz;
|
||||
NSObject *_bam;
|
||||
}
|
||||
- (NSObject *)baz;
|
||||
@end
|
||||
@@ -30,10 +31,20 @@ void FUNC () {
|
||||
@interface rdar8747333 ()
|
||||
@property (readwrite, assign) NSObject *bar;
|
||||
@property (readwrite, assign) NSObject *baz;
|
||||
@property (readwrite, assign) NSObject *bam;
|
||||
@property (readwrite, assign) NSObject *warn;
|
||||
@end
|
||||
|
||||
@implementation rdar8747333
|
||||
@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}}
|
||||
@end
|
||||
|
||||
@implementation rdar8747333 // expected-warning {{incomplete implementation}}
|
||||
@synthesize bar = _bar;
|
||||
@synthesize baz = _baz;
|
||||
@synthesize bam = _bam;
|
||||
@dynamic warn;
|
||||
@end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user