2015-11-21 02:29:01 +08:00
|
|
|
// 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
|
2013-05-03 01:30:20 +08:00
|
|
|
|
|
|
|
// Legend: EXP = Return expression, RET = ret instruction
|
|
|
|
|
|
|
|
// CHECK: define {{.*}}testNoSideEffect
|
|
|
|
// CHECK: call void @objc_storeStrong{{.*}}
|
2015-02-05 03:47:54 +08:00
|
|
|
// CHECK: call void @objc_storeStrong{{.*}} !dbg ![[RET1:[0-9]+]]
|
|
|
|
// CHECK: ret {{.*}} !dbg ![[RET1]]
|
2013-05-03 01:30:20 +08:00
|
|
|
|
|
|
|
// CHECK: define {{.*}}testNoCleanup
|
|
|
|
// CHECK: ret {{.*}} !dbg ![[RET2:[0-9]+]]
|
|
|
|
|
|
|
|
// CHECK: define {{.*}}testSideEffect
|
|
|
|
// CHECK: @objc_msgSend{{.*}} !dbg ![[MSG3:[0-9]+]]
|
|
|
|
// CHECK: ret {{.*}} !dbg ![[RET3:[0-9]+]]
|
|
|
|
|
|
|
|
// CHECK: define {{.*}}testMultiline
|
|
|
|
// CHECK: @objc_msgSend{{.*}} !dbg ![[MSG4:[0-9]+]]
|
|
|
|
// CHECK: load{{.*}} !dbg ![[EXP4:[0-9]+]]
|
|
|
|
// CHECK: ret {{.*}} !dbg ![[RET4:[0-9]+]]
|
|
|
|
|
|
|
|
// CHECK: define {{.*}}testVoid
|
|
|
|
// CHECK: call void @objc_storeStrong{{.*}}
|
2015-02-05 03:47:54 +08:00
|
|
|
// CHECK: call void @objc_storeStrong{{.*}} !dbg ![[RET5:[0-9]+]]
|
|
|
|
// CHECK: ret {{.*}} !dbg ![[RET5]]
|
2013-05-03 01:30:20 +08:00
|
|
|
|
|
|
|
// CHECK: define {{.*}}testVoidNoReturn
|
|
|
|
// CHECK: @objc_msgSend{{.*}} !dbg ![[MSG6:[0-9]+]]
|
|
|
|
// CHECK: ret {{.*}} !dbg ![[RET6:[0-9]+]]
|
|
|
|
|
|
|
|
// CHECK: define {{.*}}testNoCleanupSideEffect
|
|
|
|
// CHECK: @objc_msgSend{{.*}} !dbg ![[MSG7:[0-9]+]]
|
|
|
|
// CHECK: ret {{.*}} !dbg ![[RET7:[0-9]+]]
|
|
|
|
|
2014-04-29 09:07:59 +08:00
|
|
|
// CHECK: define {{.*}}testCleanupVoid
|
|
|
|
// CHECK: icmp ne {{.*}}!dbg ![[SKIP1:[0-9]+]]
|
2015-11-21 02:29:01 +08:00
|
|
|
// CHECK: store i32 0, i32* {{.*}}, !dbg ![[RET8:[0-9]+]]
|
|
|
|
// CHECK: @objc_storeStrong{{.*}}, !dbg ![[RET8]]
|
|
|
|
// CHECK: ret {{.*}} !dbg ![[RET8]]
|
2014-04-29 09:07:59 +08:00
|
|
|
|
|
|
|
typedef signed char BOOL;
|
2013-05-03 01:30:20 +08:00
|
|
|
|
|
|
|
@interface NSObject
|
|
|
|
+ (id)alloc;
|
|
|
|
- (id)init;
|
|
|
|
- (id)retain;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@class NSString;
|
|
|
|
|
|
|
|
@interface AppDelegate : NSObject
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation AppDelegate : NSObject
|
|
|
|
|
2015-08-27 06:50:48 +08:00
|
|
|
// CHECK: ![[TESTNOSIDEEFFECT:.*]] = distinct !DISubprogram(name: "-[AppDelegate testNoSideEffect:]"
|
|
|
|
// CHECK-SAME: line: [[@LINE+2]]
|
|
|
|
// CHECK-SAME: isLocal: true, isDefinition: true
|
2013-05-03 01:30:20 +08:00
|
|
|
- (int)testNoSideEffect:(NSString *)foo {
|
2014-01-08 06:05:55 +08:00
|
|
|
int x = 1;
|
2013-05-03 01:30:20 +08:00
|
|
|
return 1; // Return expression
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: ![[RET1]] = !DILocation(line: [[@LINE+1]], scope: ![[TESTNOSIDEEFFECT]])
|
2013-05-03 01:30:20 +08:00
|
|
|
} // Cleanup + Ret
|
|
|
|
|
|
|
|
- (int)testNoCleanup {
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: ![[RET2]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
|
2013-05-03 01:30:20 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int)testSideEffect:(NSString *)foo {
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: ![[MSG3]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
|
2013-05-03 01:30:20 +08:00
|
|
|
return [self testNoSideEffect :foo];
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: ![[RET3]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
|
2013-05-03 01:30:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int)testMultiline:(NSString *)foo {
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: ![[MSG4]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
|
2013-05-03 01:30:20 +08:00
|
|
|
int r = [self testSideEffect :foo];
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: ![[EXP4]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
|
2013-05-03 01:30:20 +08:00
|
|
|
return r;
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: ![[RET4]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
|
2013-05-03 01:30:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)testVoid:(NSString *)foo {
|
|
|
|
return;
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: ![[RET5]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
|
2013-05-03 01:30:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)testVoidNoReturn:(NSString *)foo {
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: ![[MSG6]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
|
2013-05-03 01:30:20 +08:00
|
|
|
[self testVoid :foo];
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: ![[RET6]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
|
2013-05-03 01:30:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int)testNoCleanupSideEffect {
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: ![[MSG7]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
|
2013-05-03 01:30:20 +08:00
|
|
|
[self testVoid :@"foo"];
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: ![[RET7]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
|
2013-05-03 01:30:20 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-04-29 09:07:59 +08:00
|
|
|
- (void)testCleanupVoid:(BOOL)skip withDelegate: (AppDelegate *) delegate {
|
|
|
|
static BOOL skip_all;
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: ![[SKIP1]] = !DILocation(line: [[@LINE+1]], scope:
|
2014-04-29 09:07:59 +08:00
|
|
|
if (!skip_all) {
|
|
|
|
if (!skip) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
NSString *s = @"bar";
|
|
|
|
if (!skip) {
|
|
|
|
[delegate testVoid :s];
|
|
|
|
}
|
|
|
|
}
|
2015-11-20 03:53:16 +08:00
|
|
|
// CHECK: ![[RET8]] = !DILocation(line: [[@LINE+1]], scope:
|
2014-04-29 09:07:59 +08:00
|
|
|
}
|
|
|
|
|
2013-05-03 01:30:20 +08:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, const char** argv) {
|
|
|
|
AppDelegate *o = [[AppDelegate alloc] init];
|
|
|
|
return [o testMultiline :@"foo"];
|
|
|
|
}
|