Home | History | Annotate | Download | only in CodeGenObjC
      1 // RUN: %clang_cc1 -triple x86_64-apple-darwin -fblocks -emit-llvm -o - %s | FileCheck %s
      2 
      3 @interface NSObject
      4 + (id) new;
      5 - (id) init;
      6 @end
      7 
      8 @interface Base : NSObject @end
      9 
     10 // @implementation Base
     11 // {
     12 //     int dummy;
     13 // }
     14 // @end
     15 
     16 @interface Derived : Base
     17 {
     18     @public int member;
     19 }
     20 @end
     21 
     22 @implementation Derived
     23 - (id) init
     24 {
     25     self = [super init];
     26     member = 42;
     27     return self;
     28 }
     29 @end
     30 
     31 // CHECK: define internal i8* @"\01-[Derived init]"
     32 // CHECK: [[IVAR:%.*]] = load i64, i64* @"OBJC_IVAR_$_Derived.member", align 8, !invariant.load
     33 
     34 void * variant_load_1(int i) {
     35     void *ptr;
     36     while (i--) {
     37         Derived *d = [Derived new];
     38         ptr = &d->member;
     39     }
     40     return ptr;
     41 }
     42 
     43 // CHECK-LABEL: define i8* @variant_load_1(i32 %i)
     44 // CHECK: [[IVAR:%.*]] = load i64, i64* @"OBJC_IVAR_$_Derived.member", align 8{{$}}
     45 
     46 @interface Container : Derived @end
     47 @implementation Container
     48 - (void *) invariant_load_1
     49 {
     50     return &self->member;
     51 }
     52 @end
     53 
     54 // CHECK-LABEL: define internal i8* @"\01-[Container invariant_load_1]"
     55 // CHECK: [[IVAR:%.*]] = load i64, i64* @"OBJC_IVAR_$_Derived.member", align 8, !invariant.load
     56 
     57 @interface ForBlock
     58 { 
     59 @public
     60   id foo; 
     61 }
     62 @end
     63 
     64 // CHECK-LABEL: define internal i8* @block_block_invoke
     65 // CHECK: load i64, i64* @"OBJC_IVAR_$_ForBlock.foo"
     66 id (^block)(ForBlock*) = ^(ForBlock* a) {
     67   return a->foo;
     68 };
     69