Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Analysis / retain-release-cf-audited.m
blob643c4a24d413b60de1eb238148d0c889f905f0ea
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++
4 // The special thing about this file is that CFRetain and CFRelease are marked
5 // as cf_audited_transfer.
7 #pragma clang arc_cf_code_audited begin
8 typedef const void * CFTypeRef;
9 extern CFTypeRef CFRetain(CFTypeRef cf);
10 extern void CFRelease(CFTypeRef cf);
12 extern CFTypeRef CFCreateSomethingAudited(void);
13 #pragma clang arc_cf_code_audited end
15 extern CFTypeRef CFCreateSomethingUnaudited(void);
17 void testAudited(void) {
18   CFTypeRef obj = CFCreateSomethingAudited(); // no-warning
19   CFRelease(obj); // no-warning
21   CFTypeRef obj2 = CFCreateSomethingAudited(); // expected-warning{{leak}}
22   CFRetain(obj2); // no-warning
23   CFRelease(obj2); // no-warning
26 void testUnaudited(void) {
27   CFTypeRef obj = CFCreateSomethingUnaudited(); // no-warning
28   CFRelease(obj); // no-warning
30   CFTypeRef obj2 = CFCreateSomethingUnaudited(); // expected-warning{{leak}}
31   CFRetain(obj2); // no-warning
32   CFRelease(obj2); // no-warning