[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGen / memtag-globals.cpp
blobb4f5dc0d7dcf041ec4e6931b84985e2da26cf5f9
1 // RUN: %clang_cc1 -include %S/Inputs/sanitizer-extra-source.cpp \
2 // RUN: -fsanitize-ignorelist=%S/Inputs/sanitizer-ignorelist-global.txt \
3 // RUN: -fsanitize=memtag-globals -emit-llvm -o - %s | FileCheck %s
5 // RUN: %clang_cc1 -include %S/Inputs/sanitizer-extra-source.cpp \
6 // RUN: -fsanitize-ignorelist=%S/Inputs/sanitizer-ignorelist-src.txt \
7 // RUN: -fsanitize=memtag-globals -emit-llvm -o - %s | \
8 // RUN: FileCheck %s --check-prefix=IGNORELIST
10 int global;
11 int __attribute__((no_sanitize("memtag"))) attributed_global;
12 int __attribute__((disable_sanitizer_instrumentation)) disable_instrumentation_global;
13 int ignorelisted_global;
14 extern int external_global;
16 void func() {
17 static int static_var = 0;
18 const char *literal = "Hello, world!";
19 external_global = 1;
22 // CHECK: @{{.*}}extra_global{{.*}} ={{.*}} sanitize_memtag
23 // CHECK: @{{.*}}global{{.*}} ={{.*}} sanitize_memtag
25 // CHECK: @{{.*}}attributed_global{{.*}} =
26 // CHECK-NOT: sanitize_memtag
27 // CHECK: @{{.*}}disable_instrumentation_global{{.*}} =
28 // CHECK-NOT: sanitize_memtag
29 // CHECK: @{{.*}}ignorelisted_global{{.*}} =
30 // CHECK-NOT: sanitize_memtag
32 // CHECK: @{{.*}}static_var{{.*}} ={{.*}} sanitize_memtag
33 // CHECK: @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}} sanitize_memtag
34 // CHECK: @{{.*}}external_global{{.*}} ={{.*}} sanitize_memtag
36 // IGNORELIST: @{{.*}}extra_global{{.*}} ={{.*}} sanitize_memtag
38 // IGNORELIST: @{{.*}}global{{.*}} =
39 // IGNORELIST-NOT: sanitize_memtag
40 // IGNORELIST: @{{.*}}attributed_global{{.*}} =
41 // IGNORELIST-NOT: sanitize_memtag
42 // IGNORELIST: @{{.*}}disable_instrumentation_global{{.*}} =
43 // IGNORELIST-NOT: sanitize_memtag
44 // IGNORELIST: @{{.*}}ignorelisted_globa{{.*}} =
45 // IGNORELIST-NOT: sanitize_memtag
46 // IGNORELIST: @{{.*}}static_var{{.*}} =
47 // IGNORELIST-NOT: sanitize_memtag
48 // IGNORELIST: @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}}
49 // IGNORELIST-NOT: sanitize_memtag
50 // IGNORELIST: @{{.*}}external_global{{.*}} =
51 // IGNORELIST-NOT: sanitize_memtag