summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-28 00:23:12 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-28 00:23:12 +0000
commit3fc3dcd80f34cc6750be06fa546c08df0d03652c (patch)
treebf7de9ddbbecc24b40d6b58580cfe94ce7225a7e /clang
parent1424b308c3c82acce5e23a1bcd0efbfa6dbd0349 (diff)
downloadbcm5719-llvm-3fc3dcd80f34cc6750be06fa546c08df0d03652c.tar.gz
bcm5719-llvm-3fc3dcd80f34cc6750be06fa546c08df0d03652c.zip
[arcmt] Don't add __weak if there is already a GC __weak and make sure to clear
__weak from a readonly property. llvm-svn: 145210
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/ARCMigrate/TransGCAttrs.cpp3
-rw-r--r--clang/lib/ARCMigrate/TransProperties.cpp18
-rw-r--r--clang/test/ARCMT/GC.m6
-rw-r--r--clang/test/ARCMT/GC.m.result6
4 files changed, 24 insertions, 9 deletions
diff --git a/clang/lib/ARCMigrate/TransGCAttrs.cpp b/clang/lib/ARCMigrate/TransGCAttrs.cpp
index dc223750483..607e5a0f3d9 100644
--- a/clang/lib/ARCMigrate/TransGCAttrs.cpp
+++ b/clang/lib/ARCMigrate/TransGCAttrs.cpp
@@ -326,7 +326,8 @@ static void checkAllProps(MigrationContext &MigrateCtx,
for (unsigned i = 0, e = AllProps.size(); i != e; ++i) {
ObjCPropertyDecl *PD = AllProps[i];
if (PD->getPropertyAttributesAsWritten() &
- ObjCPropertyDecl::OBJC_PR_assign) {
+ (ObjCPropertyDecl::OBJC_PR_assign |
+ ObjCPropertyDecl::OBJC_PR_readonly)) {
SourceLocation AtLoc = PD->getAtLoc();
if (AtLoc.isInvalid())
continue;
diff --git a/clang/lib/ARCMigrate/TransProperties.cpp b/clang/lib/ARCMigrate/TransProperties.cpp
index 0686dd3c2e3..8136b31d812 100644
--- a/clang/lib/ARCMigrate/TransProperties.cpp
+++ b/clang/lib/ARCMigrate/TransProperties.cpp
@@ -237,9 +237,12 @@ private:
canUseWeak = false;
for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) {
- if (isUserDeclared(I->IvarD))
- Pass.TA.insert(I->IvarD->getLocation(),
- canUseWeak ? "__weak " : "__unsafe_unretained ");
+ if (isUserDeclared(I->IvarD)) {
+ if (I->IvarD &&
+ I->IvarD->getType().getObjCLifetime() != Qualifiers::OCL_Weak)
+ Pass.TA.insert(I->IvarD->getLocation(),
+ canUseWeak ? "__weak " : "__unsafe_unretained ");
+ }
if (I->ImplD)
Pass.TA.clearDiagnostic(diag::err_arc_assign_property_ownership,
I->ImplD->getLocation());
@@ -257,9 +260,12 @@ private:
canUseWeak = false;
for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) {
- if (isUserDeclared(I->IvarD))
- Pass.TA.insert(I->IvarD->getLocation(),
- canUseWeak ? "__weak " : "__unsafe_unretained ");
+ if (isUserDeclared(I->IvarD)) {
+ if (I->IvarD &&
+ I->IvarD->getType().getObjCLifetime() != Qualifiers::OCL_Weak)
+ Pass.TA.insert(I->IvarD->getLocation(),
+ canUseWeak ? "__weak " : "__unsafe_unretained ");
+ }
if (I->ImplD) {
Pass.TA.clearDiagnostic(diag::err_arc_assign_property_ownership,
I->ImplD->getLocation());
diff --git a/clang/test/ARCMT/GC.m b/clang/test/ARCMT/GC.m
index 35e9bcf9ce1..86e8b9b9630 100644
--- a/clang/test/ARCMT/GC.m
+++ b/clang/test/ARCMT/GC.m
@@ -58,6 +58,8 @@ __attribute__((objc_arc_weak_reference_unavailable))
@interface I4Impl {
I4Impl *pds2;
I4Impl *pds3;
+ __weak I4Impl *pw3;
+ __weak I4Impl *pw4;
}
@property (assign) I4Impl *__weak pw1, *__weak pw2;
@property (assign) I4Impl *__strong ps;
@@ -65,10 +67,12 @@ __attribute__((objc_arc_weak_reference_unavailable))
@property (assign) I4Impl * pds2;
@property (readwrite) I4Impl * pds3;
@property (readonly) I4Impl * pds4;
+@property (readonly) __weak I4Impl *pw3;
+@property (assign) __weak I4Impl *pw4;
@end
@implementation I4Impl
-@synthesize pw1, pw2, ps, pds, pds2, pds3, pds4;
+@synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4;
-(void)test1:(CFTypeRef *)cft {
id x = NSMakeCollectable(cft);
diff --git a/clang/test/ARCMT/GC.m.result b/clang/test/ARCMT/GC.m.result
index 540c2a2932f..b5222dd27a6 100644
--- a/clang/test/ARCMT/GC.m.result
+++ b/clang/test/ARCMT/GC.m.result
@@ -53,6 +53,8 @@ __attribute__((objc_arc_weak_reference_unavailable))
@interface I4Impl {
I4Impl *pds2;
I4Impl *pds3;
+ __weak I4Impl *pw3;
+ __weak I4Impl *pw4;
}
@property (weak) I4Impl * pw1, * pw2;
@property I4Impl * ps;
@@ -60,10 +62,12 @@ __attribute__((objc_arc_weak_reference_unavailable))
@property I4Impl * pds2;
@property (readwrite) I4Impl * pds3;
@property (readonly) I4Impl * pds4;
+@property (weak, readonly) I4Impl *pw3;
+@property (weak) I4Impl *pw4;
@end
@implementation I4Impl
-@synthesize pw1, pw2, ps, pds, pds2, pds3, pds4;
+@synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4;
-(void)test1:(CFTypeRef *)cft {
id x = CFBridgingRelease(cft);
OpenPOWER on IntegriCloud