Skip to content

Commit d1b5c3f

Browse files
committed
coverage: Add CLI 'condition' coverage option
1 parent 6acb9e7 commit d1b5c3f

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

compiler/rustc_interface/src/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ fn test_unstable_options_tracking_hash() {
761761
})
762762
);
763763
tracked!(codegen_backend, Some("abc".to_string()));
764-
tracked!(coverage_options, CoverageOptions { branch: true, mcdc: true });
764+
tracked!(coverage_options, CoverageOptions { branch: true, condition: true, mcdc: true });
765765
tracked!(crate_attr, vec!["abc".to_string()]);
766766
tracked!(cross_crate_inline_threshold, InliningThreshold::Always);
767767
tracked!(debug_info_for_profiling, true);

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 condition coverage instrumentation.
152+
pub condition: bool,
151153
/// Add mcdc coverage instrumentation.
152154
pub mcdc: bool,
153155
}

compiler/rustc_session/src/options.rs

+5
Original file line numberDiff line numberDiff line change
@@ -951,8 +951,13 @@ mod parse {
951951
slot.mcdc = false;
952952
}
953953
"branch" => slot.branch = true,
954+
"condition" => {
955+
slot.branch = true;
956+
slot.condition = true;
957+
}
954958
"mcdc" => {
955959
slot.branch = true;
960+
slot.condition = true;
956961
slot.mcdc = true;
957962
}
958963
_ => return false,

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_condition(&self) -> bool {
356+
self.instrument_coverage() && self.opts.unstable_opts.coverage_options.condition
357+
}
358+
355359
pub fn instrument_coverage_mcdc(&self) -> bool {
356360
self.instrument_coverage() && self.opts.unstable_opts.coverage_options.mcdc
357361
}

0 commit comments

Comments
 (0)