mirror of
https://github.com/rust-lang/rust.git
synced 2025-11-17 21:06:15 +00:00
This removes the #[no_sanitize] attribute, which was behind an unstable feature named no_sanitize. Instead, we introduce the sanitize attribute which is more powerful and allows to be extended in the future (instead of just focusing on turning sanitizers off). This also makes sanitize(kernel_address = ..) attribute work with -Zsanitize=address To do it the same as how clang disables address sanitizer, we now disable ASAN on sanitize(kernel_address = "off") and KASAN on sanitize(address = "off"). The same was added to clang in https://reviews.llvm.org/D44981.
32 lines
782 B
Rust
32 lines
782 B
Rust
// Verifies that sanitize(xyz = "off") attribute prevents inlining when
|
|
// given sanitizer is enabled, but has no effect on inlining otherwise.
|
|
//
|
|
//@ needs-sanitizer-address
|
|
//@ needs-sanitizer-leak
|
|
//@ revisions: ASAN LSAN
|
|
//@ compile-flags: -Copt-level=3 -Zmir-opt-level=4 -Ctarget-feature=-crt-static
|
|
//@[ASAN] compile-flags: -Zsanitizer=address
|
|
//@[LSAN] compile-flags: -Zsanitizer=leak
|
|
|
|
#![crate_type = "lib"]
|
|
#![feature(sanitize)]
|
|
|
|
// ASAN-LABEL: define void @test
|
|
// ASAN: call {{.*}} @random_inline
|
|
// ASAN: }
|
|
//
|
|
// LSAN-LABEL: define void @test
|
|
// LSAN-NOT: call
|
|
// LSAN: }
|
|
#[no_mangle]
|
|
pub fn test(n: &mut u32) {
|
|
random_inline(n);
|
|
}
|
|
|
|
#[sanitize(address = "off")]
|
|
#[inline]
|
|
#[no_mangle]
|
|
pub fn random_inline(n: &mut u32) {
|
|
*n = 42;
|
|
}
|