diff options
Diffstat (limited to 'test/Analysis/retain-release.m')
-rw-r--r-- | test/Analysis/retain-release.m | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m index 5e858f9f54..a5f24af749 100644 --- a/test/Analysis/retain-release.m +++ b/test/Analysis/retain-release.m @@ -2,7 +2,7 @@ // RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10\ // RUN: -analyzer-checker=core,osx.coreFoundation.CFRetainRelease\ // RUN: -analyzer-checker=osx.cocoa.ClassRelease,osx.cocoa.RetainCount\ -// RUN: -analyzer-checker=debug.ExprInspection -fblocks -verify %s\ +// RUN: -analyzer-checker=debug.ExprInspection -fblocks -verify=expected,C %s\ // RUN: -Wno-objc-root-class -analyzer-output=plist -o %t.objc.plist // RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10\ // RUN: -analyzer-checker=core,osx.coreFoundation.CFRetainRelease\ @@ -10,6 +10,13 @@ // RUN: -analyzer-checker=debug.ExprInspection -fblocks -verify %s\ // RUN: -Wno-objc-root-class -analyzer-output=plist -o %t.objcpp.plist\ // RUN: -x objective-c++ -std=gnu++98 +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10\ +// RUN: -analyzer-checker=core,osx.coreFoundation.CFRetainRelease\ +// RUN: -analyzer-checker=osx.cocoa.ClassRelease,osx.cocoa.RetainCount\ +// RUN: -analyzer-checker=debug.ExprInspection -fblocks -verify %s\ +// RUN: -Wno-objc-root-class -x objective-c++ -std=gnu++98\ +// RUN: -analyzer-config osx.cocoa.RetainCount:TrackNSCFStartParam=true\ +// RUN: -DTRACK_START_PARAM // RUN: cat %t.objcpp.plist | %diff_plist %S/Inputs/expected-plists/retain-release.m.objcpp.plist - // RUN: cat %t.objc.plist | %diff_plist %S/Inputs/expected-plists/retain-release.m.objc.plist - @@ -620,11 +627,30 @@ void f16(int x, CFTypeRef p) { } } +#ifdef TRACK_START_PARAM +@interface TestParam : NSObject +- (void) f:(id) object; +@end + +@implementation TestParam +- (void) f:(id) object { // expected-warning{{Potential leak of an object of type 'id'}} + [object retain]; + [object retain]; +} +@end +#endif + // Test that an object is non-null after CFRetain/CFRelease/CFMakeCollectable/CFAutorelease. void f17(int x, CFTypeRef p) { +#ifdef TRACK_START_PARAM + // expected-warning@-2{{Potential leak of an object of type 'CFTypeRef'}} +#endif switch (x) { case 0: CFRelease(p); +#ifdef TRACK_START_PARAM + // expected-warning@-2{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} +#endif if (!p) CFRelease(0); // no-warning break; @@ -647,6 +673,9 @@ void f17(int x, CFTypeRef p) { break; } } +#ifdef TRACK_START_PARAM + // expected-warning@-2{{Object autoreleased too many times}} +#endif __attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map *isl_basic_map_cow(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap); @@ -1202,7 +1231,7 @@ typedef __darwin_pthread_attr_t pthread_attr_t; typedef unsigned long __darwin_pthread_key_t; typedef __darwin_pthread_key_t pthread_key_t; -int pthread_create(pthread_t *, const pthread_attr_t *, +int pthread_create(pthread_t *, const pthread_attr_t *, // C-warning{{declaration of built-in function 'pthread_create' requires inclusion of the header <pthread.h>}} void *(*)(void *), void *); int pthread_setspecific(pthread_key_t key, const void *value); |