1 // Make sure the sanitize_address attribute is emitted when using both ASan and KASan.
2 // Also document that __attribute__((no_sanitize_address)) doesn't disable KASan instrumentation.
3
4 /// RUN: %clang_cc1 -triple i386-unknown-linux -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NOASAN %s
5 /// RUN: %clang_cc1 -triple i386-unknown-linux -fsanitize=address -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-ASAN %s
6 /// RUN: %clang_cc1 -triple i386-unknown-linux -fsanitize=kernel-address -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-KASAN %s
7
HasSanitizeAddress()8 int HasSanitizeAddress() {
9 return 1;
10 }
11 // CHECK-NOASAN: {{Function Attrs: nounwind$}}
12 // CHECK-ASAN: Function Attrs: nounwind sanitize_address
13 // CHECK-KASAN: Function Attrs: nounwind sanitize_address
14
15 __attribute__((no_sanitize("address")))
NoSanitizeQuoteAddress()16 int NoSanitizeQuoteAddress() {
17 return 0;
18 }
19 // CHECK-NOASAN: {{Function Attrs: nounwind$}}
20 // CHECK-ASAN: {{Function Attrs: nounwind$}}
21 // CHECK-KASAN: {{Function Attrs: nounwind sanitize_address$}}
22
23 __attribute__((no_sanitize_address))
NoSanitizeAddress()24 int NoSanitizeAddress() {
25 return 0;
26 }
27 // CHECK-NOASAN: {{Function Attrs: nounwind$}}
28 // CHECK-ASAN: {{Function Attrs: nounwind$}}
29 // CHECK-KASAN: {{Function Attrs: nounwind sanitize_address$}}
30
31 __attribute__((no_sanitize("kernel-address")))
NoSanitizeKernelAddress()32 int NoSanitizeKernelAddress() {
33 return 0;
34 }
35
36 // CHECK-NOASAN: {{Function Attrs: nounwind$}}
37 // CHECK-ASAN: {{Function Attrs: nounwind sanitize_address$}}
38 // CHECK-KASAN: {{Function Attrs: nounwind$}}
39