about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/debuginfo
diff options
context:
space:
mode:
authorMatt Weber <30441572+mweber15@users.noreply.github.com>2023-07-30 00:04:47 -0400
committerMatt Weber <30441572+mweber15@users.noreply.github.com>2024-11-06 22:26:17 -0500
commit4692d46a461502ed5732a80cd0848db50cfc678a (patch)
treec6db7502d286ae642b7e818beaf4358f82f14837 /compiler/rustc_codegen_llvm/src/debuginfo
parenta4833a80893612a8e97b65777caa1c5f87d38c2c (diff)
downloadrust-4692d46a461502ed5732a80cd0848db50cfc678a.tar.gz
rust-4692d46a461502ed5732a80cd0848db50cfc678a.zip
Add additional option checks
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/debuginfo')
-rw-r--r--compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs8
-rw-r--r--compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs39
2 files changed, 38 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
index 10264af65f4..0a442f44a8d 100644
--- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
+++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
@@ -1221,6 +1221,12 @@ fn build_closure_env_di_node<'ll, 'tcx>(
     let containing_scope = get_namespace_for_item(cx, def_id);
     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(
         cx,
         type_map::stub(
@@ -1228,7 +1234,7 @@ fn build_closure_env_di_node<'ll, 'tcx>(
             Stub::Struct,
             unique_type_id,
             &type_name,
-            Some(file_metadata_from_def_id(cx, Some(def_id))),
+            def_location,
             cx.size_and_align_of(closure_env_type),
             Some(containing_scope),
             DIFlags::FlagZero,
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs
index 0d289d8995d..326aba7d2f3 100644
--- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs
+++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs
@@ -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));
 
+    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(
         cx,
         type_map::stub(
@@ -63,7 +69,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
             Stub::Struct,
             unique_type_id,
             &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),
             Some(containing_scope),
             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),
                         visibility_flags,
                     ),
-                    source_info: Some(file_metadata_from_def_id(
-                        cx,
-                        Some(enum_adt_def.variant(variant_index).def_id),
-                    )),
+                    source_info: if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo
+                    {
+                        Some(file_metadata_from_def_id(
+                            cx,
+                            Some(enum_adt_def.variant(variant_index).def_id),
+                        ))
+                    } else {
+                        None
+                    },
                 })
                 .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(
                 cx,
                 enum_type_and_layout,
                 enum_type_di_node,
-                enum_adt_def.did(),
+                enum_adt_def_id,
                 &variant_member_infos[..],
             )]
         },
@@ -210,6 +227,12 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
                 })
                 .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(
                 cx,
                 coroutine_type_and_layout,
@@ -242,7 +265,7 @@ fn build_enum_variant_part_di_node<'ll, 'tcx>(
     cx: &CodegenCx<'ll, 'tcx>,
     enum_type_and_layout: TyAndLayout<'tcx>,
     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>],
 ) -> &'ll DIType {
     let tag_member_di_node =
@@ -253,7 +276,7 @@ fn build_enum_variant_part_di_node<'ll, 'tcx>(
 
     let (file_metadata, line_number) =
         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 {
             (unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER)
         };