Skip to content

Commit ec51b15

Browse files
authored
Rollup merge of #112182 - rcvalle:rust-cfi-fix-111185, r=compiler-errors
CFI: Fix cfi with repr(transparent): transform_ty: unexpected Alias(Proj Fixes #111185 by normalizing ty::Alias before encoding.
2 parents f121f77 + faf31b5 commit ec51b15

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -697,12 +697,12 @@ fn encode_ty<'tcx>(
697697
}
698698

699699
// Unexpected types
700-
ty::Bound(..)
700+
ty::Alias(..)
701+
| ty::Bound(..)
701702
| ty::Error(..)
702703
| ty::GeneratorWitness(..)
703704
| ty::GeneratorWitnessMIR(..)
704705
| ty::Infer(..)
705-
| ty::Alias(..)
706706
| ty::Placeholder(..) => {
707707
bug!("encode_ty: unexpected `{:?}`", ty.kind());
708708
}
@@ -946,11 +946,18 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio
946946
);
947947
}
948948

949+
ty::Alias(..) => {
950+
ty = transform_ty(
951+
tcx,
952+
tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), ty),
953+
options,
954+
);
955+
}
956+
949957
ty::Bound(..)
950958
| ty::Error(..)
951959
| ty::GeneratorWitnessMIR(..)
952960
| ty::Infer(..)
953-
| ty::Alias(..)
954961
| ty::Param(..)
955962
| ty::Placeholder(..) => {
956963
bug!("transform_ty: unexpected `{:?}`", ty.kind());

tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,6 @@ pub fn foo149(_: Type14<Bar>, _: Type14<Bar>, _: Type14<Bar>) { }
587587
// CHECK: ![[TYPE144]] = !{i64 0, !"_ZTSFvu3refIvEE"}
588588
// CHECK: ![[TYPE145]] = !{i64 0, !"_ZTSFvu3refIvES_E"}
589589
// CHECK: ![[TYPE146]] = !{i64 0, !"_ZTSFvu3refIvES_S_E"}
590-
// CHECK: ![[TYPE147]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarE
591-
// CHECK: ![[TYPE148]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_E
592-
// CHECK: ![[TYPE149]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_S_E
590+
// CHECK: ![[TYPE147]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarE"}
591+
// CHECK: ![[TYPE148]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_E"}
592+
// CHECK: ![[TYPE149]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_S_E"}

0 commit comments

Comments
 (0)