1// RUN: rm -rf %t && split-file %s %t && cd %t
2// RUN: %clangxx --coverage main.cpp -o t
3// RUN: %run ./t
4// RUN: llvm-cov gcov -t t-main. | FileCheck %s
5
6//--- main.cpp
7#include "a.h"
8#include <stdio.h>
9
10// CHECK: Runs:1
11/// __cxx_global_var_init contains a block from a.h. Don't attribute its lines to main.cpp.
12// CHECK-NOT: {{^ +[0-9]+:}}
13
14inline auto *const inl_var_main = // CHECK: 1: [[#]]:inline auto
15 new A; // CHECK-NEXT: 1: [[#]]:
16void foo(int x) { // CHECK-NEXT: 1: [[#]]:
17 if (x) { // CHECK-NEXT: 1: [[#]]:
18#include "a.inc"
19 }
20}
21// CHECK-NOT: {{^ +[0-9]+:}}
22
23int main(int argc, char *argv[]) { // CHECK: 1: [[#]]:int main
24 foo(x: 1); // CHECK-NEXT: 1: [[#]]:
25} // CHECK-NEXT: 1: [[#]]:
26// CHECK-NOT: {{^ +[0-9]+:}}
27
28// CHECK: Source:a.h
29// CHECK: 1: 1:struct A
30// CHECK-NOT: {{^ +[0-9]+:}}
31
32//--- a.h
33/// Apple targets doesn't enable -mconstructor-aliases by default and the count may be 4.
34struct A { A() { } }; // CHECK: {{[24]}}: [[#]]:struct A
35inline auto *const inl_var_a =
36 new A;
37/// TODO a.inc:1 should have line execution.
38// CHECK-NOT: {{^ +[0-9]+:}}
39
40//--- a.inc
41puts("");
42

source code of compiler-rt/test/profile/Posix/gcov-file-change.cpp