|
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::DenseBitSet; |
@@ -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, |
@@ -306,11 +305,16 @@ pub(super) fn extract_mcdc_mappings( |
306 | 305 | } |
307 | 306 | let decision_span = unexpand_into_body_span(decision.span, body_span)?; |
308 | 307 |
|
309 | | - let end_bcbs = decision |
310 | | - .end_markers |
| 308 | + let update_end_bcbs = decision |
| 309 | + .update_end_markers |
| 310 | + .iter() |
| 311 | + .filter_map(|&marker| bcb_from_marker(marker)) |
| 312 | + .collect(); |
| 313 | + let discard_end_bcbs = decision |
| 314 | + .discard_end_markers |
311 | 315 | .iter() |
312 | | - .map(|&marker| bcb_from_marker(marker)) |
313 | | - .collect::<Option<_>>()?; |
| 316 | + .filter_map(|&marker| bcb_from_marker(marker)) |
| 317 | + .collect(); |
314 | 318 |
|
315 | 319 | let mut branch_mappings: Vec<_> = |
316 | 320 | branches.into_iter().filter_map(extract_condition_mapping).collect(); |
@@ -342,7 +346,8 @@ pub(super) fn extract_mcdc_mappings( |
342 | 346 | Some(( |
343 | 347 | MCDCDecision { |
344 | 348 | span, |
345 | | - end_bcbs, |
| 349 | + update_end_bcbs, |
| 350 | + discard_end_bcbs, |
346 | 351 | bitmap_idx, |
347 | 352 | num_test_vectors, |
348 | 353 | decision_depth: decision.decision_depth, |
@@ -400,7 +405,10 @@ fn calc_test_vectors_index(conditions: &mut Vec<MCDCBranch>) -> usize { |
400 | 405 | } |
401 | 406 | } |
402 | 407 | } |
403 | | - assert!(next_conditions.is_empty(), "the decision tree has untouched nodes"); |
| 408 | + assert!( |
| 409 | + next_conditions.is_empty(), |
| 410 | + "the decision tree has untouched nodes, next_conditions: {next_conditions:?}" |
| 411 | + ); |
404 | 412 | let mut cur_idx = 0; |
405 | 413 | // LLVM hopes the end nodes are sorted in descending order by `num_paths` so that it can |
406 | 414 | // optimize bitmap size for decisions in tree form such as `a && b && c && d && ...`. |
|
0 commit comments