1 // Make sure the sanitize_address attribute is emitted when using ASan, KASan or
2 // HWASan. Either __attribute__((no_sanitize("address")) or
3 // __attribute__((no_sanitize("kernel-address")) disables both ASan and KASan
5 // Same for __attribute__((no_sanitize("hwaddress")) and
6 // __attribute__((no_sanitize("kernel-hwddress")) and HWASan and KHWASan.
8 // RUN: %clang_cc1 -triple i386-unknown-linux -disable-O0-optnone \
9 // RUN: -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NOASAN %s
11 // RUN: %clang_cc1 -triple i386-unknown-linux -fsanitize=address \
12 // RUN: -disable-O0-optnone -emit-llvm -o - %s | \
13 // RUN: FileCheck -check-prefix=CHECK-ASAN %s
15 // RUN: %clang_cc1 -triple i386-unknown-linux -fsanitize=kernel-address \
16 // RUN: -disable-O0-optnone -emit-llvm -o - %s | \
17 // RUN: FileCheck -check-prefix=CHECK-KASAN %s
19 // RUN: %clang_cc1 -triple i386-unknown-linux -fsanitize=hwaddress \
20 // RUN: -disable-O0-optnone -emit-llvm -o - %s | \
21 // RUN: FileCheck -check-prefix=CHECK-HWASAN %s
23 // RUN: %clang_cc1 -triple i386-unknown-linux -fsanitize=kernel-hwaddress \
24 // RUN: -disable-O0-optnone -emit-llvm -o - %s | \
25 // RUN: FileCheck -check-prefix=CHECK-KHWASAN %s
27 int HasSanitizeAddress() { return 1; }
28 // CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}}
29 // CHECK-ASAN: Function Attrs: mustprogress noinline nounwind sanitize_address
30 // CHECK-KASAN: Function Attrs: mustprogress noinline nounwind sanitize_address
31 // CHECK-HWASAN: Function Attrs: mustprogress noinline nounwind sanitize_hwaddress
32 // CHECK-KHWASAN: Function Attrs: mustprogress noinline nounwind sanitize_hwaddress
34 __attribute__((no_sanitize("address"))) int NoSanitizeQuoteAddress() {
37 // CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}}
38 // CHECK-ASAN: {{Function Attrs: mustprogress noinline nounwind$}}
39 // CHECK-KASAN: {{Function Attrs: mustprogress noinline nounwind$}}
40 // CHECK-HWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}}
41 // CHECK-KHWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}}
43 __attribute__((no_sanitize_address
)) int NoSanitizeAddress() { return 0; }
44 // CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}}
45 // CHECK-ASAN: {{Function Attrs: mustprogress noinline nounwind$}}
46 // CHECK-KASAN: {{Function Attrs: mustprogress noinline nounwind$}}
47 // CHECK-HWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}}
48 // CHECK-KHWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}}
50 __attribute__((no_sanitize("kernel-address"))) int NoSanitizeKernelAddress() {
53 // CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}}
54 // CHECK-ASAN: {{Function Attrs: mustprogress noinline nounwind$}}
55 // CHECK-KASAN: {{Function Attrs: mustprogress noinline nounwind$}}
56 // CHECK-HWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}}
57 // CHECK-KHWASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_hwaddress$}}
59 __attribute__((no_sanitize("hwaddress"))) int NoSanitizeHWAddress() {
62 // CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}}
63 // CHECK-ASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_address$}}
64 // CHECK-KASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_address$}}
65 // CHECK-HWASAN: {{Function Attrs: mustprogress noinline nounwind$}}
66 // CHECK-KHWASAN: {{Function Attrs: mustprogress noinline nounwind$}}
68 __attribute__((no_sanitize("kernel-hwaddress"))) int NoSanitizeKernelHWAddress() {
71 // CHECK-NOASAN: {{Function Attrs: mustprogress noinline nounwind$}}
72 // CHECK-ASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_address$}}
73 // CHECK-KASAN: {{Function Attrs: mustprogress noinline nounwind sanitize_address$}}
74 // CHECK-HWASAN: {{Function Attrs: mustprogress noinline nounwind$}}
75 // CHECK-KHWASAN: {{Function Attrs: mustprogress noinline nounwind$}}
77 __attribute__((disable_sanitizer_instrumentation
)) int DisableSanitizerInstrumentation() {
80 // CHECK-NOASAN: {{Function Attrs: disable_sanitizer_instrumentation mustprogress noinline nounwind$}}
81 // CHECK-ASAN: {{Function Attrs: disable_sanitizer_instrumentation mustprogress noinline nounwind$}}
82 // CHECK-KASAN: {{Function Attrs: disable_sanitizer_instrumentation mustprogress noinline nounwind$}}
83 // CHECK-HWASAN: {{Function Attrs: disable_sanitizer_instrumentation mustprogress noinline nounwind$}}
84 // CHECK-KHWASAN: {{Function Attrs: disable_sanitizer_instrumentation mustprogress noinline nounwind$}}