Home | History | Annotate | Download | only in Analysis
      1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -verify %s
      2 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -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
      8 typedef const void * CFTypeRef;
      9 extern CFTypeRef CFRetain(CFTypeRef cf);
     10 extern void CFRelease(CFTypeRef cf);
     11 
     12 extern CFTypeRef CFCreateSomethingAudited();
     13 #pragma clang arc_cf_code_audited end
     14 
     15 extern CFTypeRef CFCreateSomethingUnaudited();
     16 
     17 void 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 
     26 void 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