]> granicus.if.org Git - clang/commitdiff
Add 'AppendValue' to the list of magic CF function names that cause a tracked object...
authorTed Kremenek <kremenek@apple.com>
Thu, 5 Feb 2009 22:34:53 +0000 (22:34 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 5 Feb 2009 22:34:53 +0000 (22:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63891 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CFRefCount.cpp
test/Analysis/rdar-6539791.c

index 8ed6bb285c0da9736fd7754264b5581a268241e0..ee17a57e9fb4922852d5dbfaf65427072067e798 100644 (file)
@@ -826,7 +826,8 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) {
         //
         ArgEffect E = (CStrInCStrNoCase(FName, "InsertValue") ||
                        CStrInCStrNoCase(FName, "AddValue") ||
-                       CStrInCStrNoCase(FName, "SetValue"))
+                       CStrInCStrNoCase(FName, "SetValue") ||
+                       CStrInCStrNoCase(FName, "AppendValue"))
                       ? MayEscape : DoNothing;
         
         S = getPersistentSummary(RetEffect::MakeNoRet(), DoNothing, E);
index 0d0b675d945b59267959d8eea6ebe86e0b09d935..75485b0b547cdcd041622c234b9aae79c885a6b5 100644 (file)
@@ -15,7 +15,11 @@ enum { kCFNumberSInt32Type = 3 };
 CFMutableDictionaryRef CFDictionaryCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
 void CFDictionaryAddValue(CFMutableDictionaryRef theDict, const void *key, const void *value);
 void CFRelease(CFTypeRef cf);
+CFTypeRef CFRetain(CFTypeRef cf);
 extern CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr);
+typedef const struct __CFArray * CFArrayRef;
+typedef struct __CFArray * CFMutableArrayRef;
+void CFArrayAppendValue(CFMutableArrayRef theArray, const void *value);
 
 void f(CFMutableDictionaryRef y, void* key, void* val_key) {
   CFMutableDictionaryRef x = CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
@@ -29,3 +33,15 @@ void f(CFMutableDictionaryRef y, void* key, void* val_key) {
     CFDictionaryAddValue(y, val_key, value); // no-warning
   }
 }
+
+// <rdar://problem/6560661>
+// Same issue, except with "AppendValue" functions.
+void f2(CFMutableArrayRef x) {
+  signed z = 1;
+  CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z);
+  // CFArrayAppendValue keeps a reference to value.
+  CFArrayAppendValue(x, value);
+  CFRelease(value);
+  CFRetain(value);
+  CFRelease(value); // no-warning
+}