[objcmt] Don't add redundant parentheses when migrating subscripting of an ivar.

rdar://11501256

llvm-svn: 157227
This commit is contained in:
Argyrios Kyrtzidis 2012-05-22 00:47:53 +00:00
parent 058bb9908f
commit 94442980c0
3 changed files with 10 additions and 2 deletions

View File

@ -624,6 +624,7 @@ static bool subscriptOperatorNeedsParens(const Expr *FullExpr) {
isa<ObjCPropertyRefExpr>(Expr) ||
isa<ObjCProtocolExpr>(Expr) ||
isa<MemberExpr>(Expr) ||
isa<ObjCIvarRefExpr>(Expr) ||
isa<ParenExpr>(FullExpr) ||
isa<ParenListExpr>(Expr) ||
isa<SizeOfPackExpr>(Expr))
@ -650,6 +651,7 @@ static bool castOperatorNeedsParens(const Expr *FullExpr) {
isa<ObjCPropertyRefExpr>(Expr) ||
isa<ObjCProtocolExpr>(Expr) ||
isa<MemberExpr>(Expr) ||
isa<ObjCIvarRefExpr>(Expr) ||
isa<ParenExpr>(FullExpr) ||
isa<ParenListExpr>(Expr) ||
isa<SizeOfPackExpr>(Expr) ||

View File

@ -77,7 +77,9 @@ typedef const struct __CFString * CFStringRef;
#define PAIR(x) @#x, [NSNumber numberWithInt:(x)]
#define TWO(x) ((x), (x))
@interface I
@interface I {
NSArray *ivarArr;
}
@end
@implementation I
-(void) foo {
@ -138,6 +140,7 @@ typedef const struct __CFString * CFStringRef;
o = [*parr objectAtIndex:2];
void *hd;
o = [(NSArray*)hd objectAtIndex:2];
o = [ivarArr objectAtIndex:2];
}
@end

View File

@ -77,7 +77,9 @@ typedef const struct __CFString * CFStringRef;
#define PAIR(x) @#x, [NSNumber numberWithInt:(x)]
#define TWO(x) ((x), (x))
@interface I
@interface I {
NSArray *ivarArr;
}
@end
@implementation I
-(void) foo {
@ -138,6 +140,7 @@ typedef const struct __CFString * CFStringRef;
o = (*parr)[2];
void *hd;
o = ((NSArray*)hd)[2];
o = ivarArr[2];
}
@end