enum PropActionKind {
PropAction_None,
- PropAction_RetainToStrong,
PropAction_RetainRemoved,
PropAction_AssignRemoved,
PropAction_AssignRewritten,
- PropAction_MaybeAddStrong,
PropAction_MaybeAddWeakOrUnsafe
};
switch (kind) {
case PropAction_None:
return;
- case PropAction_RetainToStrong:
- rewriteAttribute("retain", "strong", atLoc);
- return;
case PropAction_RetainRemoved:
removeAttribute("retain", atLoc);
return;
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);
}
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);
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))
}
}
- 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);
}
@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;
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;
@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