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