]> git.lizzy.rs Git - rust.git/blob - tests/codegen/sanitizer-no-sanitize.rs
Move /src/test to /tests
[rust.git] / tests / codegen / sanitizer-no-sanitize.rs
1 // Verifies that no_sanitize attribute can be used to
2 // selectively disable sanitizer instrumentation.
3 //
4 // needs-sanitizer-address
5 // compile-flags: -Zsanitizer=address
6
7 #![crate_type="lib"]
8 #![feature(no_sanitize)]
9
10 // CHECK-LABEL: ; sanitizer_no_sanitize::unsanitized
11 // CHECK-NEXT:  ; Function Attrs:
12 // CHECK-NOT:   sanitize_address
13 // CHECK:       start:
14 // CHECK-NOT:   call void @__asan_report_load
15 // CHECK:       }
16 #[no_sanitize(address)]
17 pub fn unsanitized(b: &mut u8) -> u8 {
18     *b
19 }
20
21 // CHECK-LABEL: ; sanitizer_no_sanitize::sanitized
22 // CHECK-NEXT:  ; Function Attrs:
23 // CHECK:       sanitize_address
24 // CHECK:       start:
25 // CHECK:       call void @__asan_report_load
26 // CHECK:       }
27 pub fn sanitized(b: &mut u8) -> u8 {
28     *b
29 }