Rollup merge of #125754 - Zalathar:conditions-num, r=lqd
coverage: Rename MC/DC `conditions_num` to `num_conditions` Updated version of #124571, without the other changes that were split out into #125108 and #125700. This value represents a quantity of conditions, not an ID, so the new spelling is more appropriate. Some of the code touched by this PR could perhaps use some other changes, but I would prefer to keep this PR as a simple renaming and avoid scope creep. `@rustbot` label +A-code-coverage
This commit is contained in:
commit
479d6cafb7
10 changed files with 34 additions and 33 deletions
|
@ -10,12 +10,12 @@ use rustc_middle::ty::TyCtxt;
|
|||
use rustc_span::Span;
|
||||
|
||||
use crate::build::Builder;
|
||||
use crate::errors::MCDCExceedsConditionNumLimit;
|
||||
use crate::errors::MCDCExceedsConditionLimit;
|
||||
|
||||
/// The MCDC bitmap scales exponentially (2^n) based on the number of conditions seen,
|
||||
/// So llvm sets a maximum value prevents the bitmap footprint from growing too large without the user's knowledge.
|
||||
/// This limit may be relaxed if the [upstream change](https://github.com/llvm/llvm-project/pull/82448) is merged.
|
||||
const MAX_CONDITIONS_NUM_IN_DECISION: usize = 6;
|
||||
const MAX_CONDITIONS_IN_DECISION: usize = 6;
|
||||
|
||||
#[derive(Default)]
|
||||
struct MCDCDecisionCtx {
|
||||
|
@ -100,7 +100,7 @@ impl MCDCState {
|
|||
}
|
||||
None => decision_ctx.processing_decision.insert(MCDCDecisionSpan {
|
||||
span,
|
||||
conditions_num: 0,
|
||||
num_conditions: 0,
|
||||
end_markers: vec![],
|
||||
decision_depth,
|
||||
}),
|
||||
|
@ -108,14 +108,14 @@ impl MCDCState {
|
|||
|
||||
let parent_condition = decision_ctx.decision_stack.pop_back().unwrap_or_default();
|
||||
let lhs_id = if parent_condition.condition_id == ConditionId::NONE {
|
||||
decision.conditions_num += 1;
|
||||
ConditionId::from(decision.conditions_num)
|
||||
decision.num_conditions += 1;
|
||||
ConditionId::from(decision.num_conditions)
|
||||
} else {
|
||||
parent_condition.condition_id
|
||||
};
|
||||
|
||||
decision.conditions_num += 1;
|
||||
let rhs_condition_id = ConditionId::from(decision.conditions_num);
|
||||
decision.num_conditions += 1;
|
||||
let rhs_condition_id = ConditionId::from(decision.num_conditions);
|
||||
|
||||
let (lhs, rhs) = match op {
|
||||
LogicalOp::And => {
|
||||
|
@ -208,17 +208,17 @@ impl MCDCInfoBuilder {
|
|||
// is empty, i.e. when all the conditions of the decision were instrumented,
|
||||
// and the decision is "complete".
|
||||
if let Some(decision) = decision_result {
|
||||
match decision.conditions_num {
|
||||
match decision.num_conditions {
|
||||
0 => {
|
||||
unreachable!("Decision with no condition is not expected");
|
||||
}
|
||||
1..=MAX_CONDITIONS_NUM_IN_DECISION => {
|
||||
1..=MAX_CONDITIONS_IN_DECISION => {
|
||||
self.decision_spans.push(decision);
|
||||
}
|
||||
_ => {
|
||||
// Do not generate mcdc mappings and statements for decisions with too many conditions.
|
||||
// Therefore, first erase the condition info of the (N-1) previous branch spans.
|
||||
let rebase_idx = self.branch_spans.len() - (decision.conditions_num - 1);
|
||||
let rebase_idx = self.branch_spans.len() - (decision.num_conditions - 1);
|
||||
for branch in &mut self.branch_spans[rebase_idx..] {
|
||||
branch.condition_info = None;
|
||||
}
|
||||
|
@ -226,10 +226,10 @@ impl MCDCInfoBuilder {
|
|||
// Then, erase this last branch span's info too, for a total of N.
|
||||
condition_info = None;
|
||||
|
||||
tcx.dcx().emit_warn(MCDCExceedsConditionNumLimit {
|
||||
tcx.dcx().emit_warn(MCDCExceedsConditionLimit {
|
||||
span: decision.span,
|
||||
conditions_num: decision.conditions_num,
|
||||
max_conditions_num: MAX_CONDITIONS_NUM_IN_DECISION,
|
||||
num_conditions: decision.num_conditions,
|
||||
max_conditions: MAX_CONDITIONS_IN_DECISION,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -812,12 +812,12 @@ pub struct NonEmptyNeverPattern<'tcx> {
|
|||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(mir_build_exceeds_mcdc_condition_num_limit)]
|
||||
pub(crate) struct MCDCExceedsConditionNumLimit {
|
||||
#[diag(mir_build_exceeds_mcdc_condition_limit)]
|
||||
pub(crate) struct MCDCExceedsConditionLimit {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub conditions_num: usize,
|
||||
pub max_conditions_num: usize,
|
||||
pub num_conditions: usize,
|
||||
pub max_conditions: usize,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue