• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// 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
3// RUN: diff %t %s.result
4// DISABLE: mingw32
5
6#include "Common.h"
7
8@interface NSString : NSObject
9-(id)string;
10-(id)newString;
11@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
30  CFUUIDRef   _uuid;
31  NSString *_uuidString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid);
32  _uuidString = [(NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid) autorelease];
33  _uuidString = CFRetain(_uuid);
34}
35
36@implementation NSString (StrExt)
37- (NSString *)stringEscapedAsURI {
38  CFStringRef str = (CFStringRef)self;
39  CFStringRef str2 = self;
40  return self;
41}
42@end
43
44extern void consumeParam(CFStringRef CF_CONSUMED p);
45
46void 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];
59
60  consumeParam((CFStringRef)s);
61  consumeParam(s);
62}
63