1 // Test visualization of MC/DC constructs for branches in macro expansions.
3 // RUN: llvm-profdata merge %S/Inputs/mcdc-macro.proftext -o %t.profdata
4 // RUN: llvm-cov show --show-expansions --show-branches=count --show-mcdc %S/Inputs/mcdc-macro.o -instr-profile %t.profdata --compilation-dir=%S/Inputs | FileCheck %s
6 // CHECK: | | | Branch (2:11): [Folded - Ignored]
7 // CHECK: | | | Branch (3:11): [True: 1, False: 0]
8 // CHECK: | | | Branch (3:23): [True: 1, False: 0]
9 // CHECK: | Branch (9:7): [True: 1, False: 0]
10 // CHECK-NEXT: | Branch (9:22): [True: 0, False: 0]
11 // CHECK-NEXT: ------------------
12 // CHECK-NEXT: |---> MC/DC Decision Region (9:7) to (9:23)
14 // CHECK-NEXT: | Number of Conditions: 5
15 // CHECK-NEXT: | Condition C1 --> (9:7)
16 // CHECK-NEXT: | Condition C2 --> (9:22)
17 // CHECK-NEXT: | Condition C3 --> (2:11)
18 // CHECK-NEXT: | Condition C4 --> (3:11)
19 // CHECK-NEXT: | Condition C5 --> (3:23)
21 // CHECK-NEXT: | Executed MC/DC Test Vectors:
23 // CHECK-NEXT: | C1, C2, C3, C4, C5 Result
24 // CHECK-NEXT: | 1 { T, -, C, T, T = T }
26 // CHECK-NEXT: | C1-Pair: not covered
27 // CHECK-NEXT: | C2-Pair: not covered
28 // CHECK-NEXT: | C3-Pair: constant folded
29 // CHECK-NEXT: | C4-Pair: not covered
30 // CHECK-NEXT: | C5-Pair: not covered
31 // CHECK-NEXT: | MC/DC Coverage for Decision: 0.00%
33 // CHECK-NEXT: ------------------
35 // CHECK: | | | Branch (2:11): [Folded - Ignored]
36 // CHECK: | Branch (11:7): [True: 1, False: 0]
37 // CHECK-NEXT: ------------------
38 // CHECK-NEXT: |---> MC/DC Decision Region (11:7) to (11:13)
40 // CHECK-NEXT: | Number of Conditions: 2
41 // CHECK-NEXT: | Condition C1 --> (11:7)
42 // CHECK-NEXT: | Condition C2 --> (2:11)
44 // CHECK-NEXT: | Executed MC/DC Test Vectors:
46 // CHECK-NEXT: | C1, C2 Result
47 // CHECK-NEXT: | 1 { T, C = T }
49 // CHECK-NEXT: | C1-Pair: not covered
50 // CHECK-NEXT: | C2-Pair: constant folded
51 // CHECK-NEXT: | MC/DC Coverage for Decision: 0.00%
53 // CHECK-NEXT: ------------------
55 // CHECK: | | | Branch (1:11): [True: 1, False: 0]
56 // CHECK: | | | Branch (2:11): [Folded - Ignored]
57 // CHECK: | | | | | Branch (3:11): [True: 0, False: 0]
58 // CHECK: | | | | | Branch (3:23): [True: 0, False: 0]
59 // CHECK: | Branch (13:7): [True: 1, False: 0]
60 // CHECK-NEXT: | Branch (13:13): [True: 1, False: 0]
61 // CHECK-NEXT: ------------------
62 // CHECK-NEXT: |---> MC/DC Decision Region (13:7) to (13:32)
64 // CHECK-NEXT: | Number of Conditions: 6
65 // CHECK-NEXT: | Condition C1 --> (13:7)
66 // CHECK-NEXT: | Condition C2 --> (13:13)
67 // CHECK-NEXT: | Condition C3 --> (1:11)
68 // CHECK-NEXT: | Condition C4 --> (2:11)
69 // CHECK-NEXT: | Condition C5 --> (3:11)
70 // CHECK-NEXT: | Condition C6 --> (3:23)
72 // CHECK-NEXT: | Executed MC/DC Test Vectors:
74 // CHECK-NEXT: | C1, C2, C3, C4, C5, C6 Result
75 // CHECK-NEXT: | 1 { T, T, T, C, -, - = T }
77 // CHECK-NEXT: | C1-Pair: not covered
78 // CHECK-NEXT: | C2-Pair: not covered
79 // CHECK-NEXT: | C3-Pair: not covered
80 // CHECK-NEXT: | C4-Pair: constant folded
81 // CHECK-NEXT: | C5-Pair: not covered
82 // CHECK-NEXT: | C6-Pair: not covered
83 // CHECK-NEXT: | MC/DC Coverage for Decision: 0.00%
85 // CHECK-NEXT: ------------------
87 Instructions for regenerating the test:
89 cd %S/Inputs # Or copy mcdc-macro.c into the working directory
91 clang -fcoverage-mcdc -fprofile-instr-generate -fcoverage-compilation-dir=. \
92 -Os -mllvm -enable-name-compression=false \
93 -fcoverage-mapping mcdc-macro.c -c
95 # Instructions for generating proftext
96 clang -fprofile-instr-generate mcdc-macro.o
99 llvm-profdata merge --sparse -o default.profdata default.profraw
100 llvm-profdata merge --text -o mcdc-macro.proftext default.profdata