@@ -8,15 +8,14 @@ use rustc_hir::def::DefKind;
88use rustc_hir:: def_id:: { DefId , LOCAL_CRATE , LocalDefId } ;
99use rustc_hir:: { self as hir, Attribute , LangItem , find_attr, lang_items} ;
1010use rustc_middle:: middle:: codegen_fn_attrs:: {
11- CodegenFnAttrFlags , CodegenFnAttrs , PatchableFunctionEntry ,
11+ CodegenFnAttrFlags , CodegenFnAttrs , PatchableFunctionEntry , SanitizerFnAttrs ,
1212} ;
1313use rustc_middle:: query:: Providers ;
1414use rustc_middle:: span_bug;
1515use rustc_middle:: ty:: { self as ty, TyCtxt } ;
1616use rustc_session:: lint;
1717use rustc_session:: parse:: feature_err;
1818use rustc_span:: { Ident , Span , sym} ;
19- use rustc_target:: spec:: SanitizerSet ;
2019
2120use crate :: errors;
2221use crate :: target_features:: {
@@ -351,7 +350,8 @@ fn apply_overrides(tcx: TyCtxt<'_>, did: LocalDefId, codegen_fn_attrs: &mut Code
351350 Ord :: max ( codegen_fn_attrs. alignment , tcx. sess . opts . unstable_opts . min_function_alignment ) ;
352351
353352 // Compute the disabled sanitizers.
354- codegen_fn_attrs. no_sanitize |= tcx. disabled_sanitizers_for ( did) ;
353+ codegen_fn_attrs. sanitizers . disabled |=
354+ tcx. sanitizer_settings_for ( did) . disabled ;
355355 // On trait methods, inherit the `#[align]` of the trait's method prototype.
356356 codegen_fn_attrs. alignment = Ord :: max ( codegen_fn_attrs. alignment , tcx. inherited_align ( did) ) ;
357357
@@ -455,14 +455,14 @@ fn check_result(
455455 }
456456
457457 // warn that inline has no effect when no_sanitize is present
458- if ! codegen_fn_attrs. no_sanitize . is_empty ( )
458+ if codegen_fn_attrs. sanitizers != SanitizerFnAttrs :: default ( )
459459 && codegen_fn_attrs. inline . always ( )
460- && let ( Some ( no_sanitize_span ) , Some ( inline_span) ) =
460+ && let ( Some ( sanitize_span ) , Some ( inline_span) ) =
461461 ( interesting_spans. sanitize , interesting_spans. inline )
462462 {
463463 let hir_id = tcx. local_def_id_to_hir_id ( did) ;
464- tcx. node_span_lint ( lint:: builtin:: INLINE_NO_SANITIZE , hir_id, no_sanitize_span , |lint| {
465- lint. primary_message ( "setting `sanitize` off will have no effect after inlining" ) ;
464+ tcx. node_span_lint ( lint:: builtin:: INLINE_NO_SANITIZE , hir_id, sanitize_span , |lint| {
465+ lint. primary_message ( "non-default `sanitize` will have no effect after inlining" ) ;
466466 lint. span_note ( inline_span, "inlining requested here" ) ;
467467 } )
468468 }
@@ -576,30 +576,30 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
576576 codegen_fn_attrs
577577}
578578
579- fn disabled_sanitizers_for ( tcx : TyCtxt < ' _ > , did : LocalDefId ) -> SanitizerSet {
579+ fn sanitizer_settings_for ( tcx : TyCtxt < ' _ > , did : LocalDefId ) -> SanitizerFnAttrs {
580580 // Backtrack to the crate root.
581- let mut disabled = match tcx. opt_local_parent ( did) {
581+ let mut settings = match tcx. opt_local_parent ( did) {
582582 // Check the parent (recursively).
583- Some ( parent) => tcx. disabled_sanitizers_for ( parent) ,
583+ Some ( parent) => tcx. sanitizer_settings_for ( parent) ,
584584 // We reached the crate root without seeing an attribute, so
585585 // there is no sanitizers to exclude.
586- None => SanitizerSet :: empty ( ) ,
586+ None => SanitizerFnAttrs :: default ( ) ,
587587 } ;
588588
589589 // Check for a sanitize annotation directly on this def.
590590 if let Some ( ( on_set, off_set) ) = find_attr ! ( tcx. get_all_attrs( did) , AttributeKind :: Sanitize { on_set, off_set, ..} => ( on_set, off_set) )
591591 {
592592 // the on set is the set of sanitizers explicitly enabled.
593593 // we mask those out since we want the set of disabled sanitizers here
594- disabled &= !* on_set;
594+ settings . disabled &= !* on_set;
595595 // the off set is the set of sanitizers explicitly disabled.
596596 // we or those in here.
597- disabled |= * off_set;
597+ settings . disabled |= * off_set;
598598 // the on set and off set are distjoint since there's a third option: unset.
599599 // a node may not set the sanitizer setting in which case it inherits from parents.
600600 // the code above in this function does this backtracking
601601 }
602- disabled
602+ settings
603603}
604604
605605/// Checks if the provided DefId is a method in a trait impl for a trait which has track_caller
@@ -731,7 +731,7 @@ pub(crate) fn provide(providers: &mut Providers) {
731731 codegen_fn_attrs,
732732 should_inherit_track_caller,
733733 inherited_align,
734- disabled_sanitizers_for ,
734+ sanitizer_settings_for ,
735735 ..* providers
736736 } ;
737737}
0 commit comments