Skip to content

Commit f01a7c6

Browse files
author
zhuyunxing
committed
coverage. Implement mcdc for if-let
1 parent b6591fb commit f01a7c6

File tree

3 files changed

+430
-23
lines changed

3 files changed

+430
-23
lines changed

compiler/rustc_mir_build/src/build/coverageinfo.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,30 @@ impl<'tcx> Builder<'_, 'tcx> {
205205
pub(crate) fn visit_coverage_conditional_let(
206206
&mut self,
207207
pattern: &Pat<'tcx>, // Pattern that has been matched when the true path is taken
208+
test_block: BasicBlock,
208209
true_block: BasicBlock,
209210
false_block: BasicBlock,
210211
) {
211212
// Bail out if branch coverage is not enabled for this function.
212213
let Some(branch_info) = self.coverage_branch_info.as_mut() else { return };
213214

214-
// FIXME(#124144) This may need special handling when MC/DC is enabled.
215-
216215
let source_info = SourceInfo { span: pattern.span, scope: self.source_scope };
216+
217+
if let Some(mcdc_info) = branch_info.mcdc_info.as_mut() {
218+
let inject_block_marker =
219+
|block| branch_info.markers.inject_block_marker(&mut self.cfg, source_info, block);
220+
221+
mcdc_info.visit_evaluated_condition(
222+
self.tcx,
223+
pattern.span,
224+
test_block,
225+
true_block,
226+
false_block,
227+
inject_block_marker,
228+
);
229+
return;
230+
}
231+
217232
branch_info.add_two_way_branch(&mut self.cfg, source_info, true_block, false_block);
218233
}
219234
}

0 commit comments

Comments
 (0)