1 // 1) Compile shared code into different object files and into an executable.
3 // RUN: %clangxx_profgen -fcoverage-mapping %s -c -o %t.v1.o -D_VERSION_1
4 // RUN: %clangxx_profgen -fcoverage-mapping %s -c -o %t.v2.o -D_VERSION_2
5 // RUN: %clangxx_profgen -fcoverage-mapping %t.v1.o %t.v2.o -o %t.exe
7 // 2) Collect profile data.
9 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t.exe
10 // RUN: llvm-profdata merge %t.profraw -o %t.profdata
12 // 3) Generate coverage reports from the different object files and the exe.
14 // RUN: llvm-cov show %t.v1.o -instr-profile=%t.profdata | FileCheck %s -check-prefixes=V1,V1-ONLY
15 // RUN: llvm-cov show %t.v2.o -instr-profile=%t.profdata | FileCheck %s -check-prefixes=V2,V2-ONLY
16 // RUN: llvm-cov show %t.v1.o -object %t.v2.o -instr-profile=%t.profdata | FileCheck %s -check-prefixes=V1,V2
17 // RUN: llvm-cov show %t.exe -instr-profile=%t.profdata | FileCheck %s -check-prefixes=V1,V2
19 // 4) Verify that coverage reporting on the aggregate coverage mapping shows
20 // hits for all code. (We used to arbitrarily pick a mapping from one binary
21 // and prefer it over others.) When only limited coverage information is
22 // available (just from one binary), don't try to guess any region counts.
25 A() {} // V1: [[@LINE]]{{ *}}|{{ *}}1
26 // V1-ONLY: [[@LINE+1]]{{ *}}|{{ *}}|
27 A(int) {} // V2-ONLY: [[@LINE-2]]{{ *}}|{{ *}}|
28 // V2: [[@LINE-1]]{{ *}}|{{ *}}1
36 A x; // V1: [[@LINE]]{{ *}}|{{ *}}1
40 foo(); // V1: [[@LINE]]{{ *}}|{{ *}}1
50 A x{0}; // V2: [[@LINE]]{{ *}}|{{ *}}1