about summary refs log tree commit diff
path: root/src/librustc_codegen_llvm
diff options
context:
space:
mode:
authorDavid Wood <david@davidtw.co>2020-06-22 13:36:53 +0100
committerDavid Wood <david@davidtw.co>2020-07-20 11:23:31 +0100
commit19e849516e19fcb0a16be7d3e329c1bbb1746fa3 (patch)
tree7bbce6384fc4d84e8ff8fdc4abd115c36ac8a7f3 /src/librustc_codegen_llvm
parent5bf2c7d4fec536c4237e859390c524837324977f (diff)
downloadrust-19e849516e19fcb0a16be7d3e329c1bbb1746fa3.tar.gz
rust-19e849516e19fcb0a16be7d3e329c1bbb1746fa3.zip
debuginfo: add type metadata for params
This commit adds type metadata for generic parameters (that arise from
polymorphization). Generic parameter metadata is considered zero-sized
and named after the generic parameter.

Signed-off-by: David Wood <david@davidtw.co>
Diffstat (limited to 'src/librustc_codegen_llvm')
-rw-r--r--src/librustc_codegen_llvm/debuginfo/metadata.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs
index ef9d42968ae..c34c6caa8ca 100644
--- a/src/librustc_codegen_llvm/debuginfo/metadata.rs
+++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs
@@ -700,6 +700,8 @@ pub fn type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>, usage_site_span: Sp
             prepare_tuple_metadata(cx, t, &tys, unique_type_id, usage_site_span, NO_SCOPE_METADATA)
                 .finalize(cx)
         }
+        // Type parameters from polymorphized functions.
+        ty::Param(_) => MetadataCreationResult::new(param_type_metadata(cx, t), false),
         _ => bug!("debuginfo: unexpected type in type_metadata: {:?}", t),
     };
 
@@ -955,6 +957,20 @@ fn pointer_type_metadata(
     }
 }
 
+fn param_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
+    debug!("param_type_metadata: {:?}", t);
+    let name = format!("{:?}", t);
+    return unsafe {
+        llvm::LLVMRustDIBuilderCreateBasicType(
+            DIB(cx),
+            name.as_ptr().cast(),
+            name.len(),
+            Size::ZERO.bits(),
+            DW_ATE_unsigned,
+        )
+    };
+}
+
 pub fn compile_unit_metadata(
     tcx: TyCtxt<'_>,
     codegen_unit_name: &str,