diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-01-12 21:45:02 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-01-12 21:45:02 +0000 |
commit | 1261938ec42b0a1b82bec5fe901b7fc02a23d9a1 (patch) | |
tree | 89673fcfe7a70209a4d82e21ea3bb1163b5c723c /test/Analysis/CFString.c | |
parent | b37c9654c94e6ebb532506f986900aacd5fde0ae (diff) |
retain/release checker:
- Refactor a bunch of logic in the retain/release checker, making it more
condense and easier to read.
- Add support for "Create" methods in the DiskArbitration framework
retain/release tests:
- Rename CFDate.m to retain-release.m, and move test from CFString.c to
retain-release.m
- Add DiskArbitration framework tests cases.
- Add/refine and few more retain/release GC test cases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62106 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/CFString.c')
-rw-r--r-- | test/Analysis/CFString.c | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/test/Analysis/CFString.c b/test/Analysis/CFString.c deleted file mode 100644 index cb53bb1c66..0000000000 --- a/test/Analysis/CFString.c +++ /dev/null @@ -1,60 +0,0 @@ -// RUN: clang -checker-cfref -pedantic -verify %s - -//===----------------------------------------------------------------------===// -// The following code is reduced using delta-debugging from -// CoreFoundation.h (Mac OS X). -// -// It includes the basic definitions for the test cases below. -// Not directly including CoreFoundation.h directly makes this test case -// both svelte and portable to non-Mac platforms. -//===----------------------------------------------------------------------===// - -typedef unsigned long UInt32; -typedef unsigned char Boolean; -typedef signed long CFIndex; -typedef const void * CFTypeRef; -typedef const struct __CFString * CFStringRef; -typedef struct { CFIndex location; } CFRange; -typedef const struct __CFAllocator * CFAllocatorRef; -extern void CFRelease(CFTypeRef cf); -typedef Boolean (*CFArrayEqualCallBack)(const void *value1, const void *value2); -typedef struct { CFArrayEqualCallBack equal; } CFArrayCallBacks; -extern const CFArrayCallBacks kCFTypeArrayCallBacks; -typedef const struct __CFArray * CFArrayRef; -typedef struct __CFArray * CFMutableArrayRef; -extern CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks); -extern const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx); -extern void CFArrayAppendValue(CFMutableArrayRef theArray, const void *value); -typedef UInt32 CFStringEncoding; -enum { kCFStringEncodingMacRoman = 0, kCFStringEncodingWindowsLatin1 = 0x0500, kCFStringEncodingISOLatin1 = 0x0201, kCFStringEncodingNextStepLatin = 0x0B01, kCFStringEncodingASCII = 0x0600, kCFStringEncodingUnicode = 0x0100, kCFStringEncodingUTF8 = 0x08000100, kCFStringEncodingNonLossyASCII = 0x0BFF , kCFStringEncodingUTF16 = 0x0100, kCFStringEncodingUTF16BE = 0x10000100, kCFStringEncodingUTF16LE = 0x14000100, kCFStringEncodingUTF32 = 0x0c000100, kCFStringEncodingUTF32BE = 0x18000100, kCFStringEncodingUTF32LE = 0x1c000100 }; -extern CFStringRef CFStringCreateWithCString(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding); - -//===----------------------------------------------------------------------===// -// Test cases. -//===----------------------------------------------------------------------===// - -void f1() { - - // Create the array. - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - - // Create a string. - CFStringRef s1 = CFStringCreateWithCString(0, "hello world", - kCFStringEncodingUTF8); - - // Add the string to the array. - CFArrayAppendValue(A, s1); - - // Decrement the reference count. - CFRelease(s1); // no-warning - - // Get the string. We don't own it. - s1 = (CFStringRef) CFArrayGetValueAtIndex(A, 0); - - // Release the array. - CFRelease(A); // no-warning - - // Release the string. This is a bug. - CFRelease(s1); // expected-warning{{Incorrect decrement of the reference count}} -} - |