1 | /// Test that destructors and destructors whose priorities are greater than 100 are tracked. |
---|---|
2 | // XFAIL: target={{.*haiku.*}} |
3 | // RUN: mkdir -p %t.dir && cd %t.dir |
4 | // RUN: %clang --coverage %s -o %t -dumpdir ./ |
5 | // RUN: rm -f gcov-destructor.gcda && %run %t |
6 | // RUN: llvm-cov gcov -t gcov-destructor.gcda | FileCheck %s |
7 | // UNSUPPORTED: darwin |
8 | |
9 | #include <unistd.h> |
10 | |
11 | void before_exec() {} // CHECK: 1: [[#@LINE]]:void before_exec |
12 | void after_exec() {} // CHECK-NEXT: 1: [[#@LINE]]:void after_exec |
13 | |
14 | __attribute__((constructor)) // CHECK: -: [[#@LINE]]:__attribute__ |
15 | void constructor() {} // CHECK-NEXT: 1: [[#@LINE]]: |
16 | |
17 | /// Runs before __llvm_gcov_writeout. |
18 | __attribute__((destructor)) // CHECK: -: [[#@LINE]]:__attribute__ |
19 | void destructor() {} // CHECK-NEXT: 1: [[#@LINE]]: |
20 | |
21 | __attribute__((destructor(101))) // CHECK: -: [[#@LINE]]:__attribute__ |
22 | void destructor_101() {} // CHECK-NEXT: 1: [[#@LINE]]: |
23 | |
24 | /// Runs after __llvm_gcov_writeout. |
25 | __attribute__((destructor(99))) // CHECK: -: [[#@LINE]]:__attribute__ |
26 | void destructor_99() {} // CHECK-NEXT: #####: [[#@LINE]]: |
27 | |
28 | int main() { |
29 | before_exec(); |
30 | // Implicit writeout. |
31 | execl(path: "/not_exist", arg: "not_exist", (char *)0); |
32 | // Still tracked. |
33 | after_exec(); |
34 | return 0; |
35 | } |
36 |