From d59d96facf70642447f1f5916e67ef6a4631fe2c Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Wed, 16 Apr 2008 04:29:21 +0000 Subject: [PATCH] Update CF reference count checker test case to illustrate the use of toll-free bridging. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49772 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Analysis-Apple/CFDate.c | 15 --------------- test/Analysis-Apple/CFDate.m | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 15 deletions(-) delete mode 100644 test/Analysis-Apple/CFDate.c create mode 100644 test/Analysis-Apple/CFDate.m diff --git a/test/Analysis-Apple/CFDate.c b/test/Analysis-Apple/CFDate.c deleted file mode 100644 index 58b568b424..0000000000 --- a/test/Analysis-Apple/CFDate.c +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: clang -checker-cfref -verify %s - -#include - -CFAbsoluteTime f1() { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(NULL, t); - CFRetain(date); - CFRelease(date); - CFDateGetAbsoluteTime(date); - CFRelease(date); - t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released.}} - return t; -} - diff --git a/test/Analysis-Apple/CFDate.m b/test/Analysis-Apple/CFDate.m new file mode 100644 index 0000000000..c79b253cfd --- /dev/null +++ b/test/Analysis-Apple/CFDate.m @@ -0,0 +1,27 @@ +// RUN: clang -checker-cfref -verify %s + +#include +#include + +CFAbsoluteTime f1() { + CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); + CFDateRef date = CFDateCreate(NULL, t); + CFRetain(date); + CFRelease(date); + CFDateGetAbsoluteTime(date); // no-warning + CFRelease(date); + t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released.}} + return t; +} + +CFAbsoluteTime f2() { + CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); + CFDateRef date = CFDateCreate(NULL, t); + [((NSDate*) date) retain]; + CFRelease(date); + CFDateGetAbsoluteTime(date); // no-warning + [((NSDate*) date) release]; + t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released.}} + return t; +} + -- 2.40.0