@@ -356,8 +356,12 @@ impl Session {
356356 self . instrument_coverage ( ) && self . opts . unstable_opts . coverage_options . mcdc
357357 }
358358
359+ pub fn is_sanitizer_address_enabled ( & self ) -> bool {
360+ self . opts . cg . sanitizer . contains ( SanitizerSet :: ADDRESS )
361+ }
362+
359363 pub fn is_sanitizer_cfi_enabled ( & self ) -> bool {
360- self . opts . unstable_opts . sanitizer . contains ( SanitizerSet :: CFI )
364+ self . opts . cg . sanitizer . contains ( SanitizerSet :: CFI )
361365 }
362366
363367 pub fn is_sanitizer_cfi_canonical_jump_tables_disabled ( & self ) -> bool {
@@ -377,7 +381,19 @@ impl Session {
377381 }
378382
379383 pub fn is_sanitizer_kcfi_enabled ( & self ) -> bool {
380- self . opts . unstable_opts . sanitizer . contains ( SanitizerSet :: KCFI )
384+ self . opts . cg . sanitizer . contains ( SanitizerSet :: KCFI )
385+ }
386+
387+ pub fn is_sanitizer_memory_enabled ( & self ) -> bool {
388+ self . opts . cg . sanitizer . contains ( SanitizerSet :: MEMORY )
389+ }
390+
391+ pub fn is_sanitizer_memory_track_origins_enabled ( & self ) -> bool {
392+ self . opts . unstable_opts . sanitizer_memory_track_origins != 0
393+ }
394+
395+ pub fn is_sanitizer_thread_enabled ( & self ) -> bool {
396+ self . opts . cg . sanitizer . contains ( SanitizerSet :: THREAD )
381397 }
382398
383399 pub fn is_split_lto_unit_enabled ( & self ) -> bool {
@@ -595,7 +611,7 @@ impl Session {
595611 // AddressSanitizer and KernelAddressSanitizer uses lifetimes to detect use after scope bugs.
596612 // MemorySanitizer uses lifetimes to detect use of uninitialized stack variables.
597613 // HWAddressSanitizer will use lifetimes to detect use after scope bugs in the future.
598- || self . opts . unstable_opts . sanitizer . intersects ( SanitizerSet :: ADDRESS | SanitizerSet :: KERNELADDRESS | SanitizerSet :: MEMORY | SanitizerSet :: HWADDRESS )
614+ || self . opts . cg . sanitizer . intersects ( SanitizerSet :: ADDRESS | SanitizerSet :: KERNELADDRESS | SanitizerSet :: MEMORY | SanitizerSet :: HWADDRESS )
599615 }
600616
601617 pub fn diagnostic_width ( & self ) -> usize {
@@ -722,7 +738,7 @@ impl Session {
722738 let more_names = self . opts . output_types . contains_key ( & OutputType :: LlvmAssembly )
723739 || self . opts . output_types . contains_key ( & OutputType :: Bitcode )
724740 // AddressSanitizer and MemorySanitizer use alloca name when reporting an issue.
725- || self . opts . unstable_opts . sanitizer . intersects ( SanitizerSet :: ADDRESS | SanitizerSet :: MEMORY ) ;
741+ || self . opts . cg . sanitizer . intersects ( SanitizerSet :: ADDRESS | SanitizerSet :: MEMORY ) ;
726742 !more_names
727743 }
728744 }
@@ -1167,8 +1183,12 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
11671183 }
11681184
11691185 // Sanitizers can only be used on platforms that we know have working sanitizer codegen.
1170- let supported_sanitizers = sess. target . options . supported_sanitizers ;
1171- let unsupported_sanitizers = sess. opts . unstable_opts . sanitizer - supported_sanitizers;
1186+ let supported_sanitizers = if sess. unstable_options ( ) {
1187+ sess. target . options . supported_sanitizers . supported_sanitizers ( )
1188+ } else {
1189+ sess. target . options . supported_sanitizers . stable_sanitizers ( )
1190+ } ;
1191+ let unsupported_sanitizers = sess. opts . cg . sanitizer - supported_sanitizers;
11721192 match unsupported_sanitizers. into_iter ( ) . count ( ) {
11731193 0 => { }
11741194 1 => {
@@ -1182,7 +1202,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
11821202 }
11831203 }
11841204 // Cannot mix and match sanitizers.
1185- let mut sanitizer_iter = sess. opts . unstable_opts . sanitizer . into_iter ( ) ;
1205+ let mut sanitizer_iter = sess. opts . cg . sanitizer . into_iter ( ) ;
11861206 if let ( Some ( first) , Some ( second) ) = ( sanitizer_iter. next ( ) , sanitizer_iter. next ( ) ) {
11871207 sess. dcx ( ) . emit_err ( errors:: CannotMixAndMatchSanitizers {
11881208 first : first. to_string ( ) ,
@@ -1191,10 +1211,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
11911211 }
11921212
11931213 // Cannot enable crt-static with sanitizers on Linux
1194- if sess. crt_static ( None )
1195- && !sess. opts . unstable_opts . sanitizer . is_empty ( )
1196- && !sess. target . is_like_msvc
1197- {
1214+ if sess. crt_static ( None ) && !sess. opts . cg . sanitizer . is_empty ( ) && !sess. target . is_like_msvc {
11981215 sess. dcx ( ) . emit_err ( errors:: CannotEnableCrtStaticLinux ) ;
11991216 }
12001217
0 commit comments