Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / address-safety-attr-flavors.cpp
blobef815555059db82f6311f34b62c2d0ce945c3995
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.
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() {
35 return 0;
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() {
51 return 0;
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() {
60 return 0;
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() {
69 return 0;
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() {
78 return 0;
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$}}