Add file and line metadata for closures
This commit is contained in:
parent
5b23c38dd5
commit
94669d9d47
2 changed files with 15 additions and 3 deletions
|
@ -1212,6 +1212,14 @@ fn build_closure_env_di_node<'ll, 'tcx>(
|
||||||
let containing_scope = get_namespace_for_item(cx, def_id);
|
let containing_scope = get_namespace_for_item(cx, def_id);
|
||||||
let type_name = compute_debuginfo_type_name(cx.tcx, closure_env_type, false);
|
let type_name = compute_debuginfo_type_name(cx.tcx, closure_env_type, false);
|
||||||
|
|
||||||
|
let closure_span = cx.tcx.def_span(def_id);
|
||||||
|
let (file_metadata, line_number) = if !closure_span.is_dummy() {
|
||||||
|
let loc = cx.lookup_debug_loc(closure_span.lo());
|
||||||
|
(file_metadata(cx, &loc.file), loc.line)
|
||||||
|
} else {
|
||||||
|
(unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER)
|
||||||
|
};
|
||||||
|
|
||||||
type_map::build_type_with_children(
|
type_map::build_type_with_children(
|
||||||
cx,
|
cx,
|
||||||
type_map::stub(
|
type_map::stub(
|
||||||
|
@ -1219,8 +1227,8 @@ fn build_closure_env_di_node<'ll, 'tcx>(
|
||||||
Stub::Struct,
|
Stub::Struct,
|
||||||
unique_type_id,
|
unique_type_id,
|
||||||
&type_name,
|
&type_name,
|
||||||
unknown_file_metadata(cx),
|
file_metadata,
|
||||||
UNKNOWN_LINE_NUMBER,
|
line_number,
|
||||||
cx.size_and_align_of(closure_env_type),
|
cx.size_and_align_of(closure_env_type),
|
||||||
Some(containing_scope),
|
Some(containing_scope),
|
||||||
DIFlags::FlagZero,
|
DIFlags::FlagZero,
|
||||||
|
|
|
@ -8,4 +8,8 @@
|
||||||
// CHECK: !DICompositeType({{.*"}}MyType{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
|
// CHECK: !DICompositeType({{.*"}}MyType{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
|
||||||
pub struct MyType;
|
pub struct MyType;
|
||||||
|
|
||||||
pub fn foo(_: MyType) {}
|
pub fn foo(_: MyType) {
|
||||||
|
// CHECK: !DICompositeType({{.*"[{]}}closure_env#0{{[}]".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
|
||||||
|
let closure = |x| x;
|
||||||
|
closure(0);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue