summaryrefslogtreecommitdiffstats
path: root/src/test/codegen/sanitizer-no-sanitize.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/codegen/sanitizer-no-sanitize.rs')
-rw-r--r--src/test/codegen/sanitizer-no-sanitize.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/codegen/sanitizer-no-sanitize.rs b/src/test/codegen/sanitizer-no-sanitize.rs
new file mode 100644
index 000000000..fb9d249da
--- /dev/null
+++ b/src/test/codegen/sanitizer-no-sanitize.rs
@@ -0,0 +1,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
+}