Skip to content
Snippets Groups Projects
Commit 12b732a8 authored by Argyrios Kyrtzidis's avatar Argyrios Kyrtzidis
Browse files

[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158697 91177308-0d34-0410-b5e6-96231b3b80d8
parent 8af669f2
No related branches found
No related tags found
No related merge requests found
...@@ -128,7 +128,7 @@ static bool rewriteToArraySubscriptGet(const ObjCInterfaceDecl *IFace, ...@@ -128,7 +128,7 @@ static bool rewriteToArraySubscriptGet(const ObjCInterfaceDecl *IFace,
const ObjCMessageExpr *Msg, const ObjCMessageExpr *Msg,
const NSAPI &NS, const NSAPI &NS,
Commit &commit) { Commit &commit) {
if (!IFace->getInstanceMethod(NS.getObjectAtIndexedSubscriptSelector())) if (!IFace->lookupInstanceMethod(NS.getObjectAtIndexedSubscriptSelector()))
return false; return false;
return rewriteToSubscriptGetCommon(Msg, commit); return rewriteToSubscriptGetCommon(Msg, commit);
} }
...@@ -137,7 +137,7 @@ static bool rewriteToDictionarySubscriptGet(const ObjCInterfaceDecl *IFace, ...@@ -137,7 +137,7 @@ static bool rewriteToDictionarySubscriptGet(const ObjCInterfaceDecl *IFace,
const ObjCMessageExpr *Msg, const ObjCMessageExpr *Msg,
const NSAPI &NS, const NSAPI &NS,
Commit &commit) { Commit &commit) {
if (!IFace->getInstanceMethod(NS.getObjectForKeyedSubscriptSelector())) if (!IFace->lookupInstanceMethod(NS.getObjectForKeyedSubscriptSelector()))
return false; return false;
return rewriteToSubscriptGetCommon(Msg, commit); return rewriteToSubscriptGetCommon(Msg, commit);
} }
...@@ -151,7 +151,7 @@ static bool rewriteToArraySubscriptSet(const ObjCInterfaceDecl *IFace, ...@@ -151,7 +151,7 @@ static bool rewriteToArraySubscriptSet(const ObjCInterfaceDecl *IFace,
const Expr *Rec = Msg->getInstanceReceiver(); const Expr *Rec = Msg->getInstanceReceiver();
if (!Rec) if (!Rec)
return false; return false;
if (!IFace->getInstanceMethod(NS.getSetObjectAtIndexedSubscriptSelector())) if (!IFace->lookupInstanceMethod(NS.getSetObjectAtIndexedSubscriptSelector()))
return false; return false;
SourceRange MsgRange = Msg->getSourceRange(); SourceRange MsgRange = Msg->getSourceRange();
...@@ -183,7 +183,7 @@ static bool rewriteToDictionarySubscriptSet(const ObjCInterfaceDecl *IFace, ...@@ -183,7 +183,7 @@ static bool rewriteToDictionarySubscriptSet(const ObjCInterfaceDecl *IFace,
const Expr *Rec = Msg->getInstanceReceiver(); const Expr *Rec = Msg->getInstanceReceiver();
if (!Rec) if (!Rec)
return false; return false;
if (!IFace->getInstanceMethod(NS.getSetObjectForKeyedSubscriptSelector())) if (!IFace->lookupInstanceMethod(NS.getSetObjectForKeyedSubscriptSelector()))
return false; return false;
SourceRange MsgRange = Msg->getSourceRange(); SourceRange MsgRange = Msg->getSourceRange();
......
...@@ -12,6 +12,9 @@ typedef const struct __CFString * CFStringRef; ...@@ -12,6 +12,9 @@ typedef const struct __CFString * CFStringRef;
+ (id)alloc; + (id)alloc;
@end @end
@protocol NSCopying
@end
@interface NSString : NSObject @interface NSString : NSObject
+ (id)stringWithString:(NSString *)string; + (id)stringWithString:(NSString *)string;
- (id)initWithString:(NSString *)aString; - (id)initWithString:(NSString *)aString;
...@@ -19,7 +22,10 @@ typedef const struct __CFString * CFStringRef; ...@@ -19,7 +22,10 @@ typedef const struct __CFString * CFStringRef;
@interface NSArray : NSObject @interface NSArray : NSObject
- (id)objectAtIndex:(unsigned long)index; - (id)objectAtIndex:(unsigned long)index;
- (id)objectAtIndexedSubscript:(int)index; @end
@interface NSArray (NSExtendedArray)
- (id)objectAtIndexedSubscript:(unsigned)idx;
@end @end
@interface NSArray (NSArrayCreation) @interface NSArray (NSArrayCreation)
...@@ -32,16 +38,21 @@ typedef const struct __CFString * CFStringRef; ...@@ -32,16 +38,21 @@ typedef const struct __CFString * CFStringRef;
- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; - (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
- (id)initWithObjects:(id)firstObj, ...; - (id)initWithObjects:(id)firstObj, ...;
- (id)initWithArray:(NSArray *)array; - (id)initWithArray:(NSArray *)array;
- (id)objectAtIndex:(unsigned long)index;
@end @end
@interface NSMutableArray : NSArray @interface NSMutableArray : NSArray
- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; - (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 @end
@interface NSDictionary : NSObject @interface NSDictionary : NSObject
- (id)objectForKey:(id)aKey;
@end
@interface NSDictionary (NSExtendedDictionary)
- (id)objectForKeyedSubscript:(id)key; - (id)objectForKeyedSubscript:(id)key;
@end @end
...@@ -57,13 +68,14 @@ typedef const struct __CFString * CFStringRef; ...@@ -57,13 +68,14 @@ typedef const struct __CFString * CFStringRef;
- (id)initWithObjectsAndKeys:(id)firstObject, ...; - (id)initWithObjectsAndKeys:(id)firstObject, ...;
- (id)initWithDictionary:(NSDictionary *)otherDictionary; - (id)initWithDictionary:(NSDictionary *)otherDictionary;
- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
- (id)objectForKey:(id)aKey;
@end @end
@interface NSMutableDictionary : NSDictionary @interface NSMutableDictionary : NSDictionary
- (void)setObject:(id)anObject forKey:(id)aKey; - (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 @end
@interface NSNumber : NSObject @interface NSNumber : NSObject
......
...@@ -12,6 +12,9 @@ typedef const struct __CFString * CFStringRef; ...@@ -12,6 +12,9 @@ typedef const struct __CFString * CFStringRef;
+ (id)alloc; + (id)alloc;
@end @end
@protocol NSCopying
@end
@interface NSString : NSObject @interface NSString : NSObject
+ (id)stringWithString:(NSString *)string; + (id)stringWithString:(NSString *)string;
- (id)initWithString:(NSString *)aString; - (id)initWithString:(NSString *)aString;
...@@ -19,7 +22,10 @@ typedef const struct __CFString * CFStringRef; ...@@ -19,7 +22,10 @@ typedef const struct __CFString * CFStringRef;
@interface NSArray : NSObject @interface NSArray : NSObject
- (id)objectAtIndex:(unsigned long)index; - (id)objectAtIndex:(unsigned long)index;
- (id)objectAtIndexedSubscript:(int)index; @end
@interface NSArray (NSExtendedArray)
- (id)objectAtIndexedSubscript:(unsigned)idx;
@end @end
@interface NSArray (NSArrayCreation) @interface NSArray (NSArrayCreation)
...@@ -32,16 +38,21 @@ typedef const struct __CFString * CFStringRef; ...@@ -32,16 +38,21 @@ typedef const struct __CFString * CFStringRef;
- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; - (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
- (id)initWithObjects:(id)firstObj, ...; - (id)initWithObjects:(id)firstObj, ...;
- (id)initWithArray:(NSArray *)array; - (id)initWithArray:(NSArray *)array;
- (id)objectAtIndex:(unsigned long)index;
@end @end
@interface NSMutableArray : NSArray @interface NSMutableArray : NSArray
- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; - (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 @end
@interface NSDictionary : NSObject @interface NSDictionary : NSObject
- (id)objectForKey:(id)aKey;
@end
@interface NSDictionary (NSExtendedDictionary)
- (id)objectForKeyedSubscript:(id)key; - (id)objectForKeyedSubscript:(id)key;
@end @end
...@@ -57,13 +68,14 @@ typedef const struct __CFString * CFStringRef; ...@@ -57,13 +68,14 @@ typedef const struct __CFString * CFStringRef;
- (id)initWithObjectsAndKeys:(id)firstObject, ...; - (id)initWithObjectsAndKeys:(id)firstObject, ...;
- (id)initWithDictionary:(NSDictionary *)otherDictionary; - (id)initWithDictionary:(NSDictionary *)otherDictionary;
- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
- (id)objectForKey:(id)aKey;
@end @end
@interface NSMutableDictionary : NSDictionary @interface NSMutableDictionary : NSDictionary
- (void)setObject:(id)anObject forKey:(id)aKey; - (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 @end
@interface NSNumber : NSObject @interface NSNumber : NSObject
......
...@@ -12,6 +12,9 @@ typedef const struct __CFString * CFStringRef; ...@@ -12,6 +12,9 @@ typedef const struct __CFString * CFStringRef;
+ (id)alloc; + (id)alloc;
@end @end
@protocol NSCopying
@end
@interface NSString : NSObject @interface NSString : NSObject
+ (id)stringWithString:(NSString *)string; + (id)stringWithString:(NSString *)string;
- (id)initWithString:(NSString *)aString; - (id)initWithString:(NSString *)aString;
...@@ -19,7 +22,10 @@ typedef const struct __CFString * CFStringRef; ...@@ -19,7 +22,10 @@ typedef const struct __CFString * CFStringRef;
@interface NSArray : NSObject @interface NSArray : NSObject
- (id)objectAtIndex:(unsigned long)index; - (id)objectAtIndex:(unsigned long)index;
- (id)objectAtIndexedSubscript:(int)index; @end
@interface NSArray (NSExtendedArray)
- (id)objectAtIndexedSubscript:(unsigned)idx;
@end @end
@interface NSArray (NSArrayCreation) @interface NSArray (NSArrayCreation)
...@@ -32,16 +38,21 @@ typedef const struct __CFString * CFStringRef; ...@@ -32,16 +38,21 @@ typedef const struct __CFString * CFStringRef;
- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; - (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
- (id)initWithObjects:(id)firstObj, ...; - (id)initWithObjects:(id)firstObj, ...;
- (id)initWithArray:(NSArray *)array; - (id)initWithArray:(NSArray *)array;
- (id)objectAtIndex:(unsigned long)index;
@end @end
@interface NSMutableArray : NSArray @interface NSMutableArray : NSArray
- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; - (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 @end
@interface NSDictionary : NSObject @interface NSDictionary : NSObject
- (id)objectForKey:(id)aKey;
@end
@interface NSDictionary (NSExtendedDictionary)
- (id)objectForKeyedSubscript:(id)key; - (id)objectForKeyedSubscript:(id)key;
@end @end
...@@ -57,13 +68,14 @@ typedef const struct __CFString * CFStringRef; ...@@ -57,13 +68,14 @@ typedef const struct __CFString * CFStringRef;
- (id)initWithObjectsAndKeys:(id)firstObject, ...; - (id)initWithObjectsAndKeys:(id)firstObject, ...;
- (id)initWithDictionary:(NSDictionary *)otherDictionary; - (id)initWithDictionary:(NSDictionary *)otherDictionary;
- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
- (id)objectForKey:(id)aKey;
@end @end
@interface NSMutableDictionary : NSDictionary @interface NSMutableDictionary : NSDictionary
- (void)setObject:(id)anObject forKey:(id)aKey; - (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 @end
@interface NSNumber : NSObject @interface NSNumber : NSObject
......
...@@ -12,6 +12,9 @@ typedef const struct __CFString * CFStringRef; ...@@ -12,6 +12,9 @@ typedef const struct __CFString * CFStringRef;
+ (id)alloc; + (id)alloc;
@end @end
@protocol NSCopying
@end
@interface NSString : NSObject @interface NSString : NSObject
+ (id)stringWithString:(NSString *)string; + (id)stringWithString:(NSString *)string;
- (id)initWithString:(NSString *)aString; - (id)initWithString:(NSString *)aString;
...@@ -19,7 +22,10 @@ typedef const struct __CFString * CFStringRef; ...@@ -19,7 +22,10 @@ typedef const struct __CFString * CFStringRef;
@interface NSArray : NSObject @interface NSArray : NSObject
- (id)objectAtIndex:(unsigned long)index; - (id)objectAtIndex:(unsigned long)index;
- (id)objectAtIndexedSubscript:(int)index; @end
@interface NSArray (NSExtendedArray)
- (id)objectAtIndexedSubscript:(unsigned)idx;
@end @end
@interface NSArray (NSArrayCreation) @interface NSArray (NSArrayCreation)
...@@ -32,16 +38,21 @@ typedef const struct __CFString * CFStringRef; ...@@ -32,16 +38,21 @@ typedef const struct __CFString * CFStringRef;
- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; - (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
- (id)initWithObjects:(id)firstObj, ...; - (id)initWithObjects:(id)firstObj, ...;
- (id)initWithArray:(NSArray *)array; - (id)initWithArray:(NSArray *)array;
- (id)objectAtIndex:(unsigned long)index;
@end @end
@interface NSMutableArray : NSArray @interface NSMutableArray : NSArray
- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; - (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 @end
@interface NSDictionary : NSObject @interface NSDictionary : NSObject
- (id)objectForKey:(id)aKey;
@end
@interface NSDictionary (NSExtendedDictionary)
- (id)objectForKeyedSubscript:(id)key; - (id)objectForKeyedSubscript:(id)key;
@end @end
...@@ -57,13 +68,14 @@ typedef const struct __CFString * CFStringRef; ...@@ -57,13 +68,14 @@ typedef const struct __CFString * CFStringRef;
- (id)initWithObjectsAndKeys:(id)firstObject, ...; - (id)initWithObjectsAndKeys:(id)firstObject, ...;
- (id)initWithDictionary:(NSDictionary *)otherDictionary; - (id)initWithDictionary:(NSDictionary *)otherDictionary;
- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
- (id)objectForKey:(id)aKey;
@end @end
@interface NSMutableDictionary : NSDictionary @interface NSMutableDictionary : NSDictionary
- (void)setObject:(id)anObject forKey:(id)aKey; - (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 @end
@interface NSNumber : NSObject @interface NSNumber : NSObject
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment