2015-10-08 12:24:12 +08:00
|
|
|
// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
|
2013-05-04 04:11:48 +08:00
|
|
|
|
2013-07-25 04:44:20 +08:00
|
|
|
// Check the line numbers for cleanup code with EH in combination with
|
2013-05-04 04:11:48 +08:00
|
|
|
// simple return expressions.
|
|
|
|
|
|
|
|
// CHECK: define {{.*}}foo
|
2015-02-05 03:47:54 +08:00
|
|
|
// CHECK: call void @_ZN1CD1Ev(%class.C* {{.*}}), !dbg ![[RET:[0-9]+]]
|
|
|
|
// CHECK: ret i32 0, !dbg ![[RET]]
|
2013-05-04 04:11:48 +08:00
|
|
|
|
2013-07-25 08:23:42 +08:00
|
|
|
// CHECK: define {{.*}}bar
|
|
|
|
// CHECK: ret void, !dbg ![[RETBAR:[0-9]+]]
|
|
|
|
|
|
|
|
// CHECK: define {{.*}}baz
|
|
|
|
// CHECK: ret void, !dbg ![[RETBAZ:[0-9]+]]
|
|
|
|
|
2013-05-04 04:11:48 +08:00
|
|
|
class C {
|
|
|
|
public:
|
|
|
|
~C() {}
|
|
|
|
int i;
|
|
|
|
};
|
|
|
|
|
|
|
|
int foo()
|
|
|
|
{
|
|
|
|
C c;
|
|
|
|
c.i = 42;
|
|
|
|
return 0;
|
2015-02-05 03:47:54 +08:00
|
|
|
// This breakpoint should be at/before the cleanup code.
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: ![[RET]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
|
2013-05-04 04:11:48 +08:00
|
|
|
}
|
2013-07-25 08:23:42 +08:00
|
|
|
|
|
|
|
void bar()
|
|
|
|
{
|
|
|
|
if (!foo())
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: {{.*}} = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
|
2013-07-25 08:23:42 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (foo()) {
|
|
|
|
C c;
|
|
|
|
c.i = foo();
|
|
|
|
}
|
|
|
|
// Clang creates only a single ret instruction. Make sure it is at a useful line.
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: ![[RETBAR]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
|
2013-07-25 08:23:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void baz()
|
|
|
|
{
|
|
|
|
if (!foo())
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: ![[SCOPE1:.*]] = distinct !DILexicalBlock({{.*}}, line: [[@LINE-1]])
|
|
|
|
// CHECK: {{.*}} = !DILocation(line: [[@LINE+1]], scope: ![[SCOPE1]])
|
2013-07-25 08:23:42 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (foo()) {
|
|
|
|
// no cleanup
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: {{.*}} = !DILocation(line: [[@LINE+2]], scope: ![[SCOPE2:.*]])
|
|
|
|
// CHECK: ![[SCOPE2]] = distinct !DILexicalBlock({{.*}}, line: [[@LINE-3]])
|
2013-07-25 08:23:42 +08:00
|
|
|
return;
|
|
|
|
}
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: ![[RETBAZ]] = !DILocation(line: [[@LINE+1]], scope: !{{.*}})
|
2013-07-25 08:23:42 +08:00
|
|
|
}
|