]> granicus.if.org Git - clang/commitdiff
[objcmt] When checking whether the subscripting methods are declared use
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 19 Jun 2012 02:22:02 +0000 (02:22 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 19 Jun 2012 02:22:02 +0000 (02:22 +0000)
ObjCInterfaceDec::lookupInstanceMethod to make sure we check categories as well
and update related tests.

rdar://11695288

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

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

index 465f18051aa3f075f3c7bf5b8c8cc4cec4b113d0..feecc70ec1450370197f73502317429ffe41bce7 100644 (file)
@@ -128,7 +128,7 @@ static bool rewriteToArraySubscriptGet(const ObjCInterfaceDecl *IFace,
                                        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 @@ static bool rewriteToDictionarySubscriptGet(const ObjCInterfaceDecl *IFace,
                                             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 @@ static bool rewriteToArraySubscriptSet(const ObjCInterfaceDecl *IFace,
   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 @@ static bool rewriteToDictionarySubscriptSet(const ObjCInterfaceDecl *IFace,
   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();
index fd100ca94daa97291023fd27bdd98b2f39638d75..4d941626c0d07b9bf9412a4dceb6b30eeeada812 100644 (file)
@@ -12,6 +12,9 @@ typedef const struct __CFString * CFStringRef;
 + (id)alloc;
 @end
 
+@protocol NSCopying
+@end
+
 @interface NSString : NSObject
 + (id)stringWithString:(NSString *)string;
 - (id)initWithString:(NSString *)aString;
@@ -19,7 +22,10 @@ typedef const struct __CFString * CFStringRef;
 
 @interface NSArray : NSObject
 - (id)objectAtIndex:(unsigned long)index;
-- (id)objectAtIndexedSubscript:(int)index;
+@end
+
+@interface NSArray (NSExtendedArray)
+- (id)objectAtIndexedSubscript:(unsigned)idx;
 @end
 
 @interface NSArray (NSArrayCreation)
@@ -32,16 +38,21 @@ typedef const struct __CFString * CFStringRef;
 - (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;
+@end
+
+@interface NSMutableArray (NSExtendedMutableArray)
+- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx;
 @end
 
 @interface NSDictionary : NSObject
+- (id)objectForKey:(id)aKey;
+@end
+
+@interface NSDictionary (NSExtendedDictionary)
 - (id)objectForKeyedSubscript:(id)key;
 @end
 
@@ -57,13 +68,14 @@ typedef const struct __CFString * CFStringRef;
 - (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;
+@end
+
+@interface NSMutableDictionary (NSExtendedMutableDictionary)
+- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key;
 @end
 
 @interface NSNumber : NSObject
index 4a65a23442899e5a7bb2ded2ee676670c5670ffc..6f7a723bc4731ce4e81d2ec41dd4e9c686efbf7b 100644 (file)
@@ -12,6 +12,9 @@ typedef const struct __CFString * CFStringRef;
 + (id)alloc;
 @end
 
+@protocol NSCopying
+@end
+
 @interface NSString : NSObject
 + (id)stringWithString:(NSString *)string;
 - (id)initWithString:(NSString *)aString;
@@ -19,7 +22,10 @@ typedef const struct __CFString * CFStringRef;
 
 @interface NSArray : NSObject
 - (id)objectAtIndex:(unsigned long)index;
-- (id)objectAtIndexedSubscript:(int)index;
+@end
+
+@interface NSArray (NSExtendedArray)
+- (id)objectAtIndexedSubscript:(unsigned)idx;
 @end
 
 @interface NSArray (NSArrayCreation)
@@ -32,16 +38,21 @@ typedef const struct __CFString * CFStringRef;
 - (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;
+@end
+
+@interface NSMutableArray (NSExtendedMutableArray)
+- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx;
 @end
 
 @interface NSDictionary : NSObject
+- (id)objectForKey:(id)aKey;
+@end
+
+@interface NSDictionary (NSExtendedDictionary)
 - (id)objectForKeyedSubscript:(id)key;
 @end
 
@@ -57,13 +68,14 @@ typedef const struct __CFString * CFStringRef;
 - (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;
+@end
+
+@interface NSMutableDictionary (NSExtendedMutableDictionary)
+- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key;
 @end
 
 @interface NSNumber : NSObject
index 6d626c4683decafe6fca3f0c462545dc49e8ba66..e9ed788275d7fec2a0993d4d8f3a257cd2a783ee 100644 (file)
@@ -12,6 +12,9 @@ typedef const struct __CFString * CFStringRef;
 + (id)alloc;
 @end
 
+@protocol NSCopying
+@end
+
 @interface NSString : NSObject
 + (id)stringWithString:(NSString *)string;
 - (id)initWithString:(NSString *)aString;
@@ -19,7 +22,10 @@ typedef const struct __CFString * CFStringRef;
 
 @interface NSArray : NSObject
 - (id)objectAtIndex:(unsigned long)index;
-- (id)objectAtIndexedSubscript:(int)index;
+@end
+
+@interface NSArray (NSExtendedArray)
+- (id)objectAtIndexedSubscript:(unsigned)idx;
 @end
 
 @interface NSArray (NSArrayCreation)
@@ -32,16 +38,21 @@ typedef const struct __CFString * CFStringRef;
 - (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;
+@end
+
+@interface NSMutableArray (NSExtendedMutableArray)
+- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx;
 @end
 
 @interface NSDictionary : NSObject
+- (id)objectForKey:(id)aKey;
+@end
+
+@interface NSDictionary (NSExtendedDictionary)
 - (id)objectForKeyedSubscript:(id)key;
 @end
 
@@ -57,13 +68,14 @@ typedef const struct __CFString * CFStringRef;
 - (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;
+@end
+
+@interface NSMutableDictionary (NSExtendedMutableDictionary)
+- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key;
 @end
 
 @interface NSNumber : NSObject
index a4eca6a447d9a5125f60f571ae9cd38c4f024aba..4e49c5e344efeb88ccac8e2c64637999dbb7a5d1 100644 (file)
@@ -12,6 +12,9 @@ typedef const struct __CFString * CFStringRef;
 + (id)alloc;
 @end
 
+@protocol NSCopying
+@end
+
 @interface NSString : NSObject
 + (id)stringWithString:(NSString *)string;
 - (id)initWithString:(NSString *)aString;
@@ -19,7 +22,10 @@ typedef const struct __CFString * CFStringRef;
 
 @interface NSArray : NSObject
 - (id)objectAtIndex:(unsigned long)index;
-- (id)objectAtIndexedSubscript:(int)index;
+@end
+
+@interface NSArray (NSExtendedArray)
+- (id)objectAtIndexedSubscript:(unsigned)idx;
 @end
 
 @interface NSArray (NSArrayCreation)
@@ -32,16 +38,21 @@ typedef const struct __CFString * CFStringRef;
 - (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;
+@end
+
+@interface NSMutableArray (NSExtendedMutableArray)
+- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx;
 @end
 
 @interface NSDictionary : NSObject
+- (id)objectForKey:(id)aKey;
+@end
+
+@interface NSDictionary (NSExtendedDictionary)
 - (id)objectForKeyedSubscript:(id)key;
 @end
 
@@ -57,13 +68,14 @@ typedef const struct __CFString * CFStringRef;
 - (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;
+@end
+
+@interface NSMutableDictionary (NSExtendedMutableDictionary)
+- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key;
 @end
 
 @interface NSNumber : NSObject