return;
if (propAttrs & ObjCPropertyDecl::OBJC_PR_retain) {
- rewriteAttribute("retain", "strong", atLoc);
+ if (propAttrs & ObjCPropertyDecl::OBJC_PR_readonly)
+ rewriteAttribute("retain", "strong", atLoc);
+ else
+ removeAttribute("retain", atLoc); // strong is the default.
return;
}
}
}
+ bool removeAttribute(StringRef fromAttr, SourceLocation atLoc) const {
+ return rewriteAttribute(fromAttr, StringRef(), atLoc);
+ }
+
bool rewriteAttribute(StringRef fromAttr, StringRef toAttr,
SourceLocation atLoc) const {
if (atLoc.isMacroID())
lexer.LexFromRawLexer(tok);
if (tok.isNot(tok::l_paren)) return false;
+ Token BeforeTok = tok;
+ Token AfterTok;
+ AfterTok.startToken();
+ SourceLocation AttrLoc;
+
lexer.LexFromRawLexer(tok);
if (tok.is(tok::r_paren))
return false;
if (tok.isNot(tok::raw_identifier)) return false;
StringRef ident(tok.getRawIdentifierData(), tok.getLength());
if (ident == fromAttr) {
- Pass.TA.replaceText(tok.getLocation(), fromAttr, toAttr);
- return true;
+ if (!toAttr.empty()) {
+ Pass.TA.replaceText(tok.getLocation(), fromAttr, toAttr);
+ return true;
+ }
+ // We want to remove the attribute.
+ AttrLoc = tok.getLocation();
}
do {
lexer.LexFromRawLexer(tok);
+ if (AttrLoc.isValid() && AfterTok.is(tok::unknown))
+ AfterTok = tok;
} while (tok.isNot(tok::comma) && tok.isNot(tok::r_paren));
if (tok.is(tok::r_paren))
break;
+ if (AttrLoc.isInvalid())
+ BeforeTok = tok;
lexer.LexFromRawLexer(tok);
}
+ if (toAttr.empty() && AttrLoc.isValid() && AfterTok.isNot(tok::unknown)) {
+ // We want to remove the attribute.
+ if (BeforeTok.is(tok::l_paren) && AfterTok.is(tok::r_paren)) {
+ Pass.TA.remove(SourceRange(BeforeTok.getLocation(),
+ AfterTok.getLocation()));
+ } else if (BeforeTok.is(tok::l_paren) && AfterTok.is(tok::comma)) {
+ Pass.TA.remove(SourceRange(AttrLoc, AfterTok.getLocation()));
+ } else {
+ Pass.TA.remove(SourceRange(BeforeTok.getLocation(), AttrLoc));
+ }
+
+ return true;
+ }
+
return false;
}
@property (assign) Foo *no_user_ivar1;
@property (readonly) Foo *no_user_ivar2;
+
+@property (retain) id def1;
+@property (atomic,retain) id def2;
+@property (retain,atomic) id def3;
+
@end
@implementation Foo
@synthesize x,w,q1,q2,oo,bcw,not_safe1,not_safe2,not_safe3;
@synthesize no_user_ivar1, no_user_ivar2;
@synthesize assign_plus1, assign_plus2, assign_plus3;
+@synthesize def1, def2, def3;
-(void)test:(Foo *)parm {
assign_plus1 = [[Foo alloc] init];
@property (weak) Foo *no_user_ivar1;
@property (weak, readonly) Foo *no_user_ivar2;
+
+@property id def1;
+@property (atomic) id def2;
+@property (atomic) id def3;
+
@end
@implementation Foo
@synthesize x,w,q1,q2,oo,bcw,not_safe1,not_safe2,not_safe3;
@synthesize no_user_ivar1, no_user_ivar2;
@synthesize assign_plus1, assign_plus2, assign_plus3;
+@synthesize def1, def2, def3;
-(void)test:(Foo *)parm {
assign_plus1 = [[Foo alloc] init];