xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/linetable-cleanup.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc // Check the line numbers for cleanup code with EH in combination with
4f4a2713aSLionel Sambuc // simple return expressions.
5f4a2713aSLionel Sambuc 
6f4a2713aSLionel Sambuc // CHECK: define {{.*}}foo
7f4a2713aSLionel Sambuc // CHECK: call void @_ZN1CD1Ev(%class.C* {{.*}}), !dbg ![[CLEANUP:[0-9]+]]
8f4a2713aSLionel Sambuc // CHECK: ret i32 0, !dbg ![[RET:[0-9]+]]
9f4a2713aSLionel Sambuc 
10f4a2713aSLionel Sambuc // CHECK: define {{.*}}bar
11f4a2713aSLionel Sambuc // CHECK: ret void, !dbg ![[RETBAR:[0-9]+]]
12f4a2713aSLionel Sambuc 
13f4a2713aSLionel Sambuc // CHECK: define {{.*}}baz
14f4a2713aSLionel Sambuc // CHECK: ret void, !dbg ![[RETBAZ:[0-9]+]]
15f4a2713aSLionel Sambuc 
16f4a2713aSLionel Sambuc class C {
17f4a2713aSLionel Sambuc public:
~C()18f4a2713aSLionel Sambuc   ~C() {}
19f4a2713aSLionel Sambuc   int i;
20f4a2713aSLionel Sambuc };
21f4a2713aSLionel Sambuc 
foo()22f4a2713aSLionel Sambuc int foo()
23f4a2713aSLionel Sambuc {
24f4a2713aSLionel Sambuc   C c;
25f4a2713aSLionel Sambuc   c.i = 42;
26f4a2713aSLionel Sambuc   // This breakpoint should be at/before the cleanup code.
27*0a6a1f1dSLionel Sambuc   // CHECK: ![[CLEANUP]] = !MDLocation(line: [[@LINE+1]], scope: !{{.*}})
28f4a2713aSLionel Sambuc   return 0;
29*0a6a1f1dSLionel Sambuc   // CHECK: ![[RET]] = !MDLocation(line: [[@LINE+1]], scope: !{{.*}})
30f4a2713aSLionel Sambuc }
31f4a2713aSLionel Sambuc 
bar()32f4a2713aSLionel Sambuc void bar()
33f4a2713aSLionel Sambuc {
34f4a2713aSLionel Sambuc   if (!foo())
35*0a6a1f1dSLionel Sambuc     // CHECK: {{.*}} = !MDLocation(line: [[@LINE+1]], scope: !{{.*}})
36f4a2713aSLionel Sambuc     return;
37f4a2713aSLionel Sambuc 
38f4a2713aSLionel Sambuc   if (foo()) {
39f4a2713aSLionel Sambuc     C c;
40f4a2713aSLionel Sambuc     c.i = foo();
41f4a2713aSLionel Sambuc   }
42f4a2713aSLionel Sambuc   // Clang creates only a single ret instruction. Make sure it is at a useful line.
43*0a6a1f1dSLionel Sambuc   // CHECK: ![[RETBAR]] = !MDLocation(line: [[@LINE+1]], scope: !{{.*}})
44f4a2713aSLionel Sambuc }
45f4a2713aSLionel Sambuc 
baz()46f4a2713aSLionel Sambuc void baz()
47f4a2713aSLionel Sambuc {
48f4a2713aSLionel Sambuc   if (!foo())
49*0a6a1f1dSLionel Sambuc     // CHECK: ![[SCOPE1:.*]] = !{!"0xb\00[[@LINE-1]]\00{{.*}}", {{.*}} ; [ DW_TAG_lexical_block ]
50*0a6a1f1dSLionel Sambuc     // CHECK: {{.*}} = !MDLocation(line: [[@LINE+1]], scope: ![[SCOPE1]])
51f4a2713aSLionel Sambuc     return;
52f4a2713aSLionel Sambuc 
53f4a2713aSLionel Sambuc   if (foo()) {
54f4a2713aSLionel Sambuc     // no cleanup
55*0a6a1f1dSLionel Sambuc     // CHECK: {{.*}} = !MDLocation(line: [[@LINE+2]], scope: ![[SCOPE2:.*]])
56*0a6a1f1dSLionel Sambuc     // CHECK: ![[SCOPE2]] = !{!"0xb\00[[@LINE-3]]\00{{.*}}", {{.*}} ; [ DW_TAG_lexical_block ]
57f4a2713aSLionel Sambuc     return;
58f4a2713aSLionel Sambuc   }
59*0a6a1f1dSLionel Sambuc   // CHECK: ![[RETBAZ]] = !MDLocation(line: [[@LINE+1]], scope: !{{.*}})
60f4a2713aSLionel Sambuc }
61