]> granicus.if.org Git - clang/commitdiff
[objcmt] Don't add redundant parentheses when migrating subscripting of an ivar.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 22 May 2012 00:47:53 +0000 (00:47 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 22 May 2012 00:47:53 +0000 (00:47 +0000)
rdar://11501256

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157227 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Edit/RewriteObjCFoundationAPI.cpp
test/ARCMT/objcmt-subscripting-literals.m
test/ARCMT/objcmt-subscripting-literals.m.result

index 846d58fc2cbae9e2c8c1fbc865608bff57c36d37..7445700cc49ff124cfbaa491c550e13dc1301a28 100644 (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) ||
index 0371e2e2ca6c8c3f05ffa4cd5a0278315ca459ee..6d626c4683decafe6fca3f0c462545dc49e8ba66 100644 (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
 
index 333d0b4c388e3dca9bed98141e20d88a308a0b36..a4eca6a447d9a5125f60f571ae9cd38c4f024aba 100644 (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