From 95f1b86b73a9a203311adc7646f2fa9ee5cdd2b7 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 25 Aug 2010 00:31:58 +0000 Subject: [PATCH] No need to default synthesize property if implementation has its own getter and setter methods declared. Fixed 8349319 (nonfragile-abi2). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112003 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaObjCProperty.cpp | 6 ++++++ test/SemaObjC/default-synthesize-1.m | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 91f47ab708..b9fd4a05d7 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -953,6 +953,12 @@ void Sema::DefaultSynthesizeProperties (Scope *S, ObjCImplDecl* IMPDecl, // Property may have been synthesized by user. if (IMPDecl->FindPropertyImplDecl(Prop->getIdentifier())) continue; + if (IMPDecl->getInstanceMethod(Prop->getGetterName())) { + if (Prop->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_readonly) + continue; + if (IMPDecl->getInstanceMethod(Prop->getSetterName())) + continue; + } ActOnPropertyImplDecl(S, IMPDecl->getLocation(), IMPDecl->getLocation(), true, IMPDecl, diff --git a/test/SemaObjC/default-synthesize-1.m b/test/SemaObjC/default-synthesize-1.m index 30a2c8f1aa..374fa8314b 100644 --- a/test/SemaObjC/default-synthesize-1.m +++ b/test/SemaObjC/default-synthesize-1.m @@ -85,4 +85,32 @@ } @end +// rdar://8349319 +// No default synthesis if implementation has getter (readonly) and setter(readwrite) methods. +@interface DSATextSearchResult +@property(assign,readonly) float relevance; +@property(assign,readonly) char isTitleMatch; +@end + +@interface DSANodeSearchResult : DSATextSearchResult {} +@end + + +@implementation DSATextSearchResult +-(char)isTitleMatch { + return (char)0; +} + +-(float)relevance { + return 0.0; +} +@end + +@implementation DSANodeSearchResult +-(id)initWithNode:(id )node relevance:(float)relevance isTitleMatch:(char)isTitleMatch { + relevance = 0.0; + isTitleMatch = 'a'; + return self; +} +@end