1 // RUN: %clang_analyze_cc1 -std=c++14 -verify=no-retain-count %s \ 2 // RUN: -analyzer-checker=core,osx \ 3 // RUN: -analyzer-disable-checker osx.cocoa.RetainCount 4 // 5 // RUN: %clang_analyze_cc1 -std=c++14 -verify=no-os-object %s \ 6 // RUN: -analyzer-checker=core,osx \ 7 // RUN: -analyzer-disable-checker osx.OSObjectRetainCount 8 9 #include "os_object_base.h" 10 11 typedef const void * CFTypeRef; 12 extern CFTypeRef CFRetain(CFTypeRef cf); 13 extern void CFRelease(CFTypeRef cf); 14 15 #define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) 16 extern CFTypeRef CFCreate() CF_RETURNS_RETAINED; 17 18 using size_t = decltype(sizeof(int)); 19 cf_overrelease()20void cf_overrelease() { 21 CFTypeRef cf = CFCreate(); 22 CFRelease(cf); 23 CFRelease(cf); // no-os-object-warning{{Reference-counted object is used after it is released}} 24 } 25 osobject_overrelease()26void osobject_overrelease() { 27 OSObject *o = new OSObject; 28 o->release(); 29 o->release(); // no-retain-count-warning{{Reference-counted object is used after it is released}} 30 } 31