1
Fork 0

Add file and line metadata for coroutines

This commit is contained in:
Matt Weber 2022-11-16 23:12:44 -05:00
parent f3da828185
commit c07797a854
3 changed files with 10 additions and 2 deletions

View file

@ -263,6 +263,9 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
unique_type_id: UniqueTypeId<'tcx>, unique_type_id: UniqueTypeId<'tcx>,
) -> DINodeCreationResult<'ll> { ) -> DINodeCreationResult<'ll> {
let coroutine_type = unique_type_id.expect_ty(); let coroutine_type = unique_type_id.expect_ty();
let &ty::Coroutine(coroutine_def_id, _, _) = coroutine_type.kind() else {
bug!("build_coroutine_di_node() called with non-coroutine type: `{:?}`", coroutine_type)
};
let coroutine_type_and_layout = cx.layout_of(coroutine_type); let coroutine_type_and_layout = cx.layout_of(coroutine_type);
let coroutine_type_name = compute_debuginfo_type_name(cx.tcx, coroutine_type, false); let coroutine_type_name = compute_debuginfo_type_name(cx.tcx, coroutine_type, false);
@ -275,7 +278,7 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
type_map::Stub::Union, type_map::Stub::Union,
unique_type_id, unique_type_id,
&coroutine_type_name, &coroutine_type_name,
None, Some(coroutine_def_id),
size_and_align_of(coroutine_type_and_layout), size_and_align_of(coroutine_type_and_layout),
NO_SCOPE_METADATA, NO_SCOPE_METADATA,
DIFlags::FlagZero, DIFlags::FlagZero,

View file

@ -142,7 +142,7 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
Stub::Struct, Stub::Struct,
unique_type_id, unique_type_id,
&coroutine_type_name, &coroutine_type_name,
None, Some(coroutine_def_id),
size_and_align_of(coroutine_type_and_layout), size_and_align_of(coroutine_type_and_layout),
Some(containing_scope), Some(containing_scope),
DIFlags::FlagZero, DIFlags::FlagZero,

View file

@ -2,6 +2,7 @@
// //
// compile-flags: -C debuginfo=2 // compile-flags: -C debuginfo=2
#![crate_type = "lib"] #![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 // The use of CHECK-DAG here is because the C++-like enum is emitted before the `DIFile` node
@ -31,4 +32,8 @@ pub fn foo(_: MyType, _: MyUnion, _: MyNativeEnum, _: MyCppLikeEnum) {
// CHECK: !DICompositeType({{.*"[{]}}closure_env#0{{[}]".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]], // CHECK: !DICompositeType({{.*"[{]}}closure_env#0{{[}]".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
let closure = |x| x; let closure = |x| x;
closure(0); closure(0);
// CHECK: !DICompositeType({{.*"[{]}}generator_env#1{{[}]".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
let generator = #[coroutine]
|| yield 1;
} }