]> granicus.if.org Git - clang/commitdiff
retain/release checker: Add special handling of CGBitmapContextCreateWithData().
authorTed Kremenek <kremenek@apple.com>
Tue, 3 Nov 2009 05:34:07 +0000 (05:34 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 3 Nov 2009 05:34:07 +0000 (05:34 +0000)
Fixes: <rdar://problem/7358899>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85864 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CFRefCount.cpp
test/Analysis/retain-release.m

index c629ad1d961234bf06561411578ca473068e8c28..120d422d374aa1052ea6a69fce9dd067aae624e0 100644 (file)
@@ -1036,6 +1036,17 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) {
                                    DoNothing);
         }
         break;
+        
+      case 29:
+        if (!memcmp(FName, "CGBitmapContextCreateWithData", 29)) {
+          // FIXES: <rdar://problem/7358899>
+          // Eventually this can be improved by recognizing that 'releaseInfo'
+          // passed to CGBitmapContextCreateWithData is released via
+          // a callback and doing full IPA to make sure this is done correctly.
+          ScratchArgs = AF.Add(ScratchArgs, 8, StopTracking);
+          S = getPersistentSummary(RetEffect::MakeNoRet(), DoNothing,DoNothing);          
+        }
+        break;
 
       case 32:
         if (!memcmp(FName, "IOServiceAddMatchingNotification", 32)) {
index e620037b2c14fdcf95b1a08e54ac13c2cc6c9ffa..19ea5ed1c93c2248bf2cba151193e0f9737f78a9 100644 (file)
@@ -1097,6 +1097,32 @@ CVReturn rdar_7283567_2(CFAllocatorRef allocator, size_t width, size_t height,
               pixelBufferAttributes, pixelBufferOut) ;
 }
 
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7358899> False leak associated with 
+//  CGBitmapContextCreateWithData
+//===----------------------------------------------------------------------===//
+typedef uint32_t CGBitmapInfo;
+typedef void (*CGBitmapContextReleaseDataCallback)(void *releaseInfo, void *data);
+    
+CGContextRef CGBitmapContextCreateWithData(void *data,
+    size_t width, size_t height, size_t bitsPerComponent,
+    size_t bytesPerRow, CGColorSpaceRef space, CGBitmapInfo bitmapInfo,
+    CGBitmapContextReleaseDataCallback releaseCallback, void *releaseInfo);
+
+void rdar_7358899(void *data,
+      size_t width, size_t height, size_t bitsPerComponent,
+      size_t bytesPerRow, CGColorSpaceRef space, CGBitmapInfo bitmapInfo,
+      CGBitmapContextReleaseDataCallback releaseCallback) {
+
+    // For the allocated object, it doesn't really matter what type it is
+    // for the purpose of this test.  All we want to show is that
+    // this is freed later by the callback.
+    NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning
+
+  CGBitmapContextCreateWithData(data, width, height, bitsPerComponent,
+    bytesPerRow, space, bitmapInfo, releaseCallback, number);
+}
+
 //===----------------------------------------------------------------------===//
 // <rdar://problem/7265711> allow 'new', 'copy', 'alloc', 'init' prefix to
 //  start before '_' when determining Cocoa fundamental rule