diff options
author | Jordan Rupprecht <rupprecht@google.com> | 2019-05-14 21:58:59 +0000 |
---|---|---|
committer | Jordan Rupprecht <rupprecht@google.com> | 2019-05-14 21:58:59 +0000 |
commit | b35a2aa71f76a334a9c98c0a3c3995b5d902d2b9 (patch) | |
tree | cdff4a5d1a715d4ad622fd8f190128b54bebe440 /test/Analysis/retain-release.m | |
parent | 3748d41833787fcbf59cc5624e8d2b042a8991bc (diff) | |
parent | 741e05796da92b46d4f7bcbee00702ff37df6489 (diff) |
Creating branches/google/stable and tags/google/stable/2019-05-14 from r360103upstream/google/stable
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/google/stable@360714 91177308-0d34-0410-b5e6-96231b3b80d8
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); |