1// RUN: %clang_cc1 -emit-llvm -fblocks -fobjc-arc -debug-info-kind=standalone -dwarf-version=4 -disable-llvm-passes -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 ![[RET1:[0-9]+]] 8// CHECK: ret {{.*}} !dbg ![[RET1]] 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 ![[RET5:[0-9]+]] 25// CHECK: ret {{.*}} !dbg ![[RET5]] 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// CHECK: define {{.*}}testCleanupVoid 36// CHECK: icmp ne {{.*}}!dbg ![[SKIP1:[0-9]+]] 37// CHECK: store i32 0, i32* {{.*}}, !dbg ![[RET8:[0-9]+]] 38// CHECK: @objc_storeStrong{{.*}}, !dbg ![[RET8]] 39// CHECK: ret {{.*}} !dbg ![[RET8]] 40 41typedef signed char BOOL; 42 43@interface NSObject 44+ (id)alloc; 45- (id)init; 46- (id)retain; 47@end 48 49@class NSString; 50 51@interface AppDelegate : NSObject 52 53@end 54 55@implementation AppDelegate : NSObject 56 57// CHECK: ![[TESTNOSIDEEFFECT:.*]] = distinct !DISubprogram(name: "-[AppDelegate testNoSideEffect:]" 58// CHECK-SAME: line: [[@LINE+2]] 59// CHECK-SAME: isLocal: true, isDefinition: true 60- (int)testNoSideEffect:(NSString *)foo { 61 int x = 1; 62 return 1; // Return expression 63 // CHECK: ![[RET1]] = !DILocation(line: [[@LINE+1]], scope: ![[TESTNOSIDEEFFECT]]) 64} // Cleanup + Ret 65 66- (int)testNoCleanup { 67 // CHECK: ![[RET2]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}}) 68 return 1; 69} 70 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: !{{.*}}) 75} 76 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: !{{.*}}) 81 return r; 82 // CHECK: ![[RET4]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}}) 83} 84 85- (void)testVoid:(NSString *)foo { 86 return; 87 // CHECK: ![[RET5]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}}) 88} 89 90- (void)testVoidNoReturn:(NSString *)foo { 91 // CHECK: ![[MSG6]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}}) 92 [self testVoid :foo]; 93 // CHECK: ![[RET6]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}}) 94} 95 96- (int)testNoCleanupSideEffect { 97 // CHECK: ![[MSG7]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}}) 98 [self testVoid :@"foo"]; 99 // CHECK: ![[RET7]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}}) 100 return 1; 101} 102 103- (void)testCleanupVoid:(BOOL)skip withDelegate: (AppDelegate *) delegate { 104 static BOOL skip_all; 105 // CHECK: ![[SKIP1]] = !DILocation(line: [[@LINE+1]], scope: 106 if (!skip_all) { 107 if (!skip) { 108 return; 109 } 110 NSString *s = @"bar"; 111 if (!skip) { 112 [delegate testVoid :s]; 113 } 114 } 115 // CHECK: ![[RET8]] = !DILocation(line: [[@LINE+1]], scope: 116} 117 118 119@end 120 121 122int main(int argc, const char** argv) { 123 AppDelegate *o = [[AppDelegate alloc] init]; 124 return [o testMultiline :@"foo"]; 125} 126