|
1 |
| -use std::collections::BTreeSet; |
2 |
| - |
3 |
| -use rustc_data_structures::fx::FxIndexMap; |
| 1 | +use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; |
4 | 2 | use rustc_data_structures::graph::DirectedGraph;
|
5 | 3 | use rustc_index::IndexVec;
|
6 | 4 | use rustc_index::bit_set::BitSet;
|
@@ -51,7 +49,8 @@ pub(super) struct MCDCBranch {
|
51 | 49 | #[derive(Debug)]
|
52 | 50 | pub(super) struct MCDCDecision {
|
53 | 51 | pub(super) span: Span,
|
54 |
| - pub(super) end_bcbs: BTreeSet<BasicCoverageBlock>, |
| 52 | + pub(super) update_end_bcbs: FxIndexSet<BasicCoverageBlock>, |
| 53 | + pub(super) discard_end_bcbs: FxIndexSet<BasicCoverageBlock>, |
55 | 54 | pub(super) bitmap_idx: usize,
|
56 | 55 | pub(super) num_test_vectors: usize,
|
57 | 56 | pub(super) decision_depth: u16,
|
@@ -308,11 +307,16 @@ pub(super) fn extract_mcdc_mappings(
|
308 | 307 | }
|
309 | 308 | let decision_span = unexpand_into_body_span(decision.span, body_span)?;
|
310 | 309 |
|
311 |
| - let end_bcbs = decision |
312 |
| - .end_markers |
| 310 | + let update_end_bcbs = decision |
| 311 | + .update_end_markers |
| 312 | + .iter() |
| 313 | + .filter_map(|&marker| bcb_from_marker(marker)) |
| 314 | + .collect(); |
| 315 | + let discard_end_bcbs = decision |
| 316 | + .discard_end_markers |
313 | 317 | .iter()
|
314 |
| - .map(|&marker| bcb_from_marker(marker)) |
315 |
| - .collect::<Option<_>>()?; |
| 318 | + .filter_map(|&marker| bcb_from_marker(marker)) |
| 319 | + .collect(); |
316 | 320 |
|
317 | 321 | let mut branch_mappings: Vec<_> =
|
318 | 322 | branches.into_iter().filter_map(extract_condition_mapping).collect();
|
@@ -344,7 +348,8 @@ pub(super) fn extract_mcdc_mappings(
|
344 | 348 | Some((
|
345 | 349 | MCDCDecision {
|
346 | 350 | span,
|
347 |
| - end_bcbs, |
| 351 | + update_end_bcbs, |
| 352 | + discard_end_bcbs, |
348 | 353 | bitmap_idx,
|
349 | 354 | num_test_vectors,
|
350 | 355 | decision_depth: decision.decision_depth,
|
@@ -403,7 +408,10 @@ fn calc_test_vectors_index(conditions: &mut Vec<MCDCBranch>) -> usize {
|
403 | 408 | }
|
404 | 409 | }
|
405 | 410 | }
|
406 |
| - assert!(next_conditions.is_empty(), "the decision tree has untouched nodes"); |
| 411 | + assert!( |
| 412 | + next_conditions.is_empty(), |
| 413 | + "the decision tree has untouched nodes, next_conditions: {next_conditions:?}" |
| 414 | + ); |
407 | 415 | let mut cur_idx = 0;
|
408 | 416 | // LLVM hopes the end nodes are sorted in descending order by `num_paths` so that it can
|
409 | 417 | // optimize bitmap size for decisions in tree form such as `a && b && c && d && ...`.
|
|
0 commit comments