summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-08 23:09:34 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-08 23:09:34 +0000
commit485eceed38debe7748351770a807e99764156fbc (patch)
treeea6ee204a935e7bc43f25cdb8e3c5b0ca10c50d6
parent1738fad337606a9ad80662fa1fd170450926d6b2 (diff)
downloadbcm5719-llvm-485eceed38debe7748351770a807e99764156fbc.tar.gz
bcm5719-llvm-485eceed38debe7748351770a807e99764156fbc.zip
[arcmt] Take into account that all properties are strong-by-default now and fix the test.
llvm-svn: 144146
-rw-r--r--clang/lib/ARCMigrate/TransProperties.cpp49
-rw-r--r--clang/test/ARCMT/assign-prop-with-arc-runtime.m5
-rw-r--r--clang/test/ARCMT/assign-prop-with-arc-runtime.m.result9
3 files changed, 13 insertions, 50 deletions
diff --git a/clang/lib/ARCMigrate/TransProperties.cpp b/clang/lib/ARCMigrate/TransProperties.cpp
index f9c02061343..0686dd3c2e3 100644
--- a/clang/lib/ARCMigrate/TransProperties.cpp
+++ b/clang/lib/ARCMigrate/TransProperties.cpp
@@ -50,11 +50,9 @@ class PropertiesRewriter {
enum PropActionKind {
PropAction_None,
- PropAction_RetainToStrong,
PropAction_RetainRemoved,
PropAction_AssignRemoved,
PropAction_AssignRewritten,
- PropAction_MaybeAddStrong,
PropAction_MaybeAddWeakOrUnsafe
};
@@ -163,9 +161,6 @@ private:
switch (kind) {
case PropAction_None:
return;
- case PropAction_RetainToStrong:
- rewriteAttribute("retain", "strong", atLoc);
- return;
case PropAction_RetainRemoved:
removeAttribute("retain", atLoc);
return;
@@ -173,8 +168,6 @@ private:
return removeAssignForDefaultStrong(props, atLoc);
case PropAction_AssignRewritten:
return rewriteAssign(props, atLoc);
- case PropAction_MaybeAddStrong:
- return maybeAddStrongAttr(props, atLoc);
case PropAction_MaybeAddWeakOrUnsafe:
return maybeAddWeakOrUnsafeUnretainedAttr(props, atLoc);
}
@@ -199,11 +192,8 @@ private:
return;
if (propAttrs & ObjCPropertyDecl::OBJC_PR_retain) {
- if (propAttrs & ObjCPropertyDecl::OBJC_PR_readonly)
- return doPropAction(PropAction_RetainToStrong, props, atLoc);
- else
- // strong is the default.
- return doPropAction(PropAction_RetainRemoved, props, atLoc);
+ // strong is the default.
+ return doPropAction(PropAction_RetainRemoved, props, atLoc);
}
bool HasIvarAssignedAPlusOneObject = hasIvarAssignedAPlusOneObject(props);
@@ -258,17 +248,13 @@ private:
void maybeAddWeakOrUnsafeUnretainedAttr(PropsTy &props,
SourceLocation atLoc) const {
- ObjCPropertyDecl::PropertyAttributeKind propAttrs = getPropertyAttrs(props);
-
bool canUseWeak = canApplyWeak(Pass.Ctx, getPropertyType(props),
/*AllowOnUnknownClass=*/Pass.isGCMigration());
- if (!(propAttrs & ObjCPropertyDecl::OBJC_PR_readonly) ||
- !hasAllIvarsBacked(props)) {
- bool addedAttr = addAttribute(canUseWeak ? "weak" : "unsafe_unretained",
- atLoc);
- if (!addedAttr)
- canUseWeak = false;
- }
+
+ bool addedAttr = addAttribute(canUseWeak ? "weak" : "unsafe_unretained",
+ atLoc);
+ if (!addedAttr)
+ canUseWeak = false;
for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) {
if (isUserDeclared(I->IvarD))
@@ -284,27 +270,6 @@ private:
}
}
- void maybeAddStrongAttr(PropsTy &props, SourceLocation atLoc) const {
- ObjCPropertyDecl::PropertyAttributeKind propAttrs = getPropertyAttrs(props);
-
- if (!(propAttrs & ObjCPropertyDecl::OBJC_PR_readonly))
- return; // 'strong' by default.
-
- if (!hasAllIvarsBacked(props)) {
- addAttribute("strong", atLoc);
- }
-
- for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) {
- if (I->ImplD) {
- Pass.TA.clearDiagnostic(diag::err_arc_assign_property_ownership,
- I->ImplD->getLocation());
- Pass.TA.clearDiagnostic(
- diag::err_arc_objc_property_default_assign_on_object,
- I->ImplD->getLocation());
- }
- }
- }
-
bool removeAttribute(StringRef fromAttr, SourceLocation atLoc) const {
return rewriteAttribute(fromAttr, StringRef(), atLoc);
}
diff --git a/clang/test/ARCMT/assign-prop-with-arc-runtime.m b/clang/test/ARCMT/assign-prop-with-arc-runtime.m
index 88450108950..8408a1858bd 100644
--- a/clang/test/ARCMT/assign-prop-with-arc-runtime.m
+++ b/clang/test/ARCMT/assign-prop-with-arc-runtime.m
@@ -14,8 +14,7 @@ typedef _NSCachedAttributedString *BadClassForWeak;
@class Forw;
@interface Foo : NSObject {
- Foo *w, *q1, *q2;
- __weak Foo *x;
+ Foo *x, *w, *q1, *q2;
WeakOptOut *oo;
BadClassForWeak bcw;
id not_safe1;
@@ -23,7 +22,7 @@ typedef _NSCachedAttributedString *BadClassForWeak;
Forw *not_safe3;
Foo *assign_plus1;
}
-@property (readonly) __weak Foo *x;
+@property (readonly) Foo *x;
@property (assign) Foo *w;
@property Foo *q1, *q2;
@property (assign) WeakOptOut *oo;
diff --git a/clang/test/ARCMT/assign-prop-with-arc-runtime.m.result b/clang/test/ARCMT/assign-prop-with-arc-runtime.m.result
index 7cb7e1722ba..56906f7002c 100644
--- a/clang/test/ARCMT/assign-prop-with-arc-runtime.m.result
+++ b/clang/test/ARCMT/assign-prop-with-arc-runtime.m.result
@@ -14,8 +14,7 @@ typedef _NSCachedAttributedString *BadClassForWeak;
@class Forw;
@interface Foo : NSObject {
- Foo *__weak w, *__weak q1, *__weak q2;
- __weak Foo *x;
+ Foo *__weak x, *__weak w, *__weak q1, *__weak q2;
WeakOptOut *__unsafe_unretained oo;
BadClassForWeak __unsafe_unretained bcw;
id __unsafe_unretained not_safe1;
@@ -23,7 +22,7 @@ typedef _NSCachedAttributedString *BadClassForWeak;
Forw *__unsafe_unretained not_safe3;
Foo *assign_plus1;
}
-@property (readonly) __weak Foo *x;
+@property (weak, readonly) Foo *x;
@property (weak) Foo *w;
@property (weak) Foo *q1, *q2;
@property (unsafe_unretained) WeakOptOut *oo;
@@ -58,12 +57,12 @@ typedef _NSCachedAttributedString *BadClassForWeak;
@end
@interface TestExt
-@property (strong,readonly) TestExt *x1;
+@property (readonly) TestExt *x1;
@property (weak, readonly) TestExt *x2;
@end
@interface TestExt()
-@property (strong,readwrite) TestExt *x1;
+@property (readwrite) TestExt *x1;
@property (weak, readwrite) TestExt *x2;
@end
OpenPOWER on IntegriCloud