blob: 0f89ad7ff87adc1211571d6cd2b1a697fe687ac8 [file] [log] [blame]
John McCalld1e40d52011-10-02 01:16:38 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
2// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
John McCall8f0e8d22011-06-15 23:25:17 +00003// RUN: diff %t %s.result
Argyrios Kyrtzidis510037b2012-01-10 02:39:29 +00004// XFAIL: mingw
John McCall8f0e8d22011-06-15 23:25:17 +00005
6#include "Common.h"
7
8@interface NSString : NSObject
Argyrios Kyrtzidis18fd0c62011-07-27 05:28:18 +00009-(id)string;
10-(id)newString;
John McCall8f0e8d22011-06-15 23:25:17 +000011@end
12
13typedef const struct __CFString * CFStringRef;
14extern const CFStringRef kUTTypePlainText;
15extern const CFStringRef kUTTypeRTF;
16
17typedef const struct __CFAllocator * CFAllocatorRef;
18typedef const struct __CFUUID * CFUUIDRef;
19
20extern const CFAllocatorRef kCFAllocatorDefault;
21
22extern CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid);
23
24void f(BOOL b, id p) {
25 NSString *str = (NSString *)kUTTypePlainText;
26 str = b ? kUTTypeRTF : kUTTypePlainText;
27 str = (NSString *)(b ? kUTTypeRTF : kUTTypePlainText);
28 str = (NSString *)p; // no change.
29
John McCall8f0e8d22011-06-15 23:25:17 +000030 CFUUIDRef _uuid;
31 NSString *_uuidString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid);
32 _uuidString = [(NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid) autorelease];
Argyrios Kyrtzidis18fd0c62011-07-27 05:28:18 +000033 _uuidString = CFRetain(_uuid);
John McCall8f0e8d22011-06-15 23:25:17 +000034}
Argyrios Kyrtzidis8e2ce7f2011-06-20 23:39:20 +000035
36@implementation NSString (StrExt)
37- (NSString *)stringEscapedAsURI {
38 CFStringRef str = (CFStringRef)self;
39 CFStringRef str2 = self;
40 return self;
41}
42@end
Argyrios Kyrtzidis18fd0c62011-07-27 05:28:18 +000043
Argyrios Kyrtzidis4532b552011-09-14 18:17:09 +000044extern void consumeParam(CFStringRef CF_CONSUMED p);
45
Argyrios Kyrtzidis18fd0c62011-07-27 05:28:18 +000046void f2(NSString *s) {
47 CFStringRef ref = [s string];
48 ref = (CFStringRef)[s string];
49 ref = s.string;
50 ref = [NSString new];
51 ref = [s newString];
52 ref = (CFStringRef)[NSString new];
53 ref = [[NSString alloc] init];
54 ref = [[s string] retain];
55 ref = CFRetain((CFStringRef)[s string]);
56 ref = CFRetain([s string]);
57 ref = CFRetain(s);
58 ref = [s retain];
Argyrios Kyrtzidis4532b552011-09-14 18:17:09 +000059
60 consumeParam((CFStringRef)s);
61 consumeParam(s);
Argyrios Kyrtzidis18fd0c62011-07-27 05:28:18 +000062}