Do not rewrite new accessor if user has defined accessors.
Fixes //rdar: // 8570020. llvm-svn: 116882
This commit is contained in:
parent
707d8228df
commit
7c299bc6fa
|
@ -767,6 +767,7 @@ void RewriteObjC::RewritePropertyImplDecl(ObjCPropertyImplDecl *PID,
|
|||
if (!OID)
|
||||
return;
|
||||
unsigned Attributes = PD->getPropertyAttributes();
|
||||
if (!PD->getGetterMethodDecl()->isDefined()) {
|
||||
bool GenGetProperty = !(Attributes & ObjCPropertyDecl::OBJC_PR_nonatomic) &&
|
||||
(Attributes & (ObjCPropertyDecl::OBJC_PR_retain |
|
||||
ObjCPropertyDecl::OBJC_PR_copy));
|
||||
|
@ -819,7 +820,9 @@ void RewriteObjC::RewritePropertyImplDecl(ObjCPropertyImplDecl *PID,
|
|||
Getr += "return " + getIvarAccessString(OID);
|
||||
Getr += "; }";
|
||||
InsertText(onePastSemiLoc, Getr);
|
||||
if (PD->isReadOnly())
|
||||
}
|
||||
|
||||
if (PD->isReadOnly() || PD->getSetterMethodDecl()->isDefined())
|
||||
return;
|
||||
|
||||
// Generate the 'setter' function.
|
||||
|
@ -3834,10 +3837,12 @@ void RewriteObjC::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
|
|||
if (!PD)
|
||||
continue;
|
||||
if (ObjCMethodDecl *Getter = PD->getGetterMethodDecl())
|
||||
if (!Getter->isDefined())
|
||||
InstanceMethods.push_back(Getter);
|
||||
if (PD->isReadOnly())
|
||||
continue;
|
||||
if (ObjCMethodDecl *Setter = PD->getSetterMethodDecl())
|
||||
if (!Setter->isDefined())
|
||||
InstanceMethods.push_back(Setter);
|
||||
}
|
||||
RewriteObjCMethodsMetaData(InstanceMethods.begin(), InstanceMethods.end(),
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
|
||||
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -Did="void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
|
||||
// rdar:// 8570020
|
||||
|
||||
@interface Foo {
|
||||
Foo *foo;
|
||||
}
|
||||
|
||||
@property (retain, nonatomic) Foo *foo;
|
||||
|
||||
@end
|
||||
|
||||
@implementation Foo
|
||||
|
||||
- (Foo *)foo {
|
||||
if (!foo) {
|
||||
foo = 0;
|
||||
}
|
||||
return foo;
|
||||
}
|
||||
|
||||
|
||||
- (void) setFoo : (Foo *) arg {
|
||||
foo = arg;
|
||||
}
|
||||
|
||||
@synthesize foo;
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in New Issue