summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-01-21 00:43:53 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-01-21 00:43:53 +0000
commit1630c15b0fa1cfa191ec34a4db7f6d5a17434c6d (patch)
tree844fe4965d127bc5b81ef2323ca122a93936c271
parent3aa55267c480f2755b14f2d3005f86202a2d8a0a (diff)
downloadbcm5719-llvm-1630c15b0fa1cfa191ec34a4db7f6d5a17434c6d.tar.gz
bcm5719-llvm-1630c15b0fa1cfa191ec34a4db7f6d5a17434c6d.zip
arg migrator: change all "assign" of object properties
to "strong" when migrating from GC. // rdar://10532449 llvm-svn: 148607
-rw-r--r--clang/lib/ARCMigrate/TransProperties.cpp20
-rw-r--r--clang/test/ARCMT/GC-no-arc-runtime.m.result8
-rw-r--r--clang/test/ARCMT/GC.m11
-rw-r--r--clang/test/ARCMT/GC.m.result19
4 files changed, 41 insertions, 17 deletions
diff --git a/clang/lib/ARCMigrate/TransProperties.cpp b/clang/lib/ARCMigrate/TransProperties.cpp
index b36acbb205d..7eb2a9bfc7e 100644
--- a/clang/lib/ARCMigrate/TransProperties.cpp
+++ b/clang/lib/ARCMigrate/TransProperties.cpp
@@ -201,10 +201,8 @@ private:
bool HasIvarAssignedAPlusOneObject = hasIvarAssignedAPlusOneObject(props);
if (propAttrs & ObjCPropertyDecl::OBJC_PR_assign) {
- if (HasIvarAssignedAPlusOneObject ||
- (Pass.isGCMigration() && !hasGCWeak(props, atLoc))) {
+ if (HasIvarAssignedAPlusOneObject)
return doPropAction(PropAction_AssignRemoved, props, atLoc);
- }
return doPropAction(PropAction_AssignRewritten, props, atLoc);
}
@@ -231,19 +229,23 @@ private:
void rewriteAssign(PropsTy &props, SourceLocation atLoc) const {
bool canUseWeak = canApplyWeak(Pass.Ctx, getPropertyType(props),
/*AllowOnUnknownClass=*/Pass.isGCMigration());
+ const char *toWhich =
+ (Pass.isGCMigration() && !hasGCWeak(props, atLoc)) ? "strong" :
+ (canUseWeak ? "weak" : "unsafe_unretained");
- bool rewroteAttr = rewriteAttribute("assign",
- canUseWeak ? "weak" : "unsafe_unretained",
- atLoc);
+ bool rewroteAttr = rewriteAttribute("assign", toWhich, atLoc);
if (!rewroteAttr)
canUseWeak = false;
for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) {
if (isUserDeclared(I->IvarD)) {
if (I->IvarD &&
- I->IvarD->getType().getObjCLifetime() != Qualifiers::OCL_Weak)
- Pass.TA.insert(I->IvarD->getLocation(),
- canUseWeak ? "__weak " : "__unsafe_unretained ");
+ I->IvarD->getType().getObjCLifetime() != Qualifiers::OCL_Weak) {
+ const char *toWhich =
+ (Pass.isGCMigration() && !hasGCWeak(props, atLoc)) ? "__strong " :
+ (canUseWeak ? "__weak " : "__unsafe_unretained ");
+ Pass.TA.insert(I->IvarD->getLocation(), toWhich);
+ }
}
if (I->ImplD)
Pass.TA.clearDiagnostic(diag::err_arc_assign_property_ownership,
diff --git a/clang/test/ARCMT/GC-no-arc-runtime.m.result b/clang/test/ARCMT/GC-no-arc-runtime.m.result
index 983af62c4a6..983a5b17427 100644
--- a/clang/test/ARCMT/GC-no-arc-runtime.m.result
+++ b/clang/test/ARCMT/GC-no-arc-runtime.m.result
@@ -52,12 +52,12 @@ __attribute__((objc_arc_weak_reference_unavailable))
@end
@interface I4Impl {
- I4Impl *pds2;
+ I4Impl *__strong pds2;
}
@property (unsafe_unretained) I4Impl * pw1, * pw2;
-@property I4Impl * ps;
-@property I4Impl * pds;
-@property I4Impl * pds2;
+@property (strong) I4Impl * ps;
+@property (strong) I4Impl * pds;
+@property (strong) I4Impl * pds2;
@end
@implementation I4Impl
diff --git a/clang/test/ARCMT/GC.m b/clang/test/ARCMT/GC.m
index d309dabf68e..f241e430085 100644
--- a/clang/test/ARCMT/GC.m
+++ b/clang/test/ARCMT/GC.m
@@ -79,3 +79,14 @@ __attribute__((objc_arc_weak_reference_unavailable))
id x = NSMakeCollectable(cft);
}
@end
+
+// rdar://10532449
+@interface rdar10532449
+@property (assign) id assign_prop;
+@property (assign, readonly) id __strong strong_readonly_prop;
+@property (assign) id __weak weak_prop;
+@end
+
+@implementation rdar10532449
+@synthesize assign_prop, strong_readonly_prop, weak_prop;
+@end
diff --git a/clang/test/ARCMT/GC.m.result b/clang/test/ARCMT/GC.m.result
index 2cf6b8e2448..f9e954af5a8 100644
--- a/clang/test/ARCMT/GC.m.result
+++ b/clang/test/ARCMT/GC.m.result
@@ -52,15 +52,15 @@ __attribute__((objc_arc_weak_reference_unavailable))
@end
@interface I4Impl {
- I4Impl *pds2;
+ I4Impl *__strong pds2;
I4Impl *pds3;
__weak I4Impl *pw3;
__weak I4Impl *pw4;
}
@property (weak) I4Impl * pw1, * pw2;
-@property I4Impl * ps;
-@property I4Impl * pds;
-@property I4Impl * pds2;
+@property (strong) I4Impl * ps;
+@property (strong) I4Impl * pds;
+@property (strong) I4Impl * pds2;
@property (readwrite) I4Impl * pds3;
@property (readonly) I4Impl * pds4;
@property (weak, readonly) I4Impl *pw3;
@@ -74,3 +74,14 @@ __attribute__((objc_arc_weak_reference_unavailable))
id x = CFBridgingRelease(cft);
}
@end
+
+// rdar://10532449
+@interface rdar10532449
+@property (strong) id assign_prop;
+@property (strong, readonly) id strong_readonly_prop;
+@property (weak) id weak_prop;
+@end
+
+@implementation rdar10532449
+@synthesize assign_prop, strong_readonly_prop, weak_prop;
+@end
OpenPOWER on IntegriCloud