diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-02-09 23:29:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-09 23:29:56 +0100 |
| commit | 6d40850e09966644d7c47742638fa53e4da7af1c (patch) | |
| tree | 9c07dc3ae5d2f7ec93c949cc11e8026e77386014 /compiler/rustc_codegen_ssa/src/debuginfo | |
| parent | 3f4aaf4f2e9fd49736e660475f446619e8734e09 (diff) | |
| parent | ed21805aee9ad1abed5dc5157ac568e95fd84afb (diff) | |
| download | rust-6d40850e09966644d7c47742638fa53e4da7af1c.tar.gz rust-6d40850e09966644d7c47742638fa53e4da7af1c.zip | |
Rollup merge of #93503 - michaelwoerister:fix-vtable-holder-debuginfo-regression, r=wesleywiser
debuginfo: Fix DW_AT_containing_type vtable debuginfo regression This PR brings back the `DW_AT_containing_type` attribute for vtables after it has accidentally been removed in #89597. It also implements a more accurate description of vtables. Instead of describing them as an array of void pointers, the compiler will now emit a struct type description with a field for each entry of the vtable. r? ``@wesleywiser`` This PR should fix issue https://github.com/rust-lang/rust/issues/93164. ~~The PR is blocked on https://github.com/rust-lang/rust/pull/93154 because both of them modify the `codegen/debug-vtable.rs` test case.~~
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/debuginfo')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs index 831c34d8f1f..3cb19c0eec6 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs @@ -469,7 +469,14 @@ fn push_debuginfo_type_name<'tcx>( } } -/// Computes a name for the global variable storing a vtable. +pub enum VTableNameKind { + // Is the name for the const/static holding the vtable? + GlobalVariable, + // Is the name for the type of the vtable? + Type, +} + +/// Computes a name for the global variable storing a vtable (or the type of that global variable). /// /// The name is of the form: /// @@ -478,10 +485,15 @@ fn push_debuginfo_type_name<'tcx>( /// or, when generating C++-like names: /// /// `impl$<path::to::SomeType, path::to::SomeTrait>::vtable$` +/// +/// If `kind` is `VTableNameKind::Type` then the last component is `{vtable_ty}` instead of just +/// `{vtable}`, so that the type and the corresponding global variable get assigned different +/// names. pub fn compute_debuginfo_vtable_name<'tcx>( tcx: TyCtxt<'tcx>, t: Ty<'tcx>, trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>, + kind: VTableNameKind, ) -> String { let cpp_like_debuginfo = cpp_like_debuginfo(tcx); @@ -514,7 +526,12 @@ pub fn compute_debuginfo_vtable_name<'tcx>( push_close_angle_bracket(cpp_like_debuginfo, &mut vtable_name); - let suffix = if cpp_like_debuginfo { "::vtable$" } else { "::{vtable}" }; + let suffix = match (cpp_like_debuginfo, kind) { + (true, VTableNameKind::GlobalVariable) => "::vtable$", + (false, VTableNameKind::GlobalVariable) => "::{vtable}", + (true, VTableNameKind::Type) => "::vtable_type$", + (false, VTableNameKind::Type) => "::{vtable_type}", + }; vtable_name.reserve_exact(suffix.len()); vtable_name.push_str(suffix); |
