1// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.cocoa.RetainCount -verify %s
2// 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 marked
5// as cf_audited_transfer.
6
7#pragma clang arc_cf_code_audited begin
8typedef const void * CFTypeRef;
9extern CFTypeRef CFRetain(CFTypeRef cf);
10extern void CFRelease(CFTypeRef cf);
11
12extern CFTypeRef CFCreateSomethingAudited();
13#pragma clang arc_cf_code_audited end
14
15extern CFTypeRef CFCreateSomethingUnaudited();
16
17void testAudited() {
18  CFTypeRef obj = CFCreateSomethingAudited(); // no-warning
19  CFRelease(obj); // no-warning
20
21  CFTypeRef obj2 = CFCreateSomethingAudited(); // expected-warning{{leak}}
22  CFRetain(obj2); // no-warning
23  CFRelease(obj2); // no-warning
24}
25
26void testUnaudited() {
27  CFTypeRef obj = CFCreateSomethingUnaudited(); // no-warning
28  CFRelease(obj); // no-warning
29
30  CFTypeRef obj2 = CFCreateSomethingUnaudited(); // expected-warning{{leak}}
31  CFRetain(obj2); // no-warning
32  CFRelease(obj2); // no-warning
33}
34