[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / llvm / test / tools / llvm-cov / branch-logical-mixed.cpp
blobf5f787112446774ce1dfd1a9bdf7ef9cdf02de9a
1 // RUN: llvm-profdata merge %S/Inputs/branch-logical-mixed.proftext -o %t.profdata
2 // RUN: llvm-cov show --show-branches=count %S/Inputs/branch-logical-mixed.o32l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
3 // RUN: llvm-cov report --show-branch-summary %S/Inputs/branch-logical-mixed.o32l -instr-profile %t.profdata -show-functions -path-equivalence=/tmp,%S %s | FileCheck %s -check-prefix=REPORT
5 #include <stdio.h>
6 #include <stdlib.h>
8 void func(int a, int b) {
9 bool b0 = a <= b;
10 bool b1 = a == b;
11 bool b2 = a >= b;
12 bool b3 = a < b;
13 bool b4 = a > b;
14 bool b5 = a != b;
16 bool c = b0 && // CHECK: Branch ([[@LINE]]:12): [True: 3, False: 1]
17 b1 && // CHECK: Branch ([[@LINE]]:12): [True: 2, False: 1]
18 b2 && // CHECK: Branch ([[@LINE]]:12): [True: 2, False: 0]
19 b3 && // CHECK: Branch ([[@LINE]]:12): [True: 0, False: 2]
20 b4 && // CHECK: Branch ([[@LINE]]:12): [True: 0, False: 0]
21 b5; // CHECK: Branch ([[@LINE]]:12): [True: 0, False: 0]
23 bool d = b0 || // CHECK: Branch ([[@LINE]]:12): [True: 3, False: 1]
24 b1 || // CHECK: Branch ([[@LINE]]:12): [True: 0, False: 1]
25 b2 || // CHECK: Branch ([[@LINE]]:12): [True: 1, False: 0]
26 b3 || // CHECK: Branch ([[@LINE]]:12): [True: 0, False: 0]
27 b4 || // CHECK: Branch ([[@LINE]]:12): [True: 0, False: 0]
28 b5; // CHECK: Branch ([[@LINE]]:12): [True: 0, False: 0]
30 bool e = (b0 && // CHECK: Branch ([[@LINE]]:13): [True: 3, False: 1]
31 b5) || // CHECK: Branch ([[@LINE]]:13): [True: 1, False: 2]
32 (b1 && // CHECK: Branch ([[@LINE]]:13): [True: 2, False: 1]
33 b4) || // CHECK: Branch ([[@LINE]]:13): [True: 0, False: 2]
34 (b2 && // CHECK: Branch ([[@LINE]]:13): [True: 3, False: 0]
35 b3) || // CHECK: Branch ([[@LINE]]:13): [True: 0, False: 3]
36 (b3 && // CHECK: Branch ([[@LINE]]:13): [True: 0, False: 3]
37 b2) || // CHECK: Branch ([[@LINE]]:13): [True: 0, False: 0]
38 (b4 && // CHECK: Branch ([[@LINE]]:13): [True: 1, False: 2]
39 b1) || // CHECK: Branch ([[@LINE]]:13): [True: 0, False: 1]
40 (b5 && // CHECK: Branch ([[@LINE]]:13): [True: 1, False: 2]
41 b0); // CHECK: Branch ([[@LINE]]:13): [True: 0, False: 1]
43 bool f = (b0 || // CHECK: Branch ([[@LINE]]:13): [True: 3, False: 1]
44 b5) && // CHECK: Branch ([[@LINE]]:13): [True: 1, False: 0]
45 (b1 || // CHECK: Branch ([[@LINE]]:13): [True: 2, False: 2]
46 b4) && // CHECK: Branch ([[@LINE]]:13): [True: 1, False: 1]
47 (b2 || // CHECK: Branch ([[@LINE]]:13): [True: 3, False: 0]
48 b3) && // CHECK: Branch ([[@LINE]]:13): [True: 0, False: 0]
49 (b3 || // CHECK: Branch ([[@LINE]]:13): [True: 0, False: 3]
50 b2) && // CHECK: Branch ([[@LINE]]:13): [True: 3, False: 0]
51 (b4 || // CHECK: Branch ([[@LINE]]:13): [True: 1, False: 2]
52 b1) && // CHECK: Branch ([[@LINE]]:13): [True: 2, False: 0]
53 (b5 || // CHECK: Branch ([[@LINE]]:13): [True: 1, False: 2]
54 b0); // CHECK: Branch ([[@LINE]]:13): [True: 2, False: 0]
56 if (c) // CHECK: Branch ([[@LINE]]:7): [True: 0, False: 4]
57 printf("case0\n");
58 else
59 printf("case1\n");
61 if (d) // CHECK: Branch ([[@LINE]]:7): [True: 4, False: 0]
62 printf("case2\n");
63 else
64 printf("case3\n");
66 if (e) // CHECK: Branch ([[@LINE]]:7): [True: 1, False: 3]
67 printf("case4\n");
68 else
69 printf("case5\n");
71 if (f) // CHECK: Branch ([[@LINE]]:7): [True: 3, False: 1]
72 printf("case6\n");
73 else
74 printf("case7\n");
77 extern "C" { extern void __llvm_profile_write_file(void); }
78 int main(int argc, char *argv[])
80 func(atoi(argv[1]), atoi(argv[2]));
81 __llvm_profile_write_file();
82 return 0;
85 // REPORT: Name Regions Miss Cover Lines Miss Cover Branches Miss Cover
86 // REPORT-NEXT: ---
87 // REPORT-NEXT: _Z4funcii 77 9 88.31% 68 3 95.59% 80 32 60.00%
88 // REPORT-NEXT: main 1 0 100.00% 5 0 100.00% 0 0 0.00%
89 // REPORT-NEXT: ---
90 // REPORT-NEXT: TOTAL 78 9 88.46% 73 3 95.89% 80 32 60.00%