[cfe-commits] r63891 - in /cfe/trunk: lib/Analysis/CFRefCount.cpp test/Analysis/rdar-6539791.c

Ted Kremenek kremenek at apple.com
Thu Feb 5 14:34:53 PST 2009


Author: kremenek
Date: Thu Feb  5 16:34:53 2009
New Revision: 63891

URL: http://llvm.org/viewvc/llvm-project?rev=63891&view=rev
Log:
Add 'AppendValue' to the list of magic CF function names that cause a tracked object to escape.  Fixes <rdar://problem/6560661>.

Modified:
    cfe/trunk/lib/Analysis/CFRefCount.cpp
    cfe/trunk/test/Analysis/rdar-6539791.c

Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=63891&r1=63890&r2=63891&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Thu Feb  5 16:34:53 2009
@@ -826,7 +826,8 @@
         //
         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);

Modified: cfe/trunk/test/Analysis/rdar-6539791.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/rdar-6539791.c?rev=63891&r1=63890&r2=63891&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/rdar-6539791.c (original)
+++ cfe/trunk/test/Analysis/rdar-6539791.c Thu Feb  5 16:34:53 2009
@@ -15,7 +15,11 @@
 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 @@
     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
+}





More information about the cfe-commits mailing list