1 /// A basic block with fork/exec* is split. .gcda is flushed immediately before
2 /// fork/exec* so the lines before fork are counted once while succeeding
3 /// lines are counted twice.
4 // RUN: mkdir -p %t.d && cd %t.d
5 // RUN: %clang --coverage %s -o %t
6 // RUN: test -f gcov-fork.gcno
7 
8 // RUN: rm -f gcov-fork.gcda && %run %t
9 // RUN: llvm-cov gcov -t gcov-fork.gcda | FileCheck %s
10 
11 #include <sys/wait.h>
12 #include <unistd.h>
13 
func1()14 void func1() {}                    // CHECK:      1: [[#@LINE]]:void func1()
func2()15 void func2() {}                    // CHECK-NEXT: 2: [[#@LINE]]:
main(void)16 int main(void) {                   // CHECK-NEXT: 1: [[#@LINE]]:
17   int status;                      // CHECK-NEXT: -: [[#@LINE]]:
18   func1();                         // CHECK-NEXT: 1: [[#@LINE]]:
19   pid_t pid = fork();              // CHECK-NEXT: 1: [[#@LINE]]:
20   if (pid == -1) return 1;         // CHECK-NEXT: 1: [[#@LINE]]:
21   if (pid)                         // CHECK-NEXT: 2: [[#@LINE]]:
22     wait(&status);                 // CHECK-NEXT: 1: [[#@LINE]]:
23   func2();                         // CHECK-NEXT: 2: [[#@LINE]]:
24   return 0;                        // CHECK-NEXT: 2: [[#@LINE]]:
25 }
26