brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · b78a676 Raw
57 lines · plain
1// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s2 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@end18 19@implementation Foo20 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@end35 36class RefCountedObject {37public:38  void ref() const;39  void deref() const;40  Ref<RefCountedObject> copy() const;41  void method();42};43 44@interface WrapperObj : NSObject45 46- (Ref<RefCountedObject>)_protectedWebExtensionControllerConfiguration;47 48@end49 50static void foo(WrapperObj *configuration) {51  configuration._protectedWebExtensionControllerConfiguration->copy();52}53 54void log(RefCountable* obj) {55  os_log_msg(os_log_create("WebKit", "DOM"), OS_LOG_TYPE_INFO, "obj: %p next: %p", obj, obj->next());56}57