blob: b4e4080149676cf11dc41ae79a5f1ceab15818d7 [file] [log] [blame]
John McCall8f0e8d22011-06-15 23:25:17 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -x objective-c %s.result
Argyrios Kyrtzidiseaed19e2011-06-16 00:53:46 +00002// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fsyntax-only -x objective-c %s > %t
John McCall8f0e8d22011-06-15 23:25:17 +00003// RUN: diff %t %s.result
4
5#include "Common.h"
6
7@interface NSString : NSObject
Argyrios Kyrtzidis18fd0c62011-07-27 05:28:18 +00008-(id)string;
9-(id)newString;
John McCall8f0e8d22011-06-15 23:25:17 +000010@end
11
12typedef const struct __CFString * CFStringRef;
13extern const CFStringRef kUTTypePlainText;
14extern const CFStringRef kUTTypeRTF;
15
16typedef const struct __CFAllocator * CFAllocatorRef;
17typedef const struct __CFUUID * CFUUIDRef;
18
19extern const CFAllocatorRef kCFAllocatorDefault;
20
21extern CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid);
22
23void 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 McCall8f0e8d22011-06-15 23:25:17 +000029 CFUUIDRef _uuid;
30 NSString *_uuidString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid);
31 _uuidString = [(NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid) autorelease];
Argyrios Kyrtzidis18fd0c62011-07-27 05:28:18 +000032 _uuidString = CFRetain(_uuid);
John McCall8f0e8d22011-06-15 23:25:17 +000033}
Argyrios Kyrtzidis8e2ce7f2011-06-20 23:39:20 +000034
35@implementation NSString (StrExt)
36- (NSString *)stringEscapedAsURI {
37 CFStringRef str = (CFStringRef)self;
38 CFStringRef str2 = self;
39 return self;
40}
41@end
Argyrios Kyrtzidis18fd0c62011-07-27 05:28:18 +000042
43void 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}