Skip to content

Commit ce93390

Browse files
committed
mcdc-coverage: Add mcdc and no-mcdc options for -Zcoverage-options
1 parent e883bf9 commit ce93390

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

compiler/rustc_session/src/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ pub enum InstrumentCoverage {
148148
pub struct CoverageOptions {
149149
/// Add branch coverage instrumentation.
150150
pub branch: bool,
151+
/// Add MCDC coverage instrumentation.
152+
pub mcdc: bool,
151153
}
152154

153155
/// Settings for `-Z instrument-xray` flag.

compiler/rustc_session/src/options.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ mod desc {
396396
pub const parse_optimization_fuel: &str = "crate=integer";
397397
pub const parse_dump_mono_stats: &str = "`markdown` (default) or `json`";
398398
pub const parse_instrument_coverage: &str = parse_bool;
399-
pub const parse_coverage_options: &str = "`branch` or `no-branch`";
399+
pub const parse_coverage_options: &str = "`branch`, `no-branch`, `mcdc`, `no-mcdc`";
400400
pub const parse_instrument_xray: &str = "either a boolean (`yes`, `no`, `on`, `off`, etc), or a comma separated list of settings: `always` or `never` (mutually exclusive), `ignore-loops`, `instruction-threshold=N`, `skip-entry`, `skip-exit`";
401401
pub const parse_unpretty: &str = "`string` or `string=string`";
402402
pub const parse_treat_err_as_bug: &str = "either no value or a non-negative number";
@@ -949,6 +949,7 @@ mod parse {
949949
};
950950
let slot = match option {
951951
"branch" => &mut slot.branch,
952+
"mcdc" => &mut slot.mcdc,
952953
_ => return false,
953954
};
954955
*slot = enabled;

compiler/rustc_session/src/session.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,10 @@ impl Session {
356356
self.instrument_coverage() && self.opts.unstable_opts.coverage_options.branch
357357
}
358358

359+
pub fn instrument_coverage_mcdc(&self) -> bool {
360+
self.instrument_coverage() && self.opts.unstable_opts.coverage_options.mcdc
361+
}
362+
359363
pub fn is_sanitizer_cfi_enabled(&self) -> bool {
360364
self.opts.unstable_opts.sanitizer.contains(SanitizerSet::CFI)
361365
}

src/doc/rustc/src/instrument-coverage.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ instrumentation. Pass one or more of the following values, separated by commas.
353353

354354
- `branch` or `no-branch`
355355
- Enables or disables branch coverage instrumentation.
356+
- `mcdc` or `no-mcdc`
357+
- Enables or disables MCDC coverage instrumentation.
356358

357359
## Other references
358360

0 commit comments

Comments
 (0)