xref: /minix3/external/bsd/llvm/dist/clang/test/Analysis/retain-release-cf-audited.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -verify %s
2*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -verify %s -x objective-c++
3*f4a2713aSLionel Sambuc
4*f4a2713aSLionel Sambuc// The special thing about this file is that CFRetain and CFRelease are marked
5*f4a2713aSLionel Sambuc// as cf_audited_transfer.
6*f4a2713aSLionel Sambuc
7*f4a2713aSLionel Sambuc#pragma clang arc_cf_code_audited begin
8*f4a2713aSLionel Sambuctypedef const void * CFTypeRef;
9*f4a2713aSLionel Sambucextern CFTypeRef CFRetain(CFTypeRef cf);
10*f4a2713aSLionel Sambucextern void CFRelease(CFTypeRef cf);
11*f4a2713aSLionel Sambuc
12*f4a2713aSLionel Sambucextern CFTypeRef CFCreateSomethingAudited();
13*f4a2713aSLionel Sambuc#pragma clang arc_cf_code_audited end
14*f4a2713aSLionel Sambuc
15*f4a2713aSLionel Sambucextern CFTypeRef CFCreateSomethingUnaudited();
16*f4a2713aSLionel Sambuc
17*f4a2713aSLionel Sambucvoid testAudited() {
18*f4a2713aSLionel Sambuc  CFTypeRef obj = CFCreateSomethingAudited(); // no-warning
19*f4a2713aSLionel Sambuc  CFRelease(obj); // no-warning
20*f4a2713aSLionel Sambuc
21*f4a2713aSLionel Sambuc  CFTypeRef obj2 = CFCreateSomethingAudited(); // expected-warning{{leak}}
22*f4a2713aSLionel Sambuc  CFRetain(obj2); // no-warning
23*f4a2713aSLionel Sambuc  CFRelease(obj2); // no-warning
24*f4a2713aSLionel Sambuc}
25*f4a2713aSLionel Sambuc
26*f4a2713aSLionel Sambucvoid testUnaudited() {
27*f4a2713aSLionel Sambuc  CFTypeRef obj = CFCreateSomethingUnaudited(); // no-warning
28*f4a2713aSLionel Sambuc  CFRelease(obj); // no-warning
29*f4a2713aSLionel Sambuc
30*f4a2713aSLionel Sambuc  CFTypeRef obj2 = CFCreateSomethingUnaudited(); // expected-warning{{leak}}
31*f4a2713aSLionel Sambuc  CFRetain(obj2); // no-warning
32*f4a2713aSLionel Sambuc  CFRelease(obj2); // no-warning
33*f4a2713aSLionel Sambuc}
34