1 // Test visualization of MC/DC constructs for constant-folded condition masking.
3 // RUN: llvm-profdata merge %S/Inputs/mcdc-const.proftext -o %t.profdata
4 // RUN: llvm-cov show --show-branches=count --show-mcdc %S/Inputs/mcdc-const.o -instr-profile %t.profdata -path-equivalence=.,%S/Inputs | FileCheck %s -check-prefix=CHECKGENERALCASE
6 // CHECKGENERALCASE: ------------------
7 // CHECKGENERALCASE-NEXT: | Branch (12:8): [True: 4, False: 1]
8 // CHECKGENERALCASE-NEXT: | Branch (12:13): [Folded - Ignored]
9 // CHECKGENERALCASE-NEXT: | Branch (12:20): [Folded - Ignored]
10 // CHECKGENERALCASE-NEXT: | Branch (12:25): [True: 0, False: 0]
11 // CHECKGENERALCASE-NEXT: | Branch (12:31): [Folded - Ignored]
12 // CHECKGENERALCASE-NEXT: ------------------
13 // CHECKGENERALCASE-NEXT: |---> MC/DC Decision Region (12:7) to (12:32)
14 // CHECKGENERALCASE-NEXT: |
15 // CHECKGENERALCASE-NEXT: | Number of Conditions: 5
16 // CHECKGENERALCASE-NEXT: | Condition C1 --> (12:8)
17 // CHECKGENERALCASE-NEXT: | Condition C2 --> (12:13)
18 // CHECKGENERALCASE-NEXT: | Condition C3 --> (12:20)
19 // CHECKGENERALCASE-NEXT: | Condition C4 --> (12:25)
20 // CHECKGENERALCASE-NEXT: | Condition C5 --> (12:31)
21 // CHECKGENERALCASE-NEXT: |
22 // CHECKGENERALCASE-NEXT: | Executed MC/DC Test Vectors:
23 // CHECKGENERALCASE-NEXT: |
24 // CHECKGENERALCASE-NEXT: | C1, C2, C3, C4, C5 Result
25 // CHECKGENERALCASE-NEXT: | 1 { F, C, C, -, C = F }
26 // CHECKGENERALCASE-NEXT: | 2 { T, C, C, -, C = T }
27 // CHECKGENERALCASE-NEXT: |
28 // CHECKGENERALCASE-NEXT: | C1-Pair: covered: (1,2)
29 // CHECKGENERALCASE-NEXT: | C2-Pair: constant folded
30 // CHECKGENERALCASE-NEXT: | C3-Pair: constant folded
31 // CHECKGENERALCASE-NEXT: | C4-Pair: not covered
32 // CHECKGENERALCASE-NEXT: | C5-Pair: constant folded
33 // CHECKGENERALCASE-NEXT: | MC/DC Coverage for Decision: 50.00%
34 // CHECKGENERALCASE-NEXT: |
35 // CHECKGENERALCASE-NEXT: ------------------
37 // RUN: llvm-profdata merge %S/Inputs/mcdc-const-folding.proftext -o %t.profdata
38 // RUN: llvm-cov show --show-mcdc %S/Inputs/mcdc-const-folding.o -instr-profile %t.profdata -path-equivalence=.,%S/Inputs | FileCheck %s -check-prefix=CHECKFULLCASE
39 // RUN: llvm-cov report --show-mcdc-summary %S/Inputs/mcdc-const-folding.o -instr-profile %t.profdata -show-functions -path-equivalence=.,%S/Inputs %S/Inputs/mcdc-const-folding.cpp | FileCheck %s -check-prefix=REPORT
41 // CHECKFULLCASE: | 1 { C, - = F }
42 // CHECKFULLCASE: | C1-Pair: constant folded
43 // CHECKFULLCASE-NEXT: | C2-Pair: not covered
44 // CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
45 // CHECKFULLCASE: | 1 { F, C = F }
46 // CHECKFULLCASE-NEXT: | 2 { T, C = F }
47 // CHECKFULLCASE: | C1-Pair: not covered
48 // CHECKFULLCASE-NEXT: | C2-Pair: constant folded
49 // CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
50 // CHECKFULLCASE: | 1 { C, F = F }
51 // CHECKFULLCASE-NEXT: | 2 { C, T = T }
52 // CHECKFULLCASE: | C1-Pair: constant folded
53 // CHECKFULLCASE-NEXT: | C2-Pair: covered: (1,2)
54 // CHECKFULLCASE: | MC/DC Coverage for Decision: 100.00%
55 // CHECKFULLCASE: | 1 { F, C = F }
56 // CHECKFULLCASE-NEXT: | 2 { T, C = T }
57 // CHECKFULLCASE: | C1-Pair: covered: (1,2)
58 // CHECKFULLCASE-NEXT: | C2-Pair: constant folded
59 // CHECKFULLCASE: | MC/DC Coverage for Decision: 100.00%
60 // CHECKFULLCASE: | 1 { C, - = T }
61 // CHECKFULLCASE: | C1-Pair: constant folded
62 // CHECKFULLCASE-NEXT: | C2-Pair: not covered
63 // CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
64 // CHECKFULLCASE: | 1 { F, C = T }
65 // CHECKFULLCASE-NEXT: | 2 { T, C = T }
66 // CHECKFULLCASE: | C1-Pair: not covered
67 // CHECKFULLCASE-NEXT: | C2-Pair: constant folded
68 // CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
69 // CHECKFULLCASE: | 1 { C, F = F }
70 // CHECKFULLCASE-NEXT: | 2 { C, T = T }
71 // CHECKFULLCASE: | C1-Pair: constant folded
72 // CHECKFULLCASE-NEXT: | C2-Pair: covered: (1,2)
73 // CHECKFULLCASE: | MC/DC Coverage for Decision: 100.00%
74 // CHECKFULLCASE: | 1 { F, C = F }
75 // CHECKFULLCASE-NEXT: | 2 { T, C = T }
76 // CHECKFULLCASE: | C1-Pair: covered: (1,2)
77 // CHECKFULLCASE-NEXT: | C2-Pair: constant folded
78 // CHECKFULLCASE: | MC/DC Coverage for Decision: 100.00%
79 // CHECKFULLCASE: | 1 { C, -, - = F }
80 // CHECKFULLCASE: | C1-Pair: constant folded
81 // CHECKFULLCASE-NEXT: | C2-Pair: not covered
82 // CHECKFULLCASE-NEXT: | C3-Pair: not covered
83 // CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
84 // CHECKFULLCASE: | 1 { F, C, - = F }
85 // CHECKFULLCASE-NEXT: | 2 { T, C, - = F }
86 // CHECKFULLCASE: | C1-Pair: not covered
87 // CHECKFULLCASE-NEXT: | C2-Pair: constant folded
88 // CHECKFULLCASE-NEXT: | C3-Pair: not covered
89 // CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
90 // CHECKFULLCASE: | 1 { C, F, - = F }
91 // CHECKFULLCASE-NEXT: | 2 { C, T, F = F }
92 // CHECKFULLCASE-NEXT: | 3 { C, T, T = T }
93 // CHECKFULLCASE: | C1-Pair: constant folded
94 // CHECKFULLCASE-NEXT: | C2-Pair: covered: (1,3)
95 // CHECKFULLCASE-NEXT: | C3-Pair: covered: (2,3)
96 // CHECKFULLCASE: | MC/DC Coverage for Decision: 100.00%
97 // CHECKFULLCASE: | 1 { F, C, - = F }
98 // CHECKFULLCASE-NEXT: | 2 { T, C, F = F }
99 // CHECKFULLCASE-NEXT: | 3 { T, C, T = T }
100 // CHECKFULLCASE: | C1-Pair: covered: (1,3)
101 // CHECKFULLCASE-NEXT: | C2-Pair: constant folded
102 // CHECKFULLCASE-NEXT: | C3-Pair: covered: (2,3)
103 // CHECKFULLCASE: | MC/DC Coverage for Decision: 100.00%
104 // CHECKFULLCASE: | 1 { C, -, - = T }
105 // CHECKFULLCASE: | C1-Pair: constant folded
106 // CHECKFULLCASE-NEXT: | C2-Pair: not covered
107 // CHECKFULLCASE-NEXT: | C3-Pair: not covered
108 // CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
109 // CHECKFULLCASE: | 1 { F, C, - = T }
110 // CHECKFULLCASE-NEXT: | 2 { T, C, - = T }
111 // CHECKFULLCASE: | C1-Pair: not covered
112 // CHECKFULLCASE-NEXT: | C2-Pair: constant folded
113 // CHECKFULLCASE-NEXT: | C3-Pair: not covered
114 // CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
115 // CHECKFULLCASE: | 1 { C, F, T = T }
116 // CHECKFULLCASE-NEXT: | 2 { C, T, - = T }
117 // CHECKFULLCASE: | C1-Pair: constant folded
118 // CHECKFULLCASE-NEXT: | C2-Pair: not covered
119 // CHECKFULLCASE-NEXT: | C3-Pair: not covered
120 // CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
121 // CHECKFULLCASE: | 1 { F, C, T = T }
122 // CHECKFULLCASE-NEXT: | 2 { T, C, - = T }
123 // CHECKFULLCASE: | C1-Pair: not covered
124 // CHECKFULLCASE-NEXT: | C2-Pair: constant folded
125 // CHECKFULLCASE-NEXT: | C3-Pair: not covered
126 // CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
127 // CHECKFULLCASE: | 1 { F, -, C = F }
128 // CHECKFULLCASE-NEXT: | 2 { T, F, C = F }
129 // CHECKFULLCASE-NEXT: | 3 { T, T, C = F }
130 // CHECKFULLCASE: | C1-Pair: not covered
131 // CHECKFULLCASE-NEXT: | C2-Pair: not covered
132 // CHECKFULLCASE-NEXT: | C3-Pair: constant folded
133 // CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
134 // CHECKFULLCASE: | 1 { F, C, - = F }
135 // CHECKFULLCASE-NEXT: | 2 { T, C, - = F }
136 // CHECKFULLCASE: | C1-Pair: not covered
137 // CHECKFULLCASE-NEXT: | C2-Pair: constant folded
138 // CHECKFULLCASE-NEXT: | C3-Pair: not covered
139 // CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
140 // CHECKFULLCASE: | 1 { F, -, C = F }
141 // CHECKFULLCASE-NEXT: | 2 { T, F, C = F }
142 // CHECKFULLCASE-NEXT: | 3 { T, T, C = T }
143 // CHECKFULLCASE: | C1-Pair: covered: (1,3)
144 // CHECKFULLCASE-NEXT: | C2-Pair: covered: (2,3)
145 // CHECKFULLCASE-NEXT: | C3-Pair: constant folded
146 // CHECKFULLCASE: | MC/DC Coverage for Decision: 100.00%
147 // CHECKFULLCASE: | 1 { F, C, - = F }
148 // CHECKFULLCASE-NEXT: | 2 { T, C, F = F }
149 // CHECKFULLCASE-NEXT: | 3 { T, C, T = T }
150 // CHECKFULLCASE: | C1-Pair: covered: (1,3)
151 // CHECKFULLCASE-NEXT: | C2-Pair: constant folded
152 // CHECKFULLCASE-NEXT: | C3-Pair: covered: (2,3)
153 // CHECKFULLCASE: | MC/DC Coverage for Decision: 100.00%
154 // CHECKFULLCASE: | 1 { F, T, C = T }
155 // CHECKFULLCASE-NEXT: | 2 { T, -, C = T }
156 // CHECKFULLCASE: | C1-Pair: not covered
157 // CHECKFULLCASE-NEXT: | C2-Pair: not covered
158 // CHECKFULLCASE-NEXT: | C3-Pair: constant folded
159 // CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
160 // CHECKFULLCASE: | 1 { F, C, - = T }
161 // CHECKFULLCASE-NEXT: | 2 { T, C, - = T }
162 // CHECKFULLCASE: | C1-Pair: not covered
163 // CHECKFULLCASE-NEXT: | C2-Pair: constant folded
164 // CHECKFULLCASE-NEXT: | C3-Pair: not covered
165 // CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
166 // CHECKFULLCASE: | 1 { F, T, C = T }
167 // CHECKFULLCASE-NEXT: | 2 { T, -, C = T }
168 // CHECKFULLCASE: | C1-Pair: not covered
169 // CHECKFULLCASE-NEXT: | C2-Pair: not covered
170 // CHECKFULLCASE-NEXT: | C3-Pair: constant folded
171 // CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
172 // CHECKFULLCASE: | 1 { F, C, T = T }
173 // CHECKFULLCASE-NEXT: | 2 { T, C, - = T }
174 // CHECKFULLCASE: | C1-Pair: not covered
175 // CHECKFULLCASE-NEXT: | C2-Pair: constant folded
176 // CHECKFULLCASE-NEXT: | C3-Pair: not covered
177 // CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
179 // REPORT: _Z5case0b {{.*}} 1 1 0.00%
180 // REPORT-NEXT: _Z5case1b {{.*}} 1 1 0.00%
181 // REPORT-NEXT: _Z5case2b {{.*}} 1 0 100.00%
182 // REPORT-NEXT: _Z5case3b {{.*}} 1 0 100.00%
183 // REPORT-NEXT: _Z5case4b {{.*}} 1 1 0.00%
184 // REPORT-NEXT: _Z5case5b {{.*}} 1 1 0.00%
185 // REPORT-NEXT: _Z5case6b {{.*}} 1 0 100.00%
186 // REPORT-NEXT: _Z5case7b {{.*}} 1 0 100.00%
187 // REPORT-NEXT: _Z5case8bb {{.*}} 2 2 0.00%
188 // REPORT-NEXT: _Z5case9bb {{.*}} 2 2 0.00%
189 // REPORT-NEXT: _Z5caseabb {{.*}} 2 0 100.00%
190 // REPORT-NEXT: _Z5casebbb {{.*}} 2 0 100.00%
191 // REPORT-NEXT: _Z5casecbb {{.*}} 2 2 0.00%
192 // REPORT-NEXT: _Z5casedbb {{.*}} 2 2 0.00%
193 // REPORT-NEXT: _Z5caseebb {{.*}} 2 2 0.00%
194 // REPORT-NEXT: _Z5casefbb {{.*}} 2 2 0.00%
195 // REPORT-NEXT: _Z5casegbb {{.*}} 2 2 0.00%
196 // REPORT-NEXT: _Z5casehbb {{.*}} 2 2 0.00%
197 // REPORT-NEXT: _Z5caseibb {{.*}} 2 0 100.00%
198 // REPORT-NEXT: _Z5casejbb {{.*}} 2 0 100.00%
199 // REPORT-NEXT: _Z5casekbb {{.*}} 2 2 0.00%
200 // REPORT-NEXT: _Z5caselbb {{.*}} 2 2 0.00%
201 // REPORT-NEXT: _Z5casembb {{.*}} 2 2 0.00%
202 // REPORT-NEXT: _Z5casenbb {{.*}} 2 2 0.00%
203 // REPORT: TOTAL {{.*}} 40 28 30.00%
205 Instructions for regenerating the test:
207 cd %S/Inputs # Or copy files into the working directory
210 -fcoverage-compilation-dir=. -mllvm -enable-name-compression=false \
211 -fcoverage-mcdc -fprofile-instr-generate -fcoverage-mapping \
212 mcdc-const.cpp mcdc-const-folding.cpp
214 # Instructions for regenerating proftext
216 for x in mcdc-const mcdc-const-folding; do (
217 clang++ -fprofile-instr-generate $x.o -o $x
218 find -name '*.profraw' | xargs rm -f
219 export LLVM_PROFILE_FILE=$x-%p.profraw
221 if [ "$x" = "mcdc-const-folding" ]; then
226 llvm-profdata merge --sparse -o $x.profdata $(find -name '*.profraw')
227 llvm-profdata merge --text -o $x.proftext $x.profdata