| 1 |
// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s |
| 2 |
|
| 3 |
#import "mock-types.h" |
| 4 |
#import "mock-system-header.h" |
| 5 |
#import "../../Inputs/system-header-simulator-for-objc-dealloc.h" |
| 6 |
|
| 7 |
@interface Foo : NSObject { |
| 8 |
const Ref<RefCountable> _obj1; |
| 9 |
const RefPtr<RefCountable> _obj2; |
| 10 |
Ref<RefCountable> _obj3; |
| 11 |
} |
| 12 |
|
| 13 |
@property (nonatomic, readonly) RefPtr<RefCountable> countable; |
| 14 |
|
| 15 |
- (void)execute; |
| 16 |
- (RefPtr<RefCountable>)_protectedRefCountable; |
| 17 |
@end |
| 18 |
|
| 19 |
@implementation Foo |
| 20 |
|
| 21 |
- (void)execute { |
| 22 |
self._protectedRefCountable->method(); |
| 23 |
_obj1->method(); |
| 24 |
_obj1.get().method(); |
| 25 |
(*_obj2).method(); |
| 26 |
_obj3->method(); |
| 27 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 28 |
} |
| 29 |
|
| 30 |
- (RefPtr<RefCountable>)_protectedRefCountable { |
| 31 |
return _countable; |
| 32 |
} |
| 33 |
|
| 34 |
@end |
| 35 |
|
| 36 |
class RefCountedObject { |
| 37 |
public: |
| 38 |
void ref() const; |
| 39 |
void deref() const; |
| 40 |
Ref<RefCountedObject> copy() const; |
| 41 |
void method(); |
| 42 |
}; |
| 43 |
|
| 44 |
@interface WrapperObj : NSObject |
| 45 |
|
| 46 |
- (Ref<RefCountedObject>)_protectedWebExtensionControllerConfiguration; |
| 47 |
|
| 48 |
@end |
| 49 |
|
| 50 |
static void foo(WrapperObj *configuration) { |
| 51 |
configuration._protectedWebExtensionControllerConfiguration->copy(); |
| 52 |
} |
| 53 |
|
| 54 |
void log(RefCountable* obj) { |
| 55 |
os_log_msg(os_log_create("WebKit", "DOM"), OS_LOG_TYPE_INFO, "obj: %p next: %p", obj, obj->next()); |
| 56 |
} |