[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGen / asan-globals-alias.cpp
blobfad23fbb0dc6cff30826bce024b48e94ff15fb3c
1 // RUN: %clang_cc1 -triple x86_64-linux -fsanitize=address -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,ASAN
2 // RUN: %clang_cc1 -triple x86_64-linux -O2 -fsanitize=address -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,ASAN
3 // RUN: %clang_cc1 -triple x86_64-linux -fsanitize=kernel-address -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,KASAN
4 // RUN: %clang_cc1 -triple x86_64-linux -O2 -fsanitize=kernel-address -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,KASAN
5 //
6 // Not all platforms support aliases - test for Linux only.
8 int global; // generate ctor for at least 1 global
9 int aliased_global; // KASAN ignored
10 extern int __attribute__((alias("aliased_global"))) __global_alias;
12 // Recursive alias:
13 int aliased_global_2; // KASAN ignored
14 extern int __attribute__((alias("aliased_global_2"))) global_alias_2;
15 extern int __attribute__((alias("global_alias_2"))) __global_alias_2_alias;
17 // Potential indirect alias:
18 struct input_device_id {
19 unsigned long keybit[24];
20 unsigned long driver_info;
22 struct input_device_id joydev_ids[] = { { {1}, 1234 } }; // KASAN ignored
23 extern struct input_device_id __attribute__((alias("joydev_ids"))) __mod_joydev_ids_device_table;
25 // ASAN: @aliased_global{{.*}} global { i32, [28 x i8] }{{.*}}, align 32
26 // ASAN: @aliased_global_2{{.*}} global { i32, [28 x i8] }{{.*}}, align 32
27 // ASAN: @joydev_ids{{.*}} global { {{.*}}[56 x i8] zeroinitializer }, align 32
28 // KASAN: @aliased_global{{.*}} global i32
29 // KASAN: @aliased_global_2{{.*}} global i32
30 // KASAN: @joydev_ids{{.*}} global [1 x {{.*}}i64 1234 }], align 16
32 // Check the aliases exist:
33 // CHECK: @__global_alias ={{.*}} alias
34 // CHECK: @global_alias_2 ={{.*}} alias
35 // CHECK: @__global_alias_2_alias ={{.*}} alias
36 // CHECK: @__mod_joydev_ids_device_table ={{.*}} alias
38 // CHECK-LABEL: define internal void @asan.module_ctor
39 // ASAN: call void @__asan_register_globals({{.*}}, i{{32|64}} 4)
40 // KASAN: call void @__asan_register_globals({{.*}}, i{{32|64}} 1)
41 // CHECK-NEXT: ret void
43 // CHECK-LABEL: define internal void @asan.module_dtor
44 // CHECK-NEXT: call void @__asan_unregister_globals
45 // CHECK-NEXT: ret void