Add extra test cases to test "escaping" for the reference count checker.

llvm-svn: 49812
This commit is contained in:
Ted Kremenek 2008-04-16 20:41:27 +00:00
parent 7145489c37
commit b47c742002
1 changed files with 39 additions and 0 deletions

View File

@ -25,3 +25,42 @@ CFAbsoluteTime f2() {
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;
}