[cfe-commits] r158697 - in /cfe/trunk: lib/Edit/RewriteObjCFoundationAPI.cpp test/ARCMT/objcmt-subscripting-literals-in-arc.m test/ARCMT/objcmt-subscripting-literals-in-arc.m.result test/ARCMT/objcmt-subscripting-literals.m test/ARCMT/objcmt-subscripting-literals.m.result

Argyrios Kyrtzidis akyrtzi at gmail.com
Mon Jun 18 19:22:03 PDT 2012


Author: akirtzidis
Date: Mon Jun 18 21:22:02 2012
New Revision: 158697

URL: http://llvm.org/viewvc/llvm-project?rev=158697&view=rev
Log:
[objcmt] When checking whether the subscripting methods are declared use
ObjCInterfaceDec::lookupInstanceMethod to make sure we check categories as well
and update related tests.

rdar://11695288

Modified:
    cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp
    cfe/trunk/test/ARCMT/objcmt-subscripting-literals-in-arc.m
    cfe/trunk/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result
    cfe/trunk/test/ARCMT/objcmt-subscripting-literals.m
    cfe/trunk/test/ARCMT/objcmt-subscripting-literals.m.result

Modified: cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp?rev=158697&r1=158696&r2=158697&view=diff
==============================================================================
--- cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp (original)
+++ cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp Mon Jun 18 21:22:02 2012
@@ -128,7 +128,7 @@
                                        const ObjCMessageExpr *Msg,
                                        const NSAPI &NS,
                                        Commit &commit) {
-  if (!IFace->getInstanceMethod(NS.getObjectAtIndexedSubscriptSelector()))
+  if (!IFace->lookupInstanceMethod(NS.getObjectAtIndexedSubscriptSelector()))
     return false;
   return rewriteToSubscriptGetCommon(Msg, commit);
 }
@@ -137,7 +137,7 @@
                                             const ObjCMessageExpr *Msg,
                                             const NSAPI &NS,
                                             Commit &commit) {
-  if (!IFace->getInstanceMethod(NS.getObjectForKeyedSubscriptSelector()))
+  if (!IFace->lookupInstanceMethod(NS.getObjectForKeyedSubscriptSelector()))
     return false;
   return rewriteToSubscriptGetCommon(Msg, commit);
 }
@@ -151,7 +151,7 @@
   const Expr *Rec = Msg->getInstanceReceiver();
   if (!Rec)
     return false;
-  if (!IFace->getInstanceMethod(NS.getSetObjectAtIndexedSubscriptSelector()))
+  if (!IFace->lookupInstanceMethod(NS.getSetObjectAtIndexedSubscriptSelector()))
     return false;
 
   SourceRange MsgRange = Msg->getSourceRange();
@@ -183,7 +183,7 @@
   const Expr *Rec = Msg->getInstanceReceiver();
   if (!Rec)
     return false;
-  if (!IFace->getInstanceMethod(NS.getSetObjectForKeyedSubscriptSelector()))
+  if (!IFace->lookupInstanceMethod(NS.getSetObjectForKeyedSubscriptSelector()))
     return false;
 
   SourceRange MsgRange = Msg->getSourceRange();

Modified: cfe/trunk/test/ARCMT/objcmt-subscripting-literals-in-arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-subscripting-literals-in-arc.m?rev=158697&r1=158696&r2=158697&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-subscripting-literals-in-arc.m (original)
+++ cfe/trunk/test/ARCMT/objcmt-subscripting-literals-in-arc.m Mon Jun 18 21:22:02 2012
@@ -12,6 +12,9 @@
 + (id)alloc;
 @end
 
+ at protocol NSCopying
+ at end
+
 @interface NSString : NSObject
 + (id)stringWithString:(NSString *)string;
 - (id)initWithString:(NSString *)aString;
@@ -19,7 +22,10 @@
 
 @interface NSArray : NSObject
 - (id)objectAtIndex:(unsigned long)index;
-- (id)objectAtIndexedSubscript:(int)index;
+ at end
+
+ at interface NSArray (NSExtendedArray)
+- (id)objectAtIndexedSubscript:(unsigned)idx;
 @end
 
 @interface NSArray (NSArrayCreation)
@@ -32,16 +38,21 @@
 - (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
 - (id)initWithObjects:(id)firstObj, ...;
 - (id)initWithArray:(NSArray *)array;
-
-- (id)objectAtIndex:(unsigned long)index;
 @end
 
 @interface NSMutableArray : NSArray
 - (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
-- (void)setObject:(id)object atIndexedSubscript:(int)index;
+ at end
+
+ at interface NSMutableArray (NSExtendedMutableArray)
+- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx;
 @end
 
 @interface NSDictionary : NSObject
+- (id)objectForKey:(id)aKey;
+ at end
+
+ at interface NSDictionary (NSExtendedDictionary)
 - (id)objectForKeyedSubscript:(id)key;
 @end
 
@@ -57,13 +68,14 @@
 - (id)initWithObjectsAndKeys:(id)firstObject, ...;
 - (id)initWithDictionary:(NSDictionary *)otherDictionary;
 - (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
-
-- (id)objectForKey:(id)aKey;
 @end
 
 @interface NSMutableDictionary : NSDictionary
 - (void)setObject:(id)anObject forKey:(id)aKey;
-- (void)setObject:(id)object forKeyedSubscript:(id)key;
+ at end
+
+ at interface NSMutableDictionary (NSExtendedMutableDictionary)
+- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key;
 @end
 
 @interface NSNumber : NSObject

Modified: cfe/trunk/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result?rev=158697&r1=158696&r2=158697&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result Mon Jun 18 21:22:02 2012
@@ -12,6 +12,9 @@
 + (id)alloc;
 @end
 
+ at protocol NSCopying
+ at end
+
 @interface NSString : NSObject
 + (id)stringWithString:(NSString *)string;
 - (id)initWithString:(NSString *)aString;
@@ -19,7 +22,10 @@
 
 @interface NSArray : NSObject
 - (id)objectAtIndex:(unsigned long)index;
-- (id)objectAtIndexedSubscript:(int)index;
+ at end
+
+ at interface NSArray (NSExtendedArray)
+- (id)objectAtIndexedSubscript:(unsigned)idx;
 @end
 
 @interface NSArray (NSArrayCreation)
@@ -32,16 +38,21 @@
 - (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
 - (id)initWithObjects:(id)firstObj, ...;
 - (id)initWithArray:(NSArray *)array;
-
-- (id)objectAtIndex:(unsigned long)index;
 @end
 
 @interface NSMutableArray : NSArray
 - (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
-- (void)setObject:(id)object atIndexedSubscript:(int)index;
+ at end
+
+ at interface NSMutableArray (NSExtendedMutableArray)
+- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx;
 @end
 
 @interface NSDictionary : NSObject
+- (id)objectForKey:(id)aKey;
+ at end
+
+ at interface NSDictionary (NSExtendedDictionary)
 - (id)objectForKeyedSubscript:(id)key;
 @end
 
@@ -57,13 +68,14 @@
 - (id)initWithObjectsAndKeys:(id)firstObject, ...;
 - (id)initWithDictionary:(NSDictionary *)otherDictionary;
 - (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
-
-- (id)objectForKey:(id)aKey;
 @end
 
 @interface NSMutableDictionary : NSDictionary
 - (void)setObject:(id)anObject forKey:(id)aKey;
-- (void)setObject:(id)object forKeyedSubscript:(id)key;
+ at end
+
+ at interface NSMutableDictionary (NSExtendedMutableDictionary)
+- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key;
 @end
 
 @interface NSNumber : NSObject

Modified: cfe/trunk/test/ARCMT/objcmt-subscripting-literals.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-subscripting-literals.m?rev=158697&r1=158696&r2=158697&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-subscripting-literals.m (original)
+++ cfe/trunk/test/ARCMT/objcmt-subscripting-literals.m Mon Jun 18 21:22:02 2012
@@ -12,6 +12,9 @@
 + (id)alloc;
 @end
 
+ at protocol NSCopying
+ at end
+
 @interface NSString : NSObject
 + (id)stringWithString:(NSString *)string;
 - (id)initWithString:(NSString *)aString;
@@ -19,7 +22,10 @@
 
 @interface NSArray : NSObject
 - (id)objectAtIndex:(unsigned long)index;
-- (id)objectAtIndexedSubscript:(int)index;
+ at end
+
+ at interface NSArray (NSExtendedArray)
+- (id)objectAtIndexedSubscript:(unsigned)idx;
 @end
 
 @interface NSArray (NSArrayCreation)
@@ -32,16 +38,21 @@
 - (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
 - (id)initWithObjects:(id)firstObj, ...;
 - (id)initWithArray:(NSArray *)array;
-
-- (id)objectAtIndex:(unsigned long)index;
 @end
 
 @interface NSMutableArray : NSArray
 - (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
-- (void)setObject:(id)object atIndexedSubscript:(int)index;
+ at end
+
+ at interface NSMutableArray (NSExtendedMutableArray)
+- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx;
 @end
 
 @interface NSDictionary : NSObject
+- (id)objectForKey:(id)aKey;
+ at end
+
+ at interface NSDictionary (NSExtendedDictionary)
 - (id)objectForKeyedSubscript:(id)key;
 @end
 
@@ -57,13 +68,14 @@
 - (id)initWithObjectsAndKeys:(id)firstObject, ...;
 - (id)initWithDictionary:(NSDictionary *)otherDictionary;
 - (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
-
-- (id)objectForKey:(id)aKey;
 @end
 
 @interface NSMutableDictionary : NSDictionary
 - (void)setObject:(id)anObject forKey:(id)aKey;
-- (void)setObject:(id)object forKeyedSubscript:(id)key;
+ at end
+
+ at interface NSMutableDictionary (NSExtendedMutableDictionary)
+- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key;
 @end
 
 @interface NSNumber : NSObject

Modified: cfe/trunk/test/ARCMT/objcmt-subscripting-literals.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-subscripting-literals.m.result?rev=158697&r1=158696&r2=158697&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-subscripting-literals.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-subscripting-literals.m.result Mon Jun 18 21:22:02 2012
@@ -12,6 +12,9 @@
 + (id)alloc;
 @end
 
+ at protocol NSCopying
+ at end
+
 @interface NSString : NSObject
 + (id)stringWithString:(NSString *)string;
 - (id)initWithString:(NSString *)aString;
@@ -19,7 +22,10 @@
 
 @interface NSArray : NSObject
 - (id)objectAtIndex:(unsigned long)index;
-- (id)objectAtIndexedSubscript:(int)index;
+ at end
+
+ at interface NSArray (NSExtendedArray)
+- (id)objectAtIndexedSubscript:(unsigned)idx;
 @end
 
 @interface NSArray (NSArrayCreation)
@@ -32,16 +38,21 @@
 - (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
 - (id)initWithObjects:(id)firstObj, ...;
 - (id)initWithArray:(NSArray *)array;
-
-- (id)objectAtIndex:(unsigned long)index;
 @end
 
 @interface NSMutableArray : NSArray
 - (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
-- (void)setObject:(id)object atIndexedSubscript:(int)index;
+ at end
+
+ at interface NSMutableArray (NSExtendedMutableArray)
+- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx;
 @end
 
 @interface NSDictionary : NSObject
+- (id)objectForKey:(id)aKey;
+ at end
+
+ at interface NSDictionary (NSExtendedDictionary)
 - (id)objectForKeyedSubscript:(id)key;
 @end
 
@@ -57,13 +68,14 @@
 - (id)initWithObjectsAndKeys:(id)firstObject, ...;
 - (id)initWithDictionary:(NSDictionary *)otherDictionary;
 - (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
-
-- (id)objectForKey:(id)aKey;
 @end
 
 @interface NSMutableDictionary : NSDictionary
 - (void)setObject:(id)anObject forKey:(id)aKey;
-- (void)setObject:(id)object forKeyedSubscript:(id)key;
+ at end
+
+ at interface NSMutableDictionary (NSExtendedMutableDictionary)
+- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key;
 @end
 
 @interface NSNumber : NSObject





More information about the cfe-commits mailing list