File tree Expand file tree Collapse file tree 5 files changed +21
-1
lines changed
lib/StaticAnalyzer/Checkers/WebKit
test/Analysis/Checkers/WebKit Expand file tree Collapse file tree 5 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -190,7 +190,6 @@ class RawPtrRefCallArgsChecker
190190 if (auto *InnerMsg =
191191 dyn_cast<ObjCMessageExpr>(Receiver->IgnoreParenCasts ())) {
192192 auto InnerSelector = InnerMsg->getSelector ();
193- auto SelName = Selector.getNameForSlot (0 );
194193 if (InnerSelector.getNameForSlot (0 ).starts_with (" alloc" ) &&
195194 (SelName.starts_with (" init" ) || SelName.starts_with (" _init" )))
196195 return ;
Original file line number Diff line number Diff line change @@ -160,6 +160,8 @@ __attribute__((objc_root_class))
160160- ( const char *)UTF8String ;
161161- (id )initWithUTF8String : (const char *)nullTerminatedCString ;
162162- (NSString *)copy ;
163+ - (NSString *)mutableCopy ;
164+ - (BOOL )isEqualToString : (NSString *)aString ;
163165+ (id )stringWithUTF8String : (const char *)nullTerminatedCString ;
164166@end
165167
@@ -198,6 +200,7 @@ extern NSApplication * NSApp;
198200+ (SomeObj *)sharedInstance ;
199201- (instancetype )_init ;
200202- (SomeObj *)mutableCopy ;
203+ - (BOOL )isEqual : (SomeObj *)other ;
201204- (SomeObj *)copyWithValue : (int )value ;
202205- (void )doWork ;
203206- (SomeObj *)other ;
Original file line number Diff line number Diff line change @@ -45,6 +45,10 @@ @implementation SomeObj {
4545 SomeObj *_other;
4646}
4747
48+ + (SomeObj *)sharedInstance {
49+ return nil ;
50+ }
51+
4852- (instancetype )_init {
4953 self = [super init ];
5054 _number = nil ;
@@ -61,6 +65,10 @@ - (SomeObj *)mutableCopy {
6165 return copy;
6266}
6367
68+ - (BOOL )isEqual : (SomeObj *)other {
69+ return self.value == other.value && self.next == other.next && _other == other.other ;
70+ }
71+
6472- (SomeObj *)copyWithValue : (int )value {
6573 auto *copy = [[SomeObj alloc ] init ];
6674 [copy setValue: _number];
Original file line number Diff line number Diff line change @@ -74,6 +74,10 @@ - (SomeObj *)mutableCopy {
7474 return copy;
7575}
7676
77+ - (BOOL )isEqual : (SomeObj *)other {
78+ return self.value == other.value && self.next == other.next && _other == other.other ;
79+ }
80+
7781- (SomeObj *)copyWithValue : (int )value {
7882 auto *copy = [[SomeObj alloc ] init ];
7983 // expected-warning@-1{{The return value is +1 and results in a memory leak [alpha.webkit.RetainPtrCtorAdoptChecker]}}
Original file line number Diff line number Diff line change 66SomeObj *provide ();
77void consume_obj (SomeObj*);
88
9+ NSString *provide_str ();
10+
911CFMutableArrayRef provide_cf ();
1012void consume_cf (CFMutableArrayRef);
1113
@@ -610,6 +612,10 @@ - (void)doWorkOnSelf {
610612 [self doWork: __null];
611613 [self doWork: nil ];
612614 [NSApp run ];
615+ [provide () isEqual: provide ()];
616+ [provide_str () isEqualToString: @" foo" ];
617+ [provide_str () copyWithZone: nullptr ];
618+ [provide_str () mutableCopy ];
613619}
614620
615621- (SomeObj *)getSomeObj {
You can’t perform that action at this time.
0 commit comments