• 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
8typedef const struct __CFString * CFStringRef;
9extern const CFStringRef kUTTypePlainText;
10extern const CFStringRef kUTTypeRTF;
11
12typedef const struct __CFAllocator * CFAllocatorRef;
13typedef const struct __CFUUID * CFUUIDRef;
14
15extern const CFAllocatorRef kCFAllocatorDefault;
16
17extern CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid);
18
19struct StrS {
20  CFStringRef sref_member;
21};
22
23@interface NSString : NSObject {
24  CFStringRef sref;
25  struct StrS *strS;
26}
27-(id)string;
28-(id)newString;
29@end
30
31void f(BOOL b, id p) {
32  NSString *str = (NSString *)kUTTypePlainText;
33  str = b ? kUTTypeRTF : kUTTypePlainText;
34  str = (NSString *)(b ? kUTTypeRTF : kUTTypePlainText);
35  str = (NSString *)p; // no change.
36
37  CFUUIDRef   _uuid;
38  NSString *_uuidString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid);
39  _uuidString = [(NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid) autorelease];
40  _uuidString = CFRetain(_uuid);
41}
42
43@implementation NSString (StrExt)
44- (NSString *)stringEscapedAsURI {
45  CFStringRef str = (CFStringRef)self;
46  CFStringRef str2 = self;
47  return self;
48}
49@end
50
51@implementation NSString
52-(id)string {
53  if (0)
54    return sref;
55  else
56    return strS->sref_member;
57}
58-(id)newString { return 0; }
59@end
60
61extern void consumeParam(CFStringRef CF_CONSUMED p);
62
63void f2(NSString *s) {
64  CFStringRef ref = [s string];
65  ref = (CFStringRef)[s string];
66  ref = s.string;
67  ref = [NSString new];
68  ref = [s newString];
69  ref = (CFStringRef)[NSString new];
70  ref = [[NSString alloc] init];
71  ref = [[s string] retain];
72  ref = CFRetain((CFStringRef)[s string]);
73  ref = CFRetain([s string]);
74  ref = CFRetain(s);
75  ref = [s retain];
76
77  consumeParam((CFStringRef)s);
78  consumeParam(s);
79}
80