summaryrefslogtreecommitdiffstats
path: root/src/test/codegen/sanitizer-no-sanitize.rs
blob: fb9d249da03d533c1198f0902767fc73cc93b993 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Verifies that no_sanitize attribute can be used to
// selectively disable sanitizer instrumentation.
//
// needs-sanitizer-address
// compile-flags: -Zsanitizer=address

#![crate_type="lib"]
#![feature(no_sanitize)]

// CHECK-LABEL: ; sanitizer_no_sanitize::unsanitized
// CHECK-NEXT:  ; Function Attrs:
// CHECK-NOT:   sanitize_address
// CHECK:       start:
// CHECK-NOT:   call void @__asan_report_load
// CHECK:       }
#[no_sanitize(address)]
pub fn unsanitized(b: &mut u8) -> u8 {
    *b
}

// CHECK-LABEL: ; sanitizer_no_sanitize::sanitized
// CHECK-NEXT:  ; Function Attrs:
// CHECK:       sanitize_address
// CHECK:       start:
// CHECK:       call void @__asan_report_load
// CHECK:       }
pub fn sanitized(b: &mut u8) -> u8 {
    *b
}