objc-missing-hash.m
979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// RUN: %check_clang_tidy %s objc-missing-hash %t
typedef _Bool BOOL;
#define YES 1
#define NO 0
typedef unsigned int NSUInteger;
typedef void *id;
@interface NSObject
- (NSUInteger)hash;
- (BOOL)isEqual:(id)object;
@end
@interface MissingHash : NSObject
@end
@implementation MissingHash
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: 'MissingHash' implements -isEqual: without implementing -hash [objc-missing-hash]
- (BOOL)isEqual:(id)object {
return YES;
}
@end
@interface HasHash : NSObject
@end
@implementation HasHash
- (NSUInteger)hash {
return 0;
}
- (BOOL)isEqual:(id)object {
return YES;
}
@end
@interface NSArray : NSObject
@end
@interface MayHaveInheritedHash : NSArray
@end
@implementation MayHaveInheritedHash
- (BOOL)isEqual:(id)object {
return YES;
}
@end
@interface AnotherRootClass
@end
@interface NotDerivedFromNSObject : AnotherRootClass
@end
@implementation NotDerivedFromNSObject
- (BOOL)isEqual:(id)object {
return NO;
}
@end