[cfe-commits] r49812 - /cfe/trunk/test/Analysis-Apple/CFDate.m

Ted Kremenek kremenek at apple.com
Wed Apr 16 13:41:27 PDT 2008


Author: kremenek
Date: Wed Apr 16 15:41:27 2008
New Revision: 49812

URL: http://llvm.org/viewvc/llvm-project?rev=49812&view=rev
Log:
Add extra test cases to test "escaping" for the reference count checker.

Modified:
    cfe/trunk/test/Analysis-Apple/CFDate.m

Modified: cfe/trunk/test/Analysis-Apple/CFDate.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis-Apple/CFDate.m?rev=49812&r1=49811&r2=49812&view=diff

==============================================================================
--- cfe/trunk/test/Analysis-Apple/CFDate.m (original)
+++ cfe/trunk/test/Analysis-Apple/CFDate.m Wed Apr 16 15:41:27 2008
@@ -25,3 +25,42 @@
   return t;
 }
 
+
+NSDate* global_x;
+
+  // Test to see if we supresss an error when we store the pointer
+  // to a global.
+  
+CFAbsoluteTime f3() {
+  CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
+  CFDateRef date = CFDateCreate(NULL, t);  
+  [((NSDate*) date) retain];
+  CFRelease(date);
+  CFDateGetAbsoluteTime(date); // no-warning
+  global_x = (NSDate*) date;  
+  [((NSDate*) date) release];
+  t = CFDateGetAbsoluteTime(date);   // no-warning
+  return t;
+}
+
+// Test to see if we supresss an error when we store the pointer
+// to a struct.
+
+struct foo {
+  NSDate* f;
+};
+
+CFAbsoluteTime f4() {
+  struct foo x;
+  
+  CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
+  CFDateRef date = CFDateCreate(NULL, t);  
+  [((NSDate*) date) retain];
+  CFRelease(date);
+  CFDateGetAbsoluteTime(date); // no-warning
+  x.f = (NSDate*) date;  
+  [((NSDate*) date) release];
+  t = CFDateGetAbsoluteTime(date);   // no-warning
+  return t;
+}
+





More information about the cfe-commits mailing list