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 |
4 | // instrumentation. |
5 | // Same for __attribute__((no_sanitize("hwaddress")) and |
6 | // __attribute__((no_sanitize("kernel-hwddress")) and HWASan and KHWASan. |
7 | |
8 | // RUN: %clang_cc1 -triple i386-unknown-linux -disable-O0-optnone \ |
9 | // RUN: -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NOASAN %s |
10 | |
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 |
14 | |
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 |
18 | |
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 |
22 | |
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 |
26 | |
27 | int HasSanitizeAddress() { return 1; } |
28 | // CHECK-NOASAN: {{Function Attrs: noinline nounwind$}} |
29 | // CHECK-ASAN: Function Attrs: noinline nounwind sanitize_address |
30 | // CHECK-KASAN: Function Attrs: noinline nounwind sanitize_address |
31 | // CHECK-HWASAN: Function Attrs: noinline nounwind sanitize_hwaddress |
32 | // CHECK-KHWASAN: Function Attrs: noinline nounwind sanitize_hwaddress |
33 | |
34 | __attribute__((no_sanitize("address"))) int NoSanitizeQuoteAddress() { |
35 | return 0; |
36 | } |
37 | // CHECK-NOASAN: {{Function Attrs: noinline nounwind$}} |
38 | // CHECK-ASAN: {{Function Attrs: noinline nounwind$}} |
39 | // CHECK-KASAN: {{Function Attrs: noinline nounwind$}} |
40 | // CHECK-HWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}} |
41 | // CHECK-KHWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}} |
42 | |
43 | __attribute__((no_sanitize_address)) int NoSanitizeAddress() { return 0; } |
44 | // CHECK-NOASAN: {{Function Attrs: noinline nounwind$}} |
45 | // CHECK-ASAN: {{Function Attrs: noinline nounwind$}} |
46 | // CHECK-KASAN: {{Function Attrs: noinline nounwind$}} |
47 | // CHECK-HWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}} |
48 | // CHECK-KHWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}} |
49 | |
50 | __attribute__((no_sanitize("kernel-address"))) int NoSanitizeKernelAddress() { |
51 | return 0; |
52 | } |
53 | // CHECK-NOASAN: {{Function Attrs: noinline nounwind$}} |
54 | // CHECK-ASAN: {{Function Attrs: noinline nounwind$}} |
55 | // CHECK-KASAN: {{Function Attrs: noinline nounwind$}} |
56 | // CHECK-HWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}} |
57 | // CHECK-KHWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}} |
58 | |
59 | __attribute__((no_sanitize("hwaddress"))) int NoSanitizeHWAddress() { |
60 | return 0; |
61 | } |
62 | // CHECK-NOASAN: {{Function Attrs: noinline nounwind$}} |
63 | // CHECK-ASAN: {{Function Attrs: noinline nounwind sanitize_address$}} |
64 | // CHECK-KASAN: {{Function Attrs: noinline nounwind sanitize_address$}} |
65 | // CHECK-HWASAN: {{Function Attrs: noinline nounwind$}} |
66 | // CHECK-KHWASAN: {{Function Attrs: noinline nounwind$}} |
67 | |
68 | __attribute__((no_sanitize("kernel-hwaddress"))) int NoSanitizeKernelHWAddress() { |
69 | return 0; |
70 | } |
71 | // CHECK-NOASAN: {{Function Attrs: noinline nounwind$}} |
72 | // CHECK-ASAN: {{Function Attrs: noinline nounwind sanitize_address$}} |
73 | // CHECK-KASAN: {{Function Attrs: noinline nounwind sanitize_address$}} |
74 | // CHECK-HWASAN: {{Function Attrs: noinline nounwind$}} |
75 | // CHECK-KHWASAN: {{Function Attrs: noinline nounwind$}} |
76 | |