diff options
| author | David Wood <david@davidtw.co> | 2020-06-22 13:36:53 +0100 |
|---|---|---|
| committer | David Wood <david@davidtw.co> | 2020-07-20 11:23:31 +0100 |
| commit | 19e849516e19fcb0a16be7d3e329c1bbb1746fa3 (patch) | |
| tree | 7bbce6384fc4d84e8ff8fdc4abd115c36ac8a7f3 | |
| parent | 5bf2c7d4fec536c4237e859390c524837324977f (diff) | |
| download | rust-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>
| -rw-r--r-- | src/librustc_codegen_llvm/debuginfo/metadata.rs | 16 | ||||
| -rw-r--r-- | src/librustc_codegen_ssa/debuginfo/type_names.rs | 7 |
2 files changed, 21 insertions, 2 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, diff --git a/src/librustc_codegen_ssa/debuginfo/type_names.rs b/src/librustc_codegen_ssa/debuginfo/type_names.rs index 20d440433cb..fb8f5a62989 100644 --- a/src/librustc_codegen_ssa/debuginfo/type_names.rs +++ b/src/librustc_codegen_ssa/debuginfo/type_names.rs @@ -205,14 +205,17 @@ pub fn push_debuginfo_type_name<'tcx>( tcx.def_key(def_id).disambiguated_data.disambiguator )); } + // Type parameters from polymorphized functions. + ty::Param(_) => { + output.push_str(&format!("{:?}", t)); + } ty::Error(_) | ty::Infer(_) | ty::Placeholder(..) | ty::Projection(..) | ty::Bound(..) | ty::Opaque(..) - | ty::GeneratorWitness(..) - | ty::Param(_) => { + | ty::GeneratorWitness(..) => { bug!( "debuginfo: Trying to create type name for \ unexpected type: {:?}", |
