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