Skip to content

Commit 3f791cb

Browse files
committed
mcdc-coverage: Add mcdc and no-mcdc options for -Zcoverage-options
1 parent 2531d08 commit 3f791cb

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

compiler/rustc_session/src/config.rs

+2
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

+2-1
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";
@@ -950,6 +950,7 @@ mod parse {
950950
};
951951
let slot = match option {
952952
"branch" => &mut slot.branch,
953+
"mcdc" => &mut slot.mcdc,
953954
_ => return false,
954955
};
955956
*slot = enabled;

compiler/rustc_session/src/session.rs

+4
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,10 @@ impl Session {
352352
self.instrument_coverage() && self.opts.unstable_opts.coverage_options.branch
353353
}
354354

355+
pub fn instrument_coverage_mcdc(&self) -> bool {
356+
self.instrument_coverage() && self.opts.unstable_opts.coverage_options.mcdc
357+
}
358+
355359
pub fn is_sanitizer_cfi_enabled(&self) -> bool {
356360
self.opts.unstable_opts.sanitizer.contains(SanitizerSet::CFI)
357361
}

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

+2
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)