[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGen / sanitizer-special-case-list-globals.c
blobf2680f2ca5f57f4aeb544d8aaf6ea03747b5c536
1 /// Verify that ignorelist sections correctly select sanitizers to apply
2 /// ignorelist entries to.
4 // RUN: %clang_cc1 -emit-llvm %s -o -\
5 // RUN: -fsanitize-ignorelist=%S/Inputs/sanitizer-special-case-list-globals.txt \
6 // RUN: | FileCheck %s --check-prefix=NONE
8 // RUN: %clang_cc1 -fsanitize=address -emit-llvm %s -o -\
9 // RUN: -fsanitize-ignorelist=%S/Inputs/sanitizer-special-case-list-globals.txt \
10 // RUN: | FileCheck %s --check-prefix=ASAN
12 /// Note: HWASan effectively reorders globals (it puts the unsanitized ones
13 /// first), which is hard to check for, as 'CHECK-DAG' doesn't play terribly
14 /// nicely with 'CHECK-NOT'. This is why the 'always_ignored' and
15 /// 'hwasan_ignored' comes first in this file.
16 // RUN: %clang_cc1 -fsanitize=hwaddress -triple=aarch64-linux-android31 -emit-llvm %s -o -\
17 // RUN: -fsanitize-ignorelist=%S/Inputs/sanitizer-special-case-list-globals.txt \
18 // RUN: | FileCheck %s --check-prefix=HWASAN
20 // RUN: %clang_cc1 -fsanitize=memtag-globals -triple=aarch64-linux-android31 \
21 // RUN: -fsanitize-ignorelist=%S/Inputs/sanitizer-special-case-list-globals.txt \
22 // RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=MEMTAG
24 /// Check that the '[cfi-vcall|cfi-icall] src:*' rule in the ignorelist doesn't change
25 /// anything for ASan.
26 // RUN: %clang_cc1 -fsanitize=address -emit-llvm %s -o -\
27 // RUN: -fsanitize-ignorelist=%S/Inputs/sanitizer-special-case-list-globals.txt \
28 // RUN: | FileCheck %s --check-prefix=ASAN
30 /// Check that -fsanitize=kernel-address picks up the '[address]' groups.
31 // RUN: %clang_cc1 -fsanitize=kernel-address -mllvm -hwasan-kernel=1 -emit-llvm %s -o -\
32 // RUN: -fsanitize-ignorelist=%S/Inputs/sanitizer-special-case-list-globals.txt \
33 // RUN: | FileCheck %s --check-prefix=ASAN
35 /// KHWASan doesn't instrument global variables.
36 // RUN: %clang_cc1 -fsanitize=kernel-hwaddress -mllvm -hwasan-kernel=1 -emit-llvm %s -o -\
37 // RUN: -fsanitize-ignorelist=%S/Inputs/sanitizer-special-case-list-globals.txt \
38 // RUN: | FileCheck %s --check-prefix=NONE
40 /// Check that the '[cfi-vcall|cfi-icall] src:*' rule doesnt' emit anything for
41 /// GVs.
42 // RUN: %clang_cc1 -fsanitize=cfi-vcall,cfi-icall -emit-llvm %s -o -\
43 // RUN: -fsanitize-ignorelist=%S/Inputs/sanitizer-special-case-list-globals.txt \
44 // RUN: | FileCheck %s --check-prefix=NONE
46 // NONE: @always_ignored ={{.*}} global
47 // NONE-NOT: no_sanitize
48 // ASAN: @always_ignored ={{.*}} global {{.*}}, no_sanitize_address
49 // HWASAN: @always_ignored ={{.*}} global {{.*}}, no_sanitize_hwaddress
50 // MEMTAG: @always_ignored ={{.*}} global
51 // MEMTAG-NOT: sanitize_memtag
52 unsigned always_ignored;
54 // NONE: @hwasan_ignored ={{.*}} global
55 // NONE-NOT: no_sanitize
56 // ASAN: @hwasan_ignored ={{.*}} global
57 // ASAN-NOT: no_sanitize_address
58 // HWASAN: @hwasan_ignored ={{.*}} global {{.*}}, no_sanitize_hwaddress
59 // MEMTAG: @hwasan_ignored ={{.*}} global {{.*}} sanitize_memtag
60 unsigned hwasan_ignored;
62 // NONE: @asan_ignored ={{.*}} global
63 // NONE-NOT: asan_ignored
64 // ASAN: @asan_ignored ={{.*}} global {{.*}}, no_sanitize_address
65 // HWASAN: @asan_ignored.hwasan = {{.*}} global
66 // HWASAN-NOT: no_sanitize_hwaddress
67 // MEMTAG: @asan_ignored ={{.*}} global {{.*}} sanitize_memtag
68 unsigned asan_ignored;
70 // NONE: @memtag_ignored ={{.*}} global
71 // NONE-NOT: memtag_ignored
72 // ASAN: @memtag_ignored ={{.*}} global
73 // ASAN-NOT: no_sanitize_address
74 // HWASAN: @memtag_ignored.hwasan = {{.*}} global
75 // HWASAN-NOT: no_sanitize_hwaddress
76 // MEMTAG: @memtag_ignored ={{.*}} global
77 // MEMTAG-NOT: sanitize_memtag
78 unsigned memtag_ignored;
80 // NONE: @never_ignored ={{.*}} global
81 // NONE-NOT: never_ignored
82 // ASAN: @never_ignored ={{.*}} global
83 // ASAN-NOT: no_sanitize_address
84 // HWASAN: @never_ignored.hwasan ={{.*}} global
85 // HWASAN-NOT: no_sanitize_hwaddress
86 // MEMTAG: @never_ignored ={{.*}} global {{.*}} sanitize_memtag
87 unsigned never_ignored;