@@ -18,6 +18,7 @@ use crate::llvm::debuginfo::{
18
18
use crate :: value:: Value ;
19
19
20
20
use cstr:: cstr;
21
+ use rustc_codegen_ssa:: debuginfo:: type_names:: cpp_like_debuginfo;
21
22
use rustc_codegen_ssa:: traits:: * ;
22
23
use rustc_data_structures:: fingerprint:: Fingerprint ;
23
24
use rustc_data_structures:: fx:: FxHashMap ;
@@ -933,16 +934,16 @@ fn basic_type_metadata<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'l
933
934
934
935
// When targeting MSVC, emit MSVC style type names for compatibility with
935
936
// .natvis visualizers (and perhaps other existing native debuggers?)
936
- let msvc_like_names = cx. tcx . sess . target . is_like_msvc ;
937
+ let cpp_like_debuginfo = cpp_like_debuginfo ( cx. tcx ) ;
937
938
938
939
let ( name, encoding) = match t. kind ( ) {
939
940
ty:: Never => ( "!" , DW_ATE_unsigned ) ,
940
941
ty:: Tuple ( elements) if elements. is_empty ( ) => ( "()" , DW_ATE_unsigned ) ,
941
942
ty:: Bool => ( "bool" , DW_ATE_boolean ) ,
942
943
ty:: Char => ( "char" , DW_ATE_unsigned_char ) ,
943
- ty:: Int ( int_ty) if msvc_like_names => ( int_ty. msvc_basic_name ( ) , DW_ATE_signed ) ,
944
- ty:: Uint ( uint_ty) if msvc_like_names => ( uint_ty. msvc_basic_name ( ) , DW_ATE_unsigned ) ,
945
- ty:: Float ( float_ty) if msvc_like_names => ( float_ty. msvc_basic_name ( ) , DW_ATE_float ) ,
944
+ ty:: Int ( int_ty) if cpp_like_debuginfo => ( int_ty. msvc_basic_name ( ) , DW_ATE_signed ) ,
945
+ ty:: Uint ( uint_ty) if cpp_like_debuginfo => ( uint_ty. msvc_basic_name ( ) , DW_ATE_unsigned ) ,
946
+ ty:: Float ( float_ty) if cpp_like_debuginfo => ( float_ty. msvc_basic_name ( ) , DW_ATE_float ) ,
946
947
ty:: Int ( int_ty) => ( int_ty. name_str ( ) , DW_ATE_signed ) ,
947
948
ty:: Uint ( uint_ty) => ( uint_ty. name_str ( ) , DW_ATE_unsigned ) ,
948
949
ty:: Float ( float_ty) => ( float_ty. name_str ( ) , DW_ATE_float ) ,
@@ -959,7 +960,7 @@ fn basic_type_metadata<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'l
959
960
)
960
961
} ;
961
962
962
- if !msvc_like_names {
963
+ if !cpp_like_debuginfo {
963
964
return ty_metadata;
964
965
}
965
966
@@ -1521,13 +1522,6 @@ fn prepare_union_metadata<'ll, 'tcx>(
1521
1522
// Enums
1522
1523
//=-----------------------------------------------------------------------------
1523
1524
1524
- /// DWARF variant support is only available starting in LLVM 8, but
1525
- /// on MSVC we have to use the fallback mode, because LLVM doesn't
1526
- /// lower variant parts to PDB.
1527
- fn use_enum_fallback ( cx : & CodegenCx < ' _ , ' _ > ) -> bool {
1528
- cx. sess ( ) . target . is_like_msvc
1529
- }
1530
-
1531
1525
// FIXME(eddyb) maybe precompute this? Right now it's computed once
1532
1526
// per generator monomorphization, but it doesn't depend on substs.
1533
1527
fn generator_layout_and_saved_local_names < ' tcx > (
@@ -1602,7 +1596,10 @@ impl<'ll, 'tcx> EnumMemberDescriptionFactory<'ll, 'tcx> {
1602
1596
_ => bug ! ( ) ,
1603
1597
} ;
1604
1598
1605
- let fallback = use_enum_fallback ( cx) ;
1599
+ // While LLVM supports generating debuginfo for variant types (enums), it doesn't support
1600
+ // lowering that debuginfo to CodeView records for msvc targets. So if we are targeting
1601
+ // msvc, then we need to use a different, fallback encoding of the debuginfo.
1602
+ let fallback = cpp_like_debuginfo ( cx. tcx ) ;
1606
1603
// This will always find the metadata in the type map.
1607
1604
let self_metadata = type_metadata ( cx, self . enum_type , self . span ) ;
1608
1605
@@ -2155,7 +2152,10 @@ fn prepare_enum_metadata<'ll, 'tcx>(
2155
2152
return FinalMetadata ( discriminant_type_metadata ( tag. value ) ) ;
2156
2153
}
2157
2154
2158
- if use_enum_fallback ( cx) {
2155
+ // While LLVM supports generating debuginfo for variant types (enums), it doesn't support
2156
+ // lowering that debuginfo to CodeView records for msvc targets. So if we are targeting
2157
+ // msvc, then we need to use a different encoding of the debuginfo.
2158
+ if cpp_like_debuginfo ( tcx) {
2159
2159
let discriminant_type_metadata = match layout. variants {
2160
2160
Variants :: Single { .. } => None ,
2161
2161
Variants :: Multiple { tag_encoding : TagEncoding :: Niche { .. } , tag, .. }
0 commit comments