John McCall | 8f0e8d2 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -x objective-c %s.result |
Argyrios Kyrtzidis | eaed19e | 2011-06-16 00:53:46 +0000 | [diff] [blame] | 2 | // RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fsyntax-only -x objective-c %s > %t |
John McCall | 8f0e8d2 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 3 | // RUN: diff %t %s.result |
| 4 | |
| 5 | #include "Common.h" |
| 6 | |
| 7 | @interface NSString : NSObject |
Argyrios Kyrtzidis | 18fd0c6 | 2011-07-27 05:28:18 +0000 | [diff] [blame] | 8 | -(id)string; |
| 9 | -(id)newString; |
John McCall | 8f0e8d2 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 10 | @end |
| 11 | |
| 12 | typedef const struct __CFString * CFStringRef; |
| 13 | extern const CFStringRef kUTTypePlainText; |
| 14 | extern const CFStringRef kUTTypeRTF; |
| 15 | |
| 16 | typedef const struct __CFAllocator * CFAllocatorRef; |
| 17 | typedef const struct __CFUUID * CFUUIDRef; |
| 18 | |
| 19 | extern const CFAllocatorRef kCFAllocatorDefault; |
| 20 | |
| 21 | extern CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid); |
| 22 | |
| 23 | void f(BOOL b, id p) { |
| 24 | NSString *str = (NSString *)kUTTypePlainText; |
| 25 | str = b ? kUTTypeRTF : kUTTypePlainText; |
| 26 | str = (NSString *)(b ? kUTTypeRTF : kUTTypePlainText); |
| 27 | str = (NSString *)p; // no change. |
| 28 | |
John McCall | 8f0e8d2 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 29 | CFUUIDRef _uuid; |
| 30 | NSString *_uuidString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid); |
| 31 | _uuidString = [(NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid) autorelease]; |
Argyrios Kyrtzidis | 18fd0c6 | 2011-07-27 05:28:18 +0000 | [diff] [blame] | 32 | _uuidString = CFRetain(_uuid); |
John McCall | 8f0e8d2 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 33 | } |
Argyrios Kyrtzidis | 8e2ce7f | 2011-06-20 23:39:20 +0000 | [diff] [blame] | 34 | |
| 35 | @implementation NSString (StrExt) |
| 36 | - (NSString *)stringEscapedAsURI { |
| 37 | CFStringRef str = (CFStringRef)self; |
| 38 | CFStringRef str2 = self; |
| 39 | return self; |
| 40 | } |
| 41 | @end |
Argyrios Kyrtzidis | 18fd0c6 | 2011-07-27 05:28:18 +0000 | [diff] [blame] | 42 | |
| 43 | void f2(NSString *s) { |
| 44 | CFStringRef ref = [s string]; |
| 45 | ref = (CFStringRef)[s string]; |
| 46 | ref = s.string; |
| 47 | ref = [NSString new]; |
| 48 | ref = [s newString]; |
| 49 | ref = (CFStringRef)[NSString new]; |
| 50 | ref = [[NSString alloc] init]; |
| 51 | ref = [[s string] retain]; |
| 52 | ref = CFRetain((CFStringRef)[s string]); |
| 53 | ref = CFRetain([s string]); |
| 54 | ref = CFRetain(s); |
| 55 | ref = [s retain]; |
| 56 | } |