diff options
| author | Devin Coughlin <dcoughlin@apple.com> | 2016-08-11 18:41:29 +0000 |
|---|---|---|
| committer | Devin Coughlin <dcoughlin@apple.com> | 2016-08-11 18:41:29 +0000 |
| commit | 81cc38cf9ad8fe2aaa3ac6203df4b5ff2d780ca4 (patch) | |
| tree | 8ff4b06fbcf67ce7c7eb580d001398ab93c43563 /clang/test | |
| parent | 932bce6ade232aebfa91ac03be2b47563e8c4a8a (diff) | |
| download | bcm5719-llvm-81cc38cf9ad8fe2aaa3ac6203df4b5ff2d780ca4.tar.gz bcm5719-llvm-81cc38cf9ad8fe2aaa3ac6203df4b5ff2d780ca4.zip | |
[analyzer] Teach RetainCountChecker about CVFooRetain
Change the retain count checker to treat CoreFoundation-style "CV"-prefixed
reference types from CoreVideo similarly to CoreGraphics types. With this
change, we treat CVFooRetain() on a CVFooRef type as a retain. CVFooRelease()
APIs are annotated as consuming their parameter, so this change prevents false
positives about incorrect decrements of reference counts.
<rdar://problem/27116090>
llvm-svn: 278382
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Analysis/retain-release.m | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/test/Analysis/retain-release.m b/clang/test/Analysis/retain-release.m index f0d91e34c1b..3acf86c7d9e 100644 --- a/clang/test/Analysis/retain-release.m +++ b/clang/test/Analysis/retain-release.m @@ -1247,6 +1247,26 @@ CVReturn rdar_7283567_2(CFAllocatorRef allocator, size_t width, size_t height, pixelBufferAttributes, pixelBufferOut) ; } +#pragma clang arc_cf_code_audited begin +typedef struct SomeOpaqueStruct *CMSampleBufferRef; +CVImageBufferRef _Nonnull CMSampleBufferGetImageBuffer(CMSampleBufferRef _Nonnull sbuf); +#pragma clang arc_cf_code_audited end + +CVBufferRef _Nullable CVBufferRetain(CVBufferRef _Nullable buffer); +void CVBufferRelease(CF_CONSUMED CVBufferRef _Nullable buffer); + +void testCVPrefixRetain(CMSampleBufferRef sbuf) { + // Make sure RetainCountChecker treats CVFooRetain() as a CF-style retain. + CVPixelBufferRef pixelBuf = CMSampleBufferGetImageBuffer(sbuf); + CVBufferRetain(pixelBuf); + CVBufferRelease(pixelBuf); // no-warning + + + // Make sure result of CVFooRetain() is the same as its argument. + CVPixelBufferRef pixelBufAlias = CVBufferRetain(pixelBuf); + CVBufferRelease(pixelBufAlias); // no-warning +} + //===----------------------------------------------------------------------===// // <rdar://problem/7358899> False leak associated with // CGBitmapContextCreateWithData |

