1
Fork 0

Split metadata testing into multiple files

This helps with the fact that the order in which debuginfo is emitted
differs between platforms, and is probably not guaranteed to be stable
in general.
This commit is contained in:
Matt Weber 2023-01-21 13:57:16 -05:00
parent 27b1b01daa
commit cc4f214a78
5 changed files with 74 additions and 46 deletions

View file

@ -0,0 +1,18 @@
// This test verifies the accuracy of emitted file and line debuginfo metadata for closures and
// generators.
//
// compile-flags: -C debuginfo=2
#![crate_type = "lib"]
#![feature(generators, stmt_expr_attributes)]
// CHECK: ![[#FILE:]] = !DIFile({{.*}}filename:{{.*}}/codegen/issue-98678-closure-generator.rs{{".*}})
pub fn foo() {
// CHECK: !DICompositeType({{.*"[{]}}closure_env#0{{[}]".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
let closure = |x| x;
closure(0);
// CHECK: !DICompositeType({{.*"[{]}}generator_env#1{{[}]".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
let generator = #[coroutine]
|| yield 1;
}

View file

@ -0,0 +1,17 @@
// This test verifies the accuracy of emitted file and line debuginfo metadata for C++-like
// enumerations.
//
// compile-flags: -C debuginfo=2
#![crate_type = "lib"]
// The use of CHECK-DAG here is because the C++-like enum is emitted before the `DIFile` node
// CHECK-DAG: ![[#FILE:]] = !DIFile({{.*}}filename:{{.*}}/codegen/issue-98678-cpp-like-enum.rs{{".*}})
// CHECK-DAG: !DICompositeType({{.*"}}MyCppLikeEnum{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 2]],
#[repr(C)]
pub enum MyCppLikeEnum {
One,
}
pub fn foo(_: MyCppLikeEnum) {}

View file

@ -0,0 +1,16 @@
// This test verifies the accuracy of emitted file and line debuginfo metadata for native
// enumerations.
//
// compile-flags: -C debuginfo=2
#![crate_type = "lib"]
// CHECK: ![[#FILE:]] = !DIFile({{.*}}filename:{{.*}}/codegen/issue-98678-native-enum.rs{{".*}})
// CHECK: !DICompositeType({{.*"}}MyNativeEnum{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 2]],
// CHECK: !DICompositeType({{.*}}DW_TAG_variant_part{{.*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
pub enum MyNativeEnum {
// CHECK: !DIDerivedType({{.*"}}One{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
One,
}
pub fn foo(_: MyNativeEnum) {}

View file

@ -0,0 +1,23 @@
// This test verifies the accuracy of emitted file and line debuginfo metadata for structs and
// unions.
//
// compile-flags: -C debuginfo=2
#![crate_type = "lib"]
// CHECK: ![[#FILE:]] = !DIFile({{.*}}filename:{{.*}}/codegen/issue-98678-struct-union.rs{{".*}})
// CHECK: !DICompositeType({{.*"}}MyType{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
pub struct MyType {
// CHECK: !DIDerivedType({{.*"}}i{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
i: i32,
}
// CHECK: !DICompositeType({{.*"}}MyUnion{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
pub union MyUnion {
// CHECK: !DIDerivedType({{.*"}}i{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
i: i32,
// CHECK: !DIDerivedType({{.*"}}f{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
f: f32,
}
pub fn foo(_: MyType, _: MyUnion) {}

View file

@ -1,46 +0,0 @@
// This test verifies the accuracy of emitted file and line debuginfo metadata.
//
// compile-flags: -C debuginfo=2
#![crate_type = "lib"]
#![feature(generators, stmt_expr_attributes)]
// The use of CHECK-DAG here is because the C++-like enum is emitted before the `DIFile` node
// CHECK-DAG: ![[#FILE:]] = !DIFile({{.*}}filename:{{.*}}/codegen/issue-98678.rs{{".*}})
// CHECK-DAG: !DICompositeType({{.*"}}MyCppLikeEnum{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 2]],
#[repr(C)]
pub enum MyCppLikeEnum {
One,
}
// CHECK: !DICompositeType({{.*"}}MyType{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
pub struct MyType {
// CHECK: !DIDerivedType({{.*"}}i{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
i: i32,
}
// CHECK: !DICompositeType({{.*"}}MyUnion{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
pub union MyUnion {
// CHECK: !DIDerivedType({{.*"}}i{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
i: i32,
// CHECK: !DIDerivedType({{.*"}}f{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
f: f32,
}
// CHECK: !DICompositeType({{.*"}}MyNativeEnum{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 2]],
// CHECK: !DICompositeType({{.*}}DW_TAG_variant_part{{.*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
pub enum MyNativeEnum {
// CHECK: !DIDerivedType({{.*"}}One{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
One,
}
pub fn foo(_: MyType, _: MyUnion, _: MyNativeEnum, _: MyCppLikeEnum) {
// CHECK: !DICompositeType({{.*"[{]}}closure_env#0{{[}]".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
let closure = |x| x;
closure(0);
// CHECK: !DICompositeType({{.*"[{]}}generator_env#1{{[}]".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
let generator = #[coroutine]
|| yield 1;
}