Skip to content

Commit 54a78cf

Browse files
committed
tests: Test line number in debuginfo for diverging function calls
1 parent 855e0fe commit 54a78cf

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/// Make sure that line debuginfo is correct for diverging calls under certain
2+
/// conditions. In particular we want to ensure that the line number is never
3+
/// 0, but we check the absence of 0 by looking for the expected exact line
4+
/// numbers. Regression test for <https://github.com/rust-lang/rust/issues/59558>.
5+
6+
//@ compile-flags: -g -Clto -Copt-level=0
7+
//@ no-prefer-dynamic
8+
9+
// First find the scope of both diverge() calls, namely this main() function.
10+
// CHECK-DAG: [[MAIN_SCOPE:![0-9]+]] = distinct !DISubprogram(name: "main", linkageName: {{.*}}diverging_function_call_debuginfo{{.*}}main{{.*}}
11+
fn main() {
12+
if True == False {
13+
// unreachable
14+
// Then find the DILocation with the correct line number for this call ...
15+
// CHECK-DAG: [[UNREACHABLE_CALL_DBG:![0-9]+]] = !DILocation(line: [[@LINE+1]], {{.*}}scope: [[MAIN_SCOPE]]
16+
diverge();
17+
}
18+
19+
// ... and this call.
20+
// CHECK-DAG: [[LAST_CALL_DBG:![0-9]+]] = !DILocation(line: [[@LINE+1]], {{.*}}scope: [[MAIN_SCOPE]]
21+
diverge();
22+
}
23+
24+
#[derive(PartialEq)]
25+
pub enum MyBool {
26+
True,
27+
False,
28+
}
29+
30+
use MyBool::*;
31+
32+
fn diverge() -> ! {
33+
panic!();
34+
}
35+
36+
// Finally make sure both DILocation's belong to each the respective diverge() calls.
37+
// CHECK-DAG: call void {{.*}}diverging_function_call_debuginfo{{.*}}diverge{{.*}} !dbg [[LAST_CALL_DBG]]
38+
// CHECK-DAG: call void {{.*}}diverging_function_call_debuginfo{{.*}}diverge{{.*}} !dbg [[UNREACHABLE_CALL_DBG]]

0 commit comments

Comments
 (0)