@@ -18,6 +18,7 @@ use crate::llvm::debuginfo::{
1818use crate :: value:: Value ;
1919
2020use cstr:: cstr;
21+ use rustc_codegen_ssa:: debuginfo:: type_names:: cpp_like_debuginfo;
2122use rustc_codegen_ssa:: traits:: * ;
2223use rustc_data_structures:: fingerprint:: Fingerprint ;
2324use rustc_data_structures:: fx:: FxHashMap ;
@@ -933,16 +934,16 @@ fn basic_type_metadata<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'l
933934
934935 // When targeting MSVC, emit MSVC style type names for compatibility with
935936 // .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 ) ;
937938
938939 let ( name, encoding) = match t. kind ( ) {
939940 ty:: Never => ( "!" , DW_ATE_unsigned ) ,
940941 ty:: Tuple ( elements) if elements. is_empty ( ) => ( "()" , DW_ATE_unsigned ) ,
941942 ty:: Bool => ( "bool" , DW_ATE_boolean ) ,
942943 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 ) ,
946947 ty:: Int ( int_ty) => ( int_ty. name_str ( ) , DW_ATE_signed ) ,
947948 ty:: Uint ( uint_ty) => ( uint_ty. name_str ( ) , DW_ATE_unsigned ) ,
948949 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
959960 )
960961 } ;
961962
962- if !msvc_like_names {
963+ if !cpp_like_debuginfo {
963964 return ty_metadata;
964965 }
965966
@@ -1525,13 +1526,6 @@ fn prepare_union_metadata<'ll, 'tcx>(
15251526// Enums
15261527//=-----------------------------------------------------------------------------
15271528
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-
15351529// FIXME(eddyb) maybe precompute this? Right now it's computed once
15361530// per generator monomorphization, but it doesn't depend on substs.
15371531fn generator_layout_and_saved_local_names < ' tcx > (
@@ -1606,7 +1600,10 @@ impl<'ll, 'tcx> EnumMemberDescriptionFactory<'ll, 'tcx> {
16061600 _ => bug ! ( ) ,
16071601 } ;
16081602
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 ) ;
16101607 // This will always find the metadata in the type map.
16111608 let self_metadata = type_metadata ( cx, self . enum_type , self . span ) ;
16121609
@@ -2159,7 +2156,10 @@ fn prepare_enum_metadata<'ll, 'tcx>(
21592156 return FinalMetadata ( discriminant_type_metadata ( tag. value ) ) ;
21602157 }
21612158
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) {
21632163 let discriminant_type_metadata = match layout. variants {
21642164 Variants :: Single { .. } => None ,
21652165 Variants :: Multiple { tag_encoding : TagEncoding :: Niche { .. } , tag, .. }
0 commit comments