1 // RUN: %clang_cc1 -emit-llvm -fblocks -fobjc-arc -debug-info-kind=standalone -dwarf-version=4 -gno-column-info -disable-llvm-passes -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
3 // Legend: EXP = Return expression, RET = ret instruction
5 // CHECK: define {{.*}}testNoSideEffect
6 // CHECK: call void @llvm.objc.storeStrong{{.*}}
7 // CHECK: call void @llvm.objc.storeStrong{{.*}} !dbg ![[RET1:[0-9]+]]
8 // CHECK: ret {{.*}} !dbg ![[RET1]]
10 // CHECK: define {{.*}}testNoCleanup
11 // CHECK: ret {{.*}} !dbg ![[RET2:[0-9]+]]
13 // CHECK: define {{.*}}testSideEffect
14 // CHECK: @objc_msgSend{{.*}} !dbg ![[MSG3:[0-9]+]]
15 // CHECK: ret {{.*}} !dbg ![[RET3:[0-9]+]]
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]+]]
22 // CHECK: define {{.*}}testVoid
23 // CHECK: call void @llvm.objc.storeStrong{{.*}}
24 // CHECK: call void @llvm.objc.storeStrong{{.*}} !dbg ![[RET5:[0-9]+]]
25 // CHECK: ret {{.*}} !dbg ![[RET5]]
27 // CHECK: define {{.*}}testVoidNoReturn
28 // CHECK: @objc_msgSend{{.*}} !dbg ![[MSG6:[0-9]+]]
29 // CHECK: ret {{.*}} !dbg ![[RET6:[0-9]+]]
31 // CHECK: define {{.*}}testNoCleanupSideEffect
32 // CHECK: @objc_msgSend{{.*}} !dbg ![[MSG7:[0-9]+]]
33 // CHECK: ret {{.*}} !dbg ![[RET7:[0-9]+]]
35 // CHECK: define {{.*}}testCleanupVoid
36 // CHECK: icmp ne {{.*}}!dbg ![[SKIP1:[0-9]+]]
37 // CHECK: store i32 0, ptr {{.*}}, !dbg ![[RET8:[0-9]+]]
38 // CHECK: @llvm.objc.storeStrong{{.*}}, !dbg ![[RET8]]
39 // CHECK: ret {{.*}} !dbg ![[RET8]]
41 typedef signed char BOOL;
51 @interface AppDelegate : NSObject
55 @implementation AppDelegate : NSObject
57 // CHECK: ![[TESTNOSIDEEFFECT:.*]] = distinct !DISubprogram(name: "-[AppDelegate testNoSideEffect:]"
58 // CHECK-SAME: line: [[@LINE+2]]
59 // CHECK-SAME: DISPFlagLocalToUnit | DISPFlagDefinition
60 - (int)testNoSideEffect:(NSString *)foo {
62 return 1; // Return expression
63 // CHECK: ![[RET1]] = !DILocation(line: [[@LINE+1]], scope: ![[TESTNOSIDEEFFECT]])
66 - (int)testNoCleanup {
67 // CHECK: ![[RET2]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
71 - (int)testSideEffect:(NSString *)foo {
72 // CHECK: ![[MSG3]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
73 return [self testNoSideEffect :foo];
74 // CHECK: ![[RET3]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
77 - (int)testMultiline:(NSString *)foo {
78 // CHECK: ![[MSG4]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
79 int r = [self testSideEffect :foo];
80 // CHECK: ![[EXP4]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
82 // CHECK: ![[RET4]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
85 - (void)testVoid:(NSString *)foo {
87 // CHECK: ![[RET5]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
90 - (void)testVoidNoReturn:(NSString *)foo {
91 // CHECK: ![[MSG6]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
93 // CHECK: ![[RET6]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
96 - (int)testNoCleanupSideEffect {
97 // CHECK: ![[MSG7]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
98 [self testVoid :@"foo"];
99 // CHECK: ![[RET7]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
103 - (void)testCleanupVoid:(BOOL)skip withDelegate: (AppDelegate *) delegate {
104 static BOOL skip_all;
105 // CHECK: ![[SKIP1]] = !DILocation(line: [[@LINE+1]], scope:
110 NSString *s = @"bar";
112 [delegate testVoid :s];
115 // CHECK: ![[RET8]] = !DILocation(line: [[@LINE+1]], scope:
122 int main(int argc, const char** argv) {
123 AppDelegate *o = [[AppDelegate alloc] init];
124 return [o testMultiline :@"foo"];