@@ -4,7 +4,7 @@ use std::collections::hash_map::Entry;
4
4
use rustc_data_structures:: fx:: FxHashMap ;
5
5
use rustc_index:: IndexVec ;
6
6
use rustc_middle:: mir:: coverage:: {
7
- BlockMarkerId , BranchSpan , ConditionId , CoverageKind , DecisionId , DecisionSpan ,
7
+ BlockMarkerId , BranchSpan , ConditionMarkerId , CoverageKind , DecisionMarkerId , DecisionSpan ,
8
8
} ;
9
9
use rustc_middle:: mir:: { self , BasicBlock , UnOp } ;
10
10
use rustc_middle:: thir:: { ExprId , ExprKind , Thir } ;
@@ -19,12 +19,12 @@ struct MCDCInfoBuilder {
19
19
/// ID of the current decision.
20
20
/// Do not use directly. Use the function instead, as it will hide
21
21
/// the decision in the scope of nested decisions.
22
- current_decision_id : Option < DecisionId > ,
22
+ current_decision_id : Option < DecisionMarkerId > ,
23
23
/// Track the nesting level of decision to avoid MCDC instrumentation of
24
24
/// nested decisions.
25
25
nested_decision_level : u32 ,
26
26
/// Vector for storing all the decisions with their span
27
- decision_spans : IndexVec < DecisionId , Span > ,
27
+ decision_spans : IndexVec < DecisionMarkerId , Span > ,
28
28
29
29
next_condition_id : u32 ,
30
30
}
@@ -52,7 +52,7 @@ impl MCDCInfoBuilder {
52
52
self . nested_decision_level > 1
53
53
}
54
54
55
- pub fn current_decision_id ( & self ) -> Option < DecisionId > {
55
+ pub fn current_decision_id ( & self ) -> Option < DecisionMarkerId > {
56
56
if self . in_nested_condition ( ) { None } else { self . current_decision_id }
57
57
}
58
58
@@ -235,7 +235,7 @@ impl Builder<'_, '_> {
235
235
. mcdc_info
236
236
. as_ref ( )
237
237
. and_then ( |mcdc_info| mcdc_info. current_decision_id ( ) )
238
- . unwrap_or ( DecisionId :: from_u32 ( 0 ) ) ,
238
+ . unwrap_or ( DecisionMarkerId :: from_u32 ( 0 ) ) ,
239
239
true_marker,
240
240
false_marker,
241
241
} ) ;
@@ -268,7 +268,7 @@ impl Builder<'_, '_> {
268
268
let marker_statement = mir:: Statement {
269
269
source_info,
270
270
kind : mir:: StatementKind :: Coverage ( CoverageKind :: MCDCDecisionEntryMarker {
271
- id : decision_id,
271
+ decm_id : decision_id,
272
272
} ) ,
273
273
} ;
274
274
self . cfg . push ( block, marker_statement) ;
@@ -290,43 +290,31 @@ impl Builder<'_, '_> {
290
290
/// If MCDC is enabled and the current decision is being instrumented,
291
291
/// inject an `MCDCDecisionOutputMarker` to the given basic block.
292
292
/// `outcome` should be true for the then block and false for the else block.
293
- pub ( crate ) fn mcdc_decision_outcome_block (
294
- & mut self ,
295
- bb : BasicBlock ,
296
- outcome : bool ,
297
- ) -> BasicBlock {
293
+ pub ( crate ) fn mcdc_decision_outcome_block ( & mut self , bb : BasicBlock , outcome : bool ) {
298
294
// Get the MCDCInfoBuilder object, which existence implies that MCDC is enabled.
299
295
let Some ( BranchInfoBuilder { mcdc_info : Some ( mcdc_info) , .. } ) =
300
296
self . coverage_branch_info . as_mut ( )
301
297
else {
302
- return bb ;
298
+ return ;
303
299
} ;
304
300
305
301
let Some ( decision_id) = mcdc_info. current_decision_id ( ) else {
306
302
// Decision is not instrumented
307
- return bb ;
303
+ return ;
308
304
} ;
309
305
310
306
let span = mcdc_info. decision_spans [ decision_id] ;
311
307
let source_info = self . source_info ( span) ;
312
308
let marker_statement = mir:: Statement {
313
309
source_info,
314
310
kind : mir:: StatementKind :: Coverage ( CoverageKind :: MCDCDecisionOutputMarker {
315
- id : decision_id,
311
+ decm_id : decision_id,
316
312
outcome,
317
313
} ) ,
318
314
} ;
319
315
320
316
// Insert statements at the beginning of the following basic block
321
317
self . cfg . block_data_mut ( bb) . statements . insert ( 0 , marker_statement) ;
322
-
323
- // Create a new block to return
324
- let new_bb = self . cfg . start_new_block ( ) ;
325
-
326
- // Set bb -> new_bb
327
- self . cfg . goto ( bb, source_info, new_bb) ;
328
-
329
- new_bb
330
318
}
331
319
332
320
/// Add markers on the condition's basic blocks to ease the later MCDC instrumentation.
@@ -344,13 +332,12 @@ impl Builder<'_, '_> {
344
332
return ;
345
333
} ;
346
334
347
- let Some ( decision_id ) = mcdc_info. current_decision_id ( ) else {
335
+ let Some ( decm_id ) = mcdc_info. current_decision_id ( ) else {
348
336
// If current_decision_id() is None, the decision is not instrumented.
349
337
return ;
350
338
} ;
351
339
352
-
353
- let id = ConditionId :: from_u32 ( mcdc_info. next_condition_id ( ) ) ;
340
+ let condm_id = ConditionMarkerId :: from_u32 ( mcdc_info. next_condition_id ( ) ) ;
354
341
let span = self . thir [ condition_expr] . span ;
355
342
let source_info = self . source_info ( span) ;
356
343
@@ -362,15 +349,15 @@ impl Builder<'_, '_> {
362
349
363
350
inject_statement (
364
351
condition_block,
365
- CoverageKind :: MCDCConditionEntryMarker { decision_id , id } ,
352
+ CoverageKind :: MCDCConditionEntryMarker { decm_id , condm_id } ,
366
353
) ;
367
354
inject_statement (
368
355
then_block,
369
- CoverageKind :: MCDCConditionOutputMarker { decision_id , id , outcome : true } ,
356
+ CoverageKind :: MCDCConditionOutputMarker { decm_id , condm_id , outcome : true } ,
370
357
) ;
371
358
inject_statement (
372
359
else_block,
373
- CoverageKind :: MCDCConditionOutputMarker { decision_id , id , outcome : false } ,
360
+ CoverageKind :: MCDCConditionOutputMarker { decm_id , condm_id , outcome : false } ,
374
361
) ;
375
362
}
376
363
}
0 commit comments