[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / cfi-stats.cpp
blob11018aa38b47bd9a2c00b0f0bb633364d49cdbf3
1 // RUN: %clang_cc1 -triple x86_64-unknown-linux -fvisibility=hidden -fsanitize=cfi-vcall,cfi-nvcall,cfi-derived-cast,cfi-unrelated-cast,cfi-icall -fsanitize-stats -emit-llvm -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple x86_64-unknown-linux -fvisibility=hidden -fsanitize=cfi-vcall,cfi-nvcall,cfi-derived-cast,cfi-unrelated-cast,cfi-icall -fsanitize-trap=cfi-vcall -fwhole-program-vtables -fsanitize-stats -emit-llvm -o - %s | FileCheck %s
4 // CHECK: [[STATS:@[^ ]*]] = internal global { ptr, i32, [5 x [2 x ptr]] } { ptr null, i32 5, [5 x [2 x ptr]]
5 // CHECK: {{\[\[}}2 x ptr] zeroinitializer,
6 // CHECK: [2 x ptr] [ptr null, ptr inttoptr (i64 2305843009213693952 to ptr)],
7 // CHECK: [2 x ptr] [ptr null, ptr inttoptr (i64 4611686018427387904 to ptr)],
8 // CHECK: [2 x ptr] [ptr null, ptr inttoptr (i64 6917529027641081856 to ptr)],
9 // CHECK: [2 x ptr] [ptr null, ptr inttoptr (i64 -9223372036854775808 to ptr)]] }
11 // CHECK: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 0, ptr [[CTOR:@[^ ]*]], ptr null }]
13 struct A {
14 virtual void vf();
15 void nvf();
17 struct B : A {};
19 // CHECK: @vcall
20 extern "C" void vcall(A *a) {
21 // CHECK: call void @__sanitizer_stat_report({{.*}}[[STATS]]{{.*}}i64 0, i32 2, i64 0
22 a->vf();
25 // CHECK: @nvcall
26 extern "C" void nvcall(A *a) {
27 // CHECK: call void @__sanitizer_stat_report({{.*}}[[STATS]]{{.*}}i64 0, i32 2, i64 1
28 a->nvf();
31 // CHECK: @dcast
32 extern "C" void dcast(A *a) {
33 // CHECK: call void @__sanitizer_stat_report({{.*}}[[STATS]]{{.*}}i64 0, i32 2, i64 2
34 static_cast<B *>(a);
37 // CHECK: @ucast
38 extern "C" void ucast(void *a) {
39 // CHECK: call void @__sanitizer_stat_report({{.*}}[[STATS]]{{.*}}i64 0, i32 2, i64 3
40 reinterpret_cast<A *>(a);
43 // CHECK: @icall
44 extern "C" void icall(void (*p)()) {
45 // CHECK: call void @__sanitizer_stat_report({{.*}}[[STATS]]{{.*}}i64 0, i32 2, i64 4
46 p();
49 // CHECK: define internal void [[CTOR]]()
50 // CHECK-NEXT: call void @__sanitizer_stat_init(ptr [[STATS]])
51 // CHECK-NEXT: ret void