Skip to content

Commit 6be96e3

Browse files
committed
Auto merge of rust-lang#127234 - ZhuUx:inlined-expr, r=davidtwco,Zalathar
[Coverage][MCDC] Group mcdc tests and fix panic when generating mcdc code for inlined expressions. ### Changes 1. Group all mcdc tests to one directory. 2. Since mcdc instruments different mappings for boolean expressions with normal branch coverage as rust-lang#125766 introduces, it would be better also trace branch coverage results in mcdc tests. 3. So far rustc does not call `CoverageInfoBuilderMethods::init_coverage` for inlined functions. As a result, it could panic if it tries to instrument mcdc statements for inlined functions due to uninitialized cond bitmaps. We can reproduce this issue by current nightly rustc and [the test](https://github.com/rust-lang/rust/pull/127234/files#diff-c81af6bf4869aa42f5c7334e3e86344475de362f673f54ce439ec75fcb5ac3e5) with flag `--release`. This patch fixes it.
2 parents 9dcaa7f + 83fa6b7 commit 6be96e3

13 files changed

+181
-24
lines changed

compiler/rustc_mir_transform/src/inline.rs

+6
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ struct CallSite<'tcx> {
4141

4242
impl<'tcx> MirPass<'tcx> for Inline {
4343
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
44+
// FIXME(#127234): Coverage instrumentation currently doesn't handle inlined
45+
// MIR correctly when Modified Condition/Decision Coverage is enabled.
46+
if sess.instrument_coverage_mcdc() {
47+
return false;
48+
}
49+
4450
if let Some(enabled) = sess.opts.unstable_opts.inline_mir {
4551
return enabled;
4652
}

tests/coverage/mcdc_if.cov-map tests/coverage/mcdc/if.cov-map

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Function name: mcdc_if::mcdc_check_a
1+
Function name: if::mcdc_check_a
22
Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 0f, 01, 01, 09, 28, 00, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02]
33
Number of files: 1
44
- file 0 => global file 1
@@ -23,7 +23,7 @@ Number of file 0 mappings: 8
2323
- Code(Expression(2, Add)) at (prev + 3, 1) to (start + 0, 2)
2424
= (c3 + (c2 + (c0 - c1)))
2525

26-
Function name: mcdc_if::mcdc_check_b
26+
Function name: if::mcdc_check_b
2727
Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 17, 01, 01, 09, 28, 00, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02]
2828
Number of files: 1
2929
- file 0 => global file 1
@@ -48,7 +48,7 @@ Number of file 0 mappings: 8
4848
- Code(Expression(2, Add)) at (prev + 3, 1) to (start + 0, 2)
4949
= (c3 + (c2 + (c0 - c1)))
5050

51-
Function name: mcdc_if::mcdc_check_both
51+
Function name: if::mcdc_check_both
5252
Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 1f, 01, 01, 09, 28, 00, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02]
5353
Number of files: 1
5454
- file 0 => global file 1
@@ -73,7 +73,7 @@ Number of file 0 mappings: 8
7373
- Code(Expression(2, Add)) at (prev + 3, 1) to (start + 0, 2)
7474
= (c3 + (c2 + (c0 - c1)))
7575

76-
Function name: mcdc_if::mcdc_check_neither
76+
Function name: if::mcdc_check_neither
7777
Raw bytes (64): 0x[01, 01, 04, 01, 05, 09, 02, 0d, 0f, 09, 02, 08, 01, 07, 01, 01, 09, 28, 00, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0d, 00, 0e, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 0e, 0d, 00, 0f, 02, 06, 0f, 02, 0c, 02, 06, 0b, 03, 01, 00, 02]
7878
Number of files: 1
7979
- file 0 => global file 1
@@ -98,7 +98,7 @@ Number of file 0 mappings: 8
9898
- Code(Expression(2, Add)) at (prev + 3, 1) to (start + 0, 2)
9999
= (c3 + (c2 + (c0 - c1)))
100100

101-
Function name: mcdc_if::mcdc_check_not_tree_decision
101+
Function name: if::mcdc_check_not_tree_decision
102102
Raw bytes (87): 0x[01, 01, 08, 01, 05, 02, 09, 05, 09, 0d, 1e, 02, 09, 11, 1b, 0d, 1e, 02, 09, 0a, 01, 31, 01, 03, 0a, 28, 00, 03, 03, 08, 00, 15, 30, 05, 02, 01, 02, 03, 00, 09, 00, 0a, 02, 00, 0e, 00, 0f, 30, 09, 1e, 03, 02, 00, 00, 0e, 00, 0f, 0b, 00, 14, 00, 15, 30, 11, 0d, 02, 00, 00, 00, 14, 00, 15, 11, 00, 16, 02, 06, 1b, 02, 0c, 02, 06, 17, 03, 01, 00, 02]
103103
Number of files: 1
104104
- file 0 => global file 1
@@ -133,7 +133,7 @@ Number of file 0 mappings: 10
133133
- Code(Expression(5, Add)) at (prev + 3, 1) to (start + 0, 2)
134134
= (c4 + (c3 + ((c0 - c1) - c2)))
135135

136-
Function name: mcdc_if::mcdc_check_tree_decision
136+
Function name: if::mcdc_check_tree_decision
137137
Raw bytes (87): 0x[01, 01, 08, 01, 05, 05, 0d, 05, 0d, 0d, 11, 09, 02, 1b, 1f, 0d, 11, 09, 02, 0a, 01, 27, 01, 03, 09, 28, 00, 03, 03, 08, 00, 15, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 05, 00, 0e, 00, 0f, 30, 0d, 0a, 02, 00, 03, 00, 0e, 00, 0f, 0a, 00, 13, 00, 14, 30, 11, 09, 03, 00, 00, 00, 13, 00, 14, 1b, 00, 16, 02, 06, 1f, 02, 0c, 02, 06, 17, 03, 01, 00, 02]
138138
Number of files: 1
139139
- file 0 => global file 1
@@ -168,7 +168,7 @@ Number of file 0 mappings: 10
168168
- Code(Expression(5, Add)) at (prev + 3, 1) to (start + 0, 2)
169169
= ((c3 + c4) + (c2 + (c0 - c1)))
170170

171-
Function name: mcdc_if::mcdc_nested_if
171+
Function name: if::mcdc_nested_if
172172
Raw bytes (124): 0x[01, 01, 0d, 01, 05, 02, 09, 05, 09, 1b, 15, 05, 09, 1b, 15, 05, 09, 11, 15, 02, 09, 2b, 32, 0d, 2f, 11, 15, 02, 09, 0e, 01, 3b, 01, 01, 09, 28, 00, 02, 01, 08, 00, 0e, 30, 05, 02, 01, 00, 02, 00, 08, 00, 09, 02, 00, 0d, 00, 0e, 30, 09, 32, 02, 00, 00, 00, 0d, 00, 0e, 1b, 01, 09, 01, 0d, 28, 01, 02, 01, 0c, 00, 12, 30, 16, 15, 01, 02, 00, 00, 0c, 00, 0d, 16, 00, 11, 00, 12, 30, 0d, 11, 02, 00, 00, 00, 11, 00, 12, 0d, 00, 13, 02, 0a, 2f, 02, 0a, 00, 0b, 32, 01, 0c, 02, 06, 27, 03, 01, 00, 02]
173173
Number of files: 1
174174
- file 0 => global file 1

tests/coverage/mcdc_if.coverage tests/coverage/mcdc/if.coverage

+27-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
LL| |//@ edition: 2021
33
LL| |//@ min-llvm-version: 18
44
LL| |//@ compile-flags: -Zcoverage-options=mcdc
5-
LL| |//@ llvm-cov-flags: --show-mcdc
5+
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc
66
LL| |
77
LL| 2|fn mcdc_check_neither(a: bool, b: bool) {
88
LL| 2| if a && b {
99
^0
1010
------------------
11+
| Branch (LL:8): [True: 0, False: 2]
12+
| Branch (LL:13): [True: 0, False: 0]
13+
------------------
1114
|---> MC/DC Decision Region (LL:8) to (LL:14)
1215
|
1316
| Number of Conditions: 2
@@ -34,6 +37,9 @@
3437
LL| 2| if a && b {
3538
^1
3639
------------------
40+
| Branch (LL:8): [True: 1, False: 1]
41+
| Branch (LL:13): [True: 1, False: 0]
42+
------------------
3743
|---> MC/DC Decision Region (LL:8) to (LL:14)
3844
|
3945
| Number of Conditions: 2
@@ -60,6 +66,9 @@
6066
LL| 2|fn mcdc_check_b(a: bool, b: bool) {
6167
LL| 2| if a && b {
6268
------------------
69+
| Branch (LL:8): [True: 2, False: 0]
70+
| Branch (LL:13): [True: 1, False: 1]
71+
------------------
6372
|---> MC/DC Decision Region (LL:8) to (LL:14)
6473
|
6574
| Number of Conditions: 2
@@ -87,6 +96,9 @@
8796
LL| 3| if a && b {
8897
^2
8998
------------------
99+
| Branch (LL:8): [True: 2, False: 1]
100+
| Branch (LL:13): [True: 1, False: 1]
101+
------------------
90102
|---> MC/DC Decision Region (LL:8) to (LL:14)
91103
|
92104
| Number of Conditions: 2
@@ -117,6 +129,10 @@
117129
LL| 4| if a && (b || c) {
118130
^3 ^2
119131
------------------
132+
| Branch (LL:8): [True: 3, False: 1]
133+
| Branch (LL:14): [True: 1, False: 2]
134+
| Branch (LL:19): [True: 1, False: 1]
135+
------------------
120136
|---> MC/DC Decision Region (LL:8) to (LL:21)
121137
|
122138
| Number of Conditions: 3
@@ -150,6 +166,10 @@
150166
LL| 4| if (a || b) && c {
151167
^1
152168
------------------
169+
| Branch (LL:9): [True: 3, False: 1]
170+
| Branch (LL:14): [True: 1, False: 0]
171+
| Branch (LL:20): [True: 2, False: 2]
172+
------------------
153173
|---> MC/DC Decision Region (LL:8) to (LL:21)
154174
|
155175
| Number of Conditions: 3
@@ -180,6 +200,9 @@
180200
LL| 3| if a || b {
181201
^0
182202
------------------
203+
| Branch (LL:8): [True: 3, False: 0]
204+
| Branch (LL:13): [True: 0, False: 0]
205+
------------------
183206
|---> MC/DC Decision Region (LL:8) to (LL:14)
184207
|
185208
| Number of Conditions: 2
@@ -200,6 +223,9 @@
200223
LL| 3| if b && c {
201224
^2
202225
------------------
226+
| Branch (LL:12): [True: 2, False: 1]
227+
| Branch (LL:17): [True: 1, False: 1]
228+
------------------
203229
|---> MC/DC Decision Region (LL:12) to (LL:18)
204230
|
205231
| Number of Conditions: 2

tests/coverage/mcdc_if.rs tests/coverage/mcdc/if.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//@ edition: 2021
33
//@ min-llvm-version: 18
44
//@ compile-flags: -Zcoverage-options=mcdc
5-
//@ llvm-cov-flags: --show-mcdc
5+
//@ llvm-cov-flags: --show-branches=count --show-mcdc
66

77
fn mcdc_check_neither(a: bool, b: bool) {
88
if a && b {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Function name: inlined_expressions::inlined_instance
2+
Raw bytes (52): 0x[01, 01, 03, 01, 05, 0b, 02, 09, 0d, 06, 01, 08, 01, 01, 06, 28, 00, 02, 01, 05, 00, 0b, 30, 05, 02, 01, 02, 00, 00, 05, 00, 06, 05, 00, 0a, 00, 0b, 30, 09, 0d, 02, 00, 00, 00, 0a, 00, 0b, 07, 01, 01, 00, 02]
3+
Number of files: 1
4+
- file 0 => global file 1
5+
Number of expressions: 3
6+
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
7+
- expression 1 operands: lhs = Expression(2, Add), rhs = Expression(0, Sub)
8+
- expression 2 operands: lhs = Counter(2), rhs = Counter(3)
9+
Number of file 0 mappings: 6
10+
- Code(Counter(0)) at (prev + 8, 1) to (start + 1, 6)
11+
- MCDCDecision { bitmap_idx: 0, conditions_num: 2 } at (prev + 1, 5) to (start + 0, 11)
12+
- MCDCBranch { true: Counter(1), false: Expression(0, Sub), condition_id: 1, true_next_id: 2, false_next_id: 0 } at (prev + 0, 5) to (start + 0, 6)
13+
true = c1
14+
false = (c0 - c1)
15+
- Code(Counter(1)) at (prev + 0, 10) to (start + 0, 11)
16+
- MCDCBranch { true: Counter(2), false: Counter(3), condition_id: 2, true_next_id: 0, false_next_id: 0 } at (prev + 0, 10) to (start + 0, 11)
17+
true = c2
18+
false = c3
19+
- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2)
20+
= ((c2 + c3) + (c0 - c1))
21+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
LL| |#![feature(coverage_attribute)]
2+
LL| |//@ edition: 2021
3+
LL| |//@ min-llvm-version: 18
4+
LL| |//@ compile-flags: -Zcoverage-options=mcdc -Copt-level=z -Cllvm-args=--inline-threshold=0
5+
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc
6+
LL| |
7+
LL| |#[inline(always)]
8+
LL| 3|fn inlined_instance(a: bool, b: bool) -> bool {
9+
LL| 3| a && b
10+
^2
11+
------------------
12+
| Branch (LL:5): [True: 2, False: 1]
13+
| Branch (LL:10): [True: 1, False: 1]
14+
------------------
15+
|---> MC/DC Decision Region (LL:5) to (LL:11)
16+
|
17+
| Number of Conditions: 2
18+
| Condition C1 --> (LL:5)
19+
| Condition C2 --> (LL:10)
20+
|
21+
| Executed MC/DC Test Vectors:
22+
|
23+
| C1, C2 Result
24+
| 1 { F, - = F }
25+
| 2 { T, F = F }
26+
| 3 { T, T = T }
27+
|
28+
| C1-Pair: covered: (1,3)
29+
| C2-Pair: covered: (2,3)
30+
| MC/DC Coverage for Decision: 100.00%
31+
|
32+
------------------
33+
LL| 3|}
34+
LL| |
35+
LL| |#[coverage(off)]
36+
LL| |fn main() {
37+
LL| | let _ = inlined_instance(true, false);
38+
LL| | let _ = inlined_instance(false, true);
39+
LL| | let _ = inlined_instance(true, true);
40+
LL| |}
41+
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#![feature(coverage_attribute)]
2+
//@ edition: 2021
3+
//@ min-llvm-version: 18
4+
//@ compile-flags: -Zcoverage-options=mcdc -Copt-level=z -Cllvm-args=--inline-threshold=0
5+
//@ llvm-cov-flags: --show-branches=count --show-mcdc
6+
7+
#[inline(always)]
8+
fn inlined_instance(a: bool, b: bool) -> bool {
9+
a && b
10+
}
11+
12+
#[coverage(off)]
13+
fn main() {
14+
let _ = inlined_instance(true, false);
15+
let _ = inlined_instance(false, true);
16+
let _ = inlined_instance(true, true);
17+
}

tests/coverage/mcdc_nested_if.cov-map tests/coverage/mcdc/nested_if.cov-map

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Function name: mcdc_nested_if::doubly_nested_if_in_condition
1+
Function name: nested_if::doubly_nested_if_in_condition
22
Raw bytes (168): 0x[01, 01, 0e, 01, 05, 05, 11, 05, 11, 26, 19, 05, 11, 19, 1d, 19, 1d, 1d, 22, 26, 19, 05, 11, 11, 15, 09, 02, 0d, 37, 09, 02, 14, 01, 0f, 01, 01, 09, 28, 02, 02, 01, 08, 00, 4e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 4e, 05, 00, 10, 00, 11, 28, 01, 02, 00, 10, 00, 36, 30, 11, 26, 01, 00, 02, 00, 10, 00, 11, 30, 15, 21, 02, 00, 00, 00, 15, 00, 36, 26, 00, 18, 00, 19, 28, 00, 02, 00, 18, 00, 1e, 30, 19, 22, 01, 02, 00, 00, 18, 00, 19, 19, 00, 1d, 00, 1e, 30, 1a, 1d, 02, 00, 00, 00, 1d, 00, 1e, 1a, 00, 21, 00, 25, 1f, 00, 2f, 00, 34, 2b, 00, 39, 00, 3e, 21, 00, 48, 00, 4c, 0d, 00, 4f, 02, 06, 37, 02, 0c, 02, 06, 33, 03, 01, 00, 02]
33
Number of files: 1
44
- file 0 => global file 1
@@ -57,7 +57,7 @@ Number of file 0 mappings: 20
5757
- Code(Expression(12, Add)) at (prev + 3, 1) to (start + 0, 2)
5858
= (c3 + (c2 + (c0 - c1)))
5959

60-
Function name: mcdc_nested_if::nested_if_in_condition
60+
Function name: nested_if::nested_if_in_condition
6161
Raw bytes (120): 0x[01, 01, 0b, 01, 05, 05, 11, 05, 11, 1e, 15, 05, 11, 11, 15, 1e, 15, 05, 11, 09, 02, 0d, 2b, 09, 02, 0e, 01, 07, 01, 01, 09, 28, 01, 02, 01, 08, 00, 2e, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 2e, 05, 00, 10, 00, 11, 28, 00, 02, 00, 10, 00, 16, 30, 11, 1e, 01, 00, 02, 00, 10, 00, 11, 1e, 00, 15, 00, 16, 30, 15, 1a, 02, 00, 00, 00, 15, 00, 16, 17, 00, 19, 00, 1d, 1a, 00, 27, 00, 2c, 0d, 00, 2f, 02, 06, 2b, 02, 0c, 02, 06, 27, 03, 01, 00, 02]
6262
Number of files: 1
6363
- file 0 => global file 1
@@ -102,7 +102,7 @@ Number of file 0 mappings: 14
102102
- Code(Expression(9, Add)) at (prev + 3, 1) to (start + 0, 2)
103103
= (c3 + (c2 + (c0 - c1)))
104104

105-
Function name: mcdc_nested_if::nested_in_then_block_in_condition
105+
Function name: nested_if::nested_in_then_block_in_condition
106106
Raw bytes (176): 0x[01, 01, 12, 01, 05, 05, 11, 05, 11, 3a, 15, 05, 11, 11, 15, 33, 19, 11, 15, 19, 1d, 19, 1d, 1d, 2e, 33, 19, 11, 15, 3a, 15, 05, 11, 09, 02, 0d, 47, 09, 02, 14, 01, 22, 01, 01, 09, 28, 02, 02, 01, 08, 00, 4b, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 4b, 05, 00, 10, 00, 11, 28, 00, 02, 00, 10, 00, 16, 30, 11, 3a, 01, 00, 02, 00, 10, 00, 11, 3a, 00, 15, 00, 16, 30, 15, 36, 02, 00, 00, 00, 15, 00, 16, 33, 00, 1c, 00, 1d, 28, 01, 02, 00, 1c, 00, 22, 30, 19, 2e, 01, 02, 00, 00, 1c, 00, 1d, 19, 00, 21, 00, 22, 30, 26, 1d, 02, 00, 00, 00, 21, 00, 22, 26, 00, 25, 00, 29, 2b, 00, 33, 00, 38, 36, 00, 44, 00, 49, 0d, 00, 4c, 02, 06, 47, 02, 0c, 02, 06, 43, 03, 01, 00, 02]
107107
Number of files: 1
108108
- file 0 => global file 1
@@ -166,7 +166,7 @@ Number of file 0 mappings: 20
166166
- Code(Expression(16, Add)) at (prev + 3, 1) to (start + 0, 2)
167167
= (c3 + (c2 + (c0 - c1)))
168168

169-
Function name: mcdc_nested_if::nested_single_condition_decision
169+
Function name: nested_if::nested_single_condition_decision
170170
Raw bytes (85): 0x[01, 01, 06, 01, 05, 05, 11, 05, 11, 09, 02, 0d, 17, 09, 02, 0b, 01, 17, 01, 04, 09, 28, 00, 02, 04, 08, 00, 29, 30, 05, 02, 01, 02, 00, 00, 08, 00, 09, 30, 0d, 09, 02, 00, 00, 00, 0d, 00, 29, 05, 00, 10, 00, 11, 20, 11, 0a, 00, 10, 00, 11, 11, 00, 14, 00, 19, 0a, 00, 23, 00, 27, 0d, 00, 2a, 02, 06, 17, 02, 0c, 02, 06, 13, 03, 01, 00, 02]
171171
Number of files: 1
172172
- file 0 => global file 1

tests/coverage/mcdc_nested_if.coverage tests/coverage/mcdc/nested_if.coverage

+24-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
LL| |//@ edition: 2021
33
LL| |//@ min-llvm-version: 18
44
LL| |//@ compile-flags: -Zcoverage-options=mcdc
5-
LL| |//@ llvm-cov-flags: --show-mcdc
5+
LL| |//@ llvm-cov-flags: --show-branches=count --show-mcdc
66
LL| |
77
LL| 4|fn nested_if_in_condition(a: bool, b: bool, c: bool) {
88
LL| 4| if a && if b || c { true } else { false } {
99
^3 ^2 ^2 ^1
1010
------------------
11+
| Branch (LL:8): [True: 3, False: 1]
12+
| Branch (LL:13): [True: 2, False: 1]
13+
| Branch (LL:16): [True: 1, False: 2]
14+
| Branch (LL:21): [True: 1, False: 1]
15+
------------------
1116
|---> MC/DC Decision Region (LL:8) to (LL:46)
1217
|
1318
| Number of Conditions: 2
@@ -53,6 +58,13 @@
5358
LL| 4| if a && if b || if c && d { true } else { false } { false } else { true } {
5459
^3 ^2 ^1 ^1 ^1 ^2 ^1
5560
------------------
61+
| Branch (LL:8): [True: 3, False: 1]
62+
| Branch (LL:13): [True: 1, False: 2]
63+
| Branch (LL:16): [True: 1, False: 2]
64+
| Branch (LL:21): [True: 1, False: 1]
65+
| Branch (LL:24): [True: 1, False: 1]
66+
| Branch (LL:29): [True: 1, False: 0]
67+
------------------
5668
|---> MC/DC Decision Region (LL:8) to (LL:78)
5769
|
5870
| Number of Conditions: 2
@@ -117,6 +129,10 @@
117129
LL| 3| if a && if b { false } else { true } {
118130
^2 ^1 ^1
119131
------------------
132+
| Branch (LL:8): [True: 2, False: 1]
133+
| Branch (LL:13): [True: 1, False: 1]
134+
| Branch (LL:16): [True: 1, False: 1]
135+
------------------
120136
|---> MC/DC Decision Region (LL:8) to (LL:41)
121137
|
122138
| Number of Conditions: 2
@@ -145,6 +161,13 @@
145161
LL| 7| if a && if b || c { if d && e { true } else { false } } else { false } {
146162
^6 ^5 ^5 ^2 ^1 ^4 ^1
147163
------------------
164+
| Branch (LL:8): [True: 6, False: 1]
165+
| Branch (LL:13): [True: 1, False: 5]
166+
| Branch (LL:16): [True: 1, False: 5]
167+
| Branch (LL:21): [True: 4, False: 1]
168+
| Branch (LL:28): [True: 2, False: 3]
169+
| Branch (LL:33): [True: 1, False: 1]
170+
------------------
148171
|---> MC/DC Decision Region (LL:8) to (LL:75)
149172
|
150173
| Number of Conditions: 2

tests/coverage/mcdc_nested_if.rs tests/coverage/mcdc/nested_if.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//@ edition: 2021
33
//@ min-llvm-version: 18
44
//@ compile-flags: -Zcoverage-options=mcdc
5-
//@ llvm-cov-flags: --show-mcdc
5+
//@ llvm-cov-flags: --show-branches=count --show-mcdc
66

77
fn nested_if_in_condition(a: bool, b: bool, c: bool) {
88
if a && if b || c { true } else { false } {

0 commit comments

Comments
 (0)