blob: 1fc2774c14926d4ee9772523287dec59a273e9f7 [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 = (__bridge NSString *)kUTTypePlainText;
25 str = (__bridge NSString *)(b ? kUTTypeRTF : kUTTypePlainText);
26 str = (__bridge NSString *)(b ? kUTTypeRTF : kUTTypePlainText);
27 str = (NSString *)p; // no change.
28
John McCall8f0e8d22011-06-15 23:25:17 +000029 CFUUIDRef _uuid;
30 NSString *_uuidString = (__bridge_transfer NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid);
31 _uuidString = (__bridge_transfer NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid);
Argyrios Kyrtzidis18fd0c62011-07-27 05:28:18 +000032 _uuidString = (__bridge_transfer NSString *)(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 = (__bridge CFStringRef)self;
38 CFStringRef str2 = (__bridge CFStringRef)(self);
39 return self;
40}
41@end
Argyrios Kyrtzidis18fd0c62011-07-27 05:28:18 +000042
43void f2(NSString *s) {
44 CFStringRef ref = (__bridge CFStringRef)([s string]);
45 ref = (__bridge CFStringRef)[s string];
46 ref = (__bridge CFStringRef)(s.string);
47 ref = (__bridge_retained CFStringRef)([NSString new]);
48 ref = (__bridge_retained CFStringRef)([s newString]);
49 ref = (__bridge_retained CFStringRef)[NSString new];
50 ref = (__bridge_retained CFStringRef)([[NSString alloc] init]);
51 ref = (__bridge_retained CFStringRef)([s string]);
52 ref = (__bridge_retained CFStringRef)[s string];
53 ref = (__bridge_retained CFTypeRef)([s string]);
54 ref = (__bridge_retained CFTypeRef)(s);
55 ref = (__bridge_retained CFStringRef)(s);
56}