Home | History | Annotate | Download | only in CodeGenObjC
      1 // RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
      2 
      3 @interface NSObject
      4 + (id)alloc;
      5 - (id)init;
      6 - (id)retain;
      7 @end
      8 
      9 @interface NSString : NSObject
     10 @end
     11 
     12 // CHECK-LABEL: define {{.*}}void @test1()
     13 void test1() {
     14   // CHECK: {{call.*@objc_msgSend}}
     15   // CHECK: {{call.*@objc_msgSend}}
     16   // CHECK: {{call.*@objc_msgSend}}
     17   // CHECK: bitcast i8*
     18   NSString *str1 = [[[NSString alloc] init] retain];
     19 }
     20 
     21 // CHECK-LABEL: define {{.*}}void @test2()
     22 void test2() {
     23   // CHECK: {{call.*@objc_msgSend}}
     24   // CHECK: {{call.*@objc_msgSend}}
     25   // CHECK: {{call.*@objc_msgSend}}
     26   // CHECK: bitcast i8*
     27   NSString *str1 = NSString.alloc.init.retain;
     28 }
     29 
     30 @interface Test2 : NSString
     31 - (id)init;
     32 @end
     33 
     34 @implementation Test2
     35 // CHECK: define internal {{.*}}i8* @"\01-[Test2 init]"
     36 - (id)init {
     37   // CHECK: {{call.*@objc_msgSendSuper}}
     38   // CHECK-NEXT: bitcast i8*
     39   return [super init];
     40 }
     41 @end
     42 
     43 @interface Test3 : NSString
     44 - (id)init;
     45 @end
     46 
     47 @implementation Test3
     48 // CHECK: define internal {{.*}}i8* @"\01-[Test3 init]"
     49 - (id)init {
     50   // CHECK: {{call.*@objc_msgSendSuper}}
     51   // CHECK-NEXT: bitcast i8*
     52   return [super init];
     53 }
     54 @end
     55