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 
      5 #include "Common.h"
      6 
      7 @interface A : NSObject {
      8 @package
      9     id object;
     10 }
     11 @end
     12 
     13 @interface B : NSObject {
     14   id _prop;
     15   xpc_object_t _xpc_prop;
     16 }
     17 - (BOOL)containsSelf:(A*)a;
     18 @property (retain) id prop;
     19 @property (retain) xpc_object_t xpc_prop;
     20 @end
     21 
     22 @implementation A
     23 @end
     24 
     25 @implementation B
     26 - (BOOL)containsSelf:(A*)a {
     27     return a->object == self;
     28 }
     29 
     30 -(id) prop {
     31   return _prop;
     32 }
     33 -(void) setProp:(id) newVal {
     34   [_prop autorelease];
     35   _prop = [newVal retain];
     36 }
     37 -(void) setProp2:(CFTypeRef) newVal {
     38   [_prop autorelease];
     39   _prop = (id)CFRetain(newVal);
     40 }
     41 
     42 -(id) xpc_prop {
     43   return _xpc_prop;
     44 }
     45 -(void) setXpc_prop:(xpc_object_t) newVal {
     46   [_xpc_prop autorelease];
     47   _xpc_prop = xpc_retain(newVal);
     48 }
     49 @end
     50 
     51 void NSLog(id, ...);
     52 
     53 int main (int argc, const char * argv[]) {
     54     NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
     55     A *a = [[A new] autorelease];
     56     B *b = [[B new] autorelease];
     57     NSLog(@"%s", [b containsSelf:a] ? "YES" : "NO");
     58     [pool drain];
     59     return 0;
     60 }
     61 
     62 void test(A *prevVal, A *newVal) {
     63   [prevVal autorelease];
     64   prevVal = [newVal retain];
     65 }
     66 
     67 id test2(A* val) {
     68   [[val retain] autorelease];
     69   return val;
     70 }
     71 
     72 id test3() {
     73   id a = [[A alloc] init];
     74   [a autorelease];
     75 }
     76