@@ -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
@@ -1525,13 +1526,6 @@ fn prepare_union_metadata<'ll, 'tcx>(
1525
1526
// Enums
1526
1527
//=-----------------------------------------------------------------------------
1527
1528
1528
- /// DWARF variant support is only available starting in LLVM 8, but
1529
- /// on MSVC we have to use the fallback mode, because LLVM doesn't
1530
- /// lower variant parts to PDB.
1531
- fn use_enum_fallback ( cx : & CodegenCx < ' _ , ' _ > ) -> bool {
1532
- cx. sess ( ) . target . is_like_msvc
1533
- }
1534
-
1535
1529
// FIXME(eddyb) maybe precompute this? Right now it's computed once
1536
1530
// per generator monomorphization, but it doesn't depend on substs.
1537
1531
fn generator_layout_and_saved_local_names < ' tcx > (
@@ -1606,7 +1600,10 @@ impl<'ll, 'tcx> EnumMemberDescriptionFactory<'ll, 'tcx> {
1606
1600
_ => bug ! ( ) ,
1607
1601
} ;
1608
1602
1609
- let fallback = use_enum_fallback ( cx) ;
1603
+ // While LLVM supports generating debuginfo for variant types (enums), it doesn't support
1604
+ // lowering that debuginfo to CodeView records for msvc targets. So if we are targeting
1605
+ // msvc, then we need to use a different, fallback encoding of the debuginfo.
1606
+ let fallback = cpp_like_debuginfo ( cx. tcx ) ;
1610
1607
// This will always find the metadata in the type map.
1611
1608
let self_metadata = type_metadata ( cx, self . enum_type , self . span ) ;
1612
1609
@@ -2159,7 +2156,10 @@ fn prepare_enum_metadata<'ll, 'tcx>(
2159
2156
return FinalMetadata ( discriminant_type_metadata ( tag. value ) ) ;
2160
2157
}
2161
2158
2162
- if use_enum_fallback ( cx) {
2159
+ // While LLVM supports generating debuginfo for variant types (enums), it doesn't support
2160
+ // lowering that debuginfo to CodeView records for msvc targets. So if we are targeting
2161
+ // msvc, then we need to use a different encoding of the debuginfo.
2162
+ if cpp_like_debuginfo ( tcx) {
2163
2163
let discriminant_type_metadata = match layout. variants {
2164
2164
Variants :: Single { .. } => None ,
2165
2165
Variants :: Multiple { tag_encoding : TagEncoding :: Niche { .. } , tag, .. }
0 commit comments