1 | // RUN: %clangxx_cfi %debug_info_flags -fsanitize-stats -o %t %s |
2 | // RUN: env SANITIZER_STATS_PATH=%t.stats %run %t |
3 | // RUN: sanstats %t.stats | FileCheck %s |
4 | |
5 | // FIXME: We currently emit the wrong debug info under devirtualization. |
6 | // UNSUPPORTED: devirt |
7 | |
8 | // FIXME: %t.stats must be transferred from device to host for this to work on Android. |
9 | // XFAIL: android |
10 | |
11 | struct ABase {}; |
12 | |
13 | struct A : ABase { |
14 | virtual void vf() {} |
15 | void nvf() {} |
16 | }; |
17 | |
18 | extern "C" __attribute__((noinline)) void vcall(A *a) { |
19 | // CHECK: stats.cpp:[[@LINE+1]] {{_?}}vcall cfi-vcall 37 |
20 | a->vf(); |
21 | } |
22 | |
23 | extern "C" __attribute__((noinline)) void nvcall(A *a) { |
24 | // CHECK: stats.cpp:[[@LINE+1]] {{_?}}nvcall cfi-nvcall 51 |
25 | a->nvf(); |
26 | } |
27 | |
28 | extern "C" __attribute__((noinline)) A *dcast(A *a) { |
29 | // CHECK: stats.cpp:[[@LINE+1]] {{_?}}dcast cfi-derived-cast 24 |
30 | return (A *)(ABase *)a; |
31 | } |
32 | |
33 | extern "C" __attribute__((noinline)) A *ucast(A *a) { |
34 | // CHECK: stats.cpp:[[@LINE+1]] {{_?}}ucast cfi-unrelated-cast 81 |
35 | return (A *)(char *)a; |
36 | } |
37 | |
38 | extern "C" __attribute__((noinline)) void unreachable(A *a) { |
39 | // CHECK-NOT: unreachable |
40 | a->vf(); |
41 | } |
42 | |
43 | int main() { |
44 | A a; |
45 | for (unsigned i = 0; i != 37; ++i) |
46 | vcall(a: &a); |
47 | for (unsigned i = 0; i != 51; ++i) |
48 | nvcall(a: &a); |
49 | for (unsigned i = 0; i != 24; ++i) |
50 | dcast(a: &a); |
51 | for (unsigned i = 0; i != 81; ++i) |
52 | ucast(a: &a); |
53 | for (unsigned i = 0; i != 0; ++i) |
54 | unreachable(a: &a); |
55 | } |
56 | |