1 // RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s 2 3 #include "mock-types.h" 4 5 RefCountableAndCheckable* makeObj(); 6 CheckedRef<RefCountableAndCheckable> makeObjChecked(); 7 void someFunction(RefCountableAndCheckable*); 8 9 namespace call_args_unchecked_uncounted { 10 11 static void foo() { 12 someFunction(makeObj()); 13 // expected-warning@-1{{Call argument is uncounted and unsafe [alpha.webkit.UncountedCallArgsChecker]}} 14 } 15 16 } // namespace call_args_checked 17 18 namespace call_args_checked { 19 20 static void foo() { 21 CheckedPtr<RefCountableAndCheckable> ptr = makeObj(); 22 someFunction(ptr.get()); 23 } 24 25 static void bar() { 26 someFunction(CheckedPtr { makeObj() }.get()); 27 } 28 29 static void baz() { 30 someFunction(makeObjChecked().ptr()); 31 } 32 33 } // namespace call_args_checked 34 35 namespace call_args_default { 36 37 void someFunction(RefCountableAndCheckable* = makeObj()); 38 // expected-warning@-1{{Call argument is uncounted and unsafe [alpha.webkit.UncountedCallArgsChecker]}} 39 void otherFunction(RefCountableAndCheckable* = makeObjChecked().ptr()); 40 41 void foo() { 42 someFunction(); 43 otherFunction(); 44 } 45 46 } 47