Home | History | Annotate | Download | only in CodeGenObjC
      1 // RUN: %clang_cc1 -emit-llvm -fblocks -fobjc-arc -g -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
      2 
      3 // Legend: EXP = Return expression, RET = ret instruction
      4 
      5 // CHECK: define {{.*}}testNoSideEffect
      6 // CHECK: call void @objc_storeStrong{{.*}}
      7 // CHECK: call void @objc_storeStrong{{.*}} !dbg ![[ARC1:[0-9]+]]
      8 // CHECK: ret {{.*}} !dbg ![[RET1:[0-9]+]]
      9 
     10 // CHECK: define {{.*}}testNoCleanup
     11 // CHECK: ret {{.*}} !dbg ![[RET2:[0-9]+]]
     12 
     13 // CHECK: define {{.*}}testSideEffect
     14 // CHECK: @objc_msgSend{{.*}} !dbg ![[MSG3:[0-9]+]]
     15 // CHECK: ret {{.*}} !dbg ![[RET3:[0-9]+]]
     16 
     17 // CHECK: define {{.*}}testMultiline
     18 // CHECK: @objc_msgSend{{.*}} !dbg ![[MSG4:[0-9]+]]
     19 // CHECK: load{{.*}} !dbg ![[EXP4:[0-9]+]]
     20 // CHECK: ret {{.*}} !dbg ![[RET4:[0-9]+]]
     21 
     22 // CHECK: define {{.*}}testVoid
     23 // CHECK: call void @objc_storeStrong{{.*}}
     24 // CHECK: call void @objc_storeStrong{{.*}} !dbg ![[ARC5:[0-9]+]]
     25 // CHECK: ret {{.*}} !dbg ![[RET5:[0-9]+]]
     26 
     27 // CHECK: define {{.*}}testVoidNoReturn
     28 // CHECK: @objc_msgSend{{.*}} !dbg ![[MSG6:[0-9]+]]
     29 // CHECK: ret {{.*}} !dbg ![[RET6:[0-9]+]]
     30 
     31 // CHECK: define {{.*}}testNoCleanupSideEffect
     32 // CHECK: @objc_msgSend{{.*}} !dbg ![[MSG7:[0-9]+]]
     33 // CHECK: ret {{.*}} !dbg ![[RET7:[0-9]+]]
     34 
     35 
     36 @interface NSObject
     37 + (id)alloc;
     38 - (id)init;
     39 - (id)retain;
     40 @end
     41 
     42 @class NSString;
     43 
     44 @interface AppDelegate : NSObject
     45 
     46 @end
     47 
     48 @implementation AppDelegate : NSObject
     49 
     50 - (int)testNoSideEffect:(NSString *)foo {
     51   // CHECK: ![[ARC1]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
     52   return 1; // Return expression
     53   // CHECK: ![[RET1]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
     54 }           // Cleanup + Ret
     55 
     56 - (int)testNoCleanup {
     57   // CHECK: ![[RET2]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
     58   return 1;
     59 }
     60 
     61 - (int)testSideEffect:(NSString *)foo {
     62   // CHECK: ![[MSG3]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
     63   return [self testNoSideEffect :foo];
     64   // CHECK: ![[RET3]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
     65 }
     66 
     67 - (int)testMultiline:(NSString *)foo {
     68   // CHECK: ![[MSG4]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
     69   int r = [self testSideEffect :foo];
     70   // CHECK: ![[EXP4]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
     71   return r;
     72   // CHECK: ![[RET4]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
     73 }
     74 
     75 - (void)testVoid:(NSString *)foo {
     76   // CHECK: ![[ARC5]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
     77   return;
     78   // CHECK: ![[RET5]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
     79 }
     80 
     81 - (void)testVoidNoReturn:(NSString *)foo {
     82   // CHECK: ![[MSG6]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
     83   [self testVoid :foo];
     84   // CHECK: ![[RET6]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
     85 }
     86 
     87 - (int)testNoCleanupSideEffect {
     88   // CHECK: ![[MSG7]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
     89   [self testVoid :@"foo"];
     90   // CHECK: ![[RET7]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
     91   return 1;
     92 }
     93 
     94 
     95 @end
     96 
     97 
     98 int main(int argc, const char** argv) {
     99   AppDelegate *o = [[AppDelegate alloc] init];
    100   return [o testMultiline :@"foo"];
    101 }
    102