brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 643c4a2 Raw
34 lines · plain
1// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.cocoa.RetainCount -verify %s2// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.cocoa.RetainCount -verify %s -x objective-c++3 4// The special thing about this file is that CFRetain and CFRelease are marked5// as cf_audited_transfer.6 7#pragma clang arc_cf_code_audited begin8typedef const void * CFTypeRef;9extern CFTypeRef CFRetain(CFTypeRef cf);10extern void CFRelease(CFTypeRef cf);11 12extern CFTypeRef CFCreateSomethingAudited(void);13#pragma clang arc_cf_code_audited end14 15extern CFTypeRef CFCreateSomethingUnaudited(void);16 17void testAudited(void) {18  CFTypeRef obj = CFCreateSomethingAudited(); // no-warning19  CFRelease(obj); // no-warning20 21  CFTypeRef obj2 = CFCreateSomethingAudited(); // expected-warning{{leak}}22  CFRetain(obj2); // no-warning23  CFRelease(obj2); // no-warning24}25 26void testUnaudited(void) {27  CFTypeRef obj = CFCreateSomethingUnaudited(); // no-warning28  CFRelease(obj); // no-warning29 30  CFTypeRef obj2 = CFCreateSomethingUnaudited(); // expected-warning{{leak}}31  CFRetain(obj2); // no-warning32  CFRelease(obj2); // no-warning33}34