1
Fork 0

Add additional option checks

This commit is contained in:
Matt Weber 2023-07-30 00:04:47 -04:00
parent a4833a8089
commit 4692d46a46
2 changed files with 38 additions and 9 deletions

View file

@ -1221,6 +1221,12 @@ 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 def_location = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
Some(file_metadata_from_def_id(cx, Some(def_id)))
} else {
None
};
type_map::build_type_with_children( type_map::build_type_with_children(
cx, cx,
type_map::stub( type_map::stub(
@ -1228,7 +1234,7 @@ fn build_closure_env_di_node<'ll, 'tcx>(
Stub::Struct, Stub::Struct,
unique_type_id, unique_type_id,
&type_name, &type_name,
Some(file_metadata_from_def_id(cx, Some(def_id))), def_location,
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,

View file

@ -56,6 +56,12 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
assert!(!wants_c_like_enum_debuginfo(cx.tcx, enum_type_and_layout)); assert!(!wants_c_like_enum_debuginfo(cx.tcx, enum_type_and_layout));
let def_location = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
Some(file_metadata_from_def_id(cx, Some(enum_adt_def.did())))
} else {
None
};
type_map::build_type_with_children( type_map::build_type_with_children(
cx, cx,
type_map::stub( type_map::stub(
@ -63,7 +69,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
Stub::Struct, Stub::Struct,
unique_type_id, unique_type_id,
&enum_type_name, &enum_type_name,
Some(file_metadata_from_def_id(cx, Some(enum_adt_def.did()))), def_location,
size_and_align_of(enum_type_and_layout), size_and_align_of(enum_type_and_layout),
Some(containing_scope), Some(containing_scope),
visibility_flags, visibility_flags,
@ -86,18 +92,29 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
enum_type_and_layout.for_variant(cx, variant_index), enum_type_and_layout.for_variant(cx, variant_index),
visibility_flags, visibility_flags,
), ),
source_info: Some(file_metadata_from_def_id( source_info: if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo
cx, {
Some(enum_adt_def.variant(variant_index).def_id), Some(file_metadata_from_def_id(
)), cx,
Some(enum_adt_def.variant(variant_index).def_id),
))
} else {
None
},
}) })
.collect(); .collect();
let enum_adt_def_id = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo
{
Some(enum_adt_def.did())
} else {
None
};
smallvec![build_enum_variant_part_di_node( smallvec![build_enum_variant_part_di_node(
cx, cx,
enum_type_and_layout, enum_type_and_layout,
enum_type_di_node, enum_type_di_node,
enum_adt_def.did(), enum_adt_def_id,
&variant_member_infos[..], &variant_member_infos[..],
)] )]
}, },
@ -210,6 +227,12 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
}) })
.collect(); .collect();
let generator_def_id =
if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
Some(generator_def_id)
} else {
None
};
smallvec![build_enum_variant_part_di_node( smallvec![build_enum_variant_part_di_node(
cx, cx,
coroutine_type_and_layout, coroutine_type_and_layout,
@ -242,7 +265,7 @@ fn build_enum_variant_part_di_node<'ll, 'tcx>(
cx: &CodegenCx<'ll, 'tcx>, cx: &CodegenCx<'ll, 'tcx>,
enum_type_and_layout: TyAndLayout<'tcx>, enum_type_and_layout: TyAndLayout<'tcx>,
enum_type_di_node: &'ll DIType, enum_type_di_node: &'ll DIType,
enum_type_def_id: rustc_span::def_id::DefId, enum_type_def_id: Option<rustc_span::def_id::DefId>,
variant_member_infos: &[VariantMemberInfo<'_, 'll>], variant_member_infos: &[VariantMemberInfo<'_, 'll>],
) -> &'ll DIType { ) -> &'ll DIType {
let tag_member_di_node = let tag_member_di_node =
@ -253,7 +276,7 @@ fn build_enum_variant_part_di_node<'ll, 'tcx>(
let (file_metadata, line_number) = let (file_metadata, line_number) =
if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo { if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
file_metadata_from_def_id(cx, Some(enum_type_def_id)) file_metadata_from_def_id(cx, enum_type_def_id)
} else { } else {
(unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER) (unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER)
}; };