coverage: Add a synthetic test for when all spans are discarded
This commit is contained in:
parent
837a25dd41
commit
aced4dcf10
8 changed files with 67 additions and 3 deletions
|
@ -147,18 +147,24 @@ pub enum InstrumentCoverage {
|
|||
Yes,
|
||||
}
|
||||
|
||||
/// Individual flag values controlled by `-Z coverage-options`.
|
||||
/// Individual flag values controlled by `-Zcoverage-options`.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Default)]
|
||||
pub struct CoverageOptions {
|
||||
pub level: CoverageLevel,
|
||||
|
||||
/// `-Z coverage-options=no-mir-spans`: Don't extract block coverage spans
|
||||
/// `-Zcoverage-options=no-mir-spans`: Don't extract block coverage spans
|
||||
/// from MIR statements/terminators, making it easier to inspect/debug
|
||||
/// branch and MC/DC coverage mappings.
|
||||
///
|
||||
/// For internal debugging only. If other code changes would make it hard
|
||||
/// to keep supporting this flag, remove it.
|
||||
pub no_mir_spans: bool,
|
||||
|
||||
/// `-Zcoverage-options=discard-all-spans-in-codegen`: During codgen,
|
||||
/// discard all coverage spans as though they were invalid. Needed by
|
||||
/// regression tests for #133606, because we don't have an easy way to
|
||||
/// reproduce it from actual source code.
|
||||
pub discard_all_spans_in_codegen: bool,
|
||||
}
|
||||
|
||||
/// Controls whether branch coverage or MC/DC coverage is enabled.
|
||||
|
|
|
@ -1037,6 +1037,7 @@ pub mod parse {
|
|||
"condition" => slot.level = CoverageLevel::Condition,
|
||||
"mcdc" => slot.level = CoverageLevel::Mcdc,
|
||||
"no-mir-spans" => slot.no_mir_spans = true,
|
||||
"discard-all-spans-in-codegen" => slot.discard_all_spans_in_codegen = true,
|
||||
_ => return false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -352,6 +352,11 @@ impl Session {
|
|||
self.opts.unstable_opts.coverage_options.no_mir_spans
|
||||
}
|
||||
|
||||
/// True if `-Zcoverage-options=discard-all-spans-in-codegen` was passed.
|
||||
pub fn coverage_discard_all_spans_in_codegen(&self) -> bool {
|
||||
self.opts.unstable_opts.coverage_options.discard_all_spans_in_codegen
|
||||
}
|
||||
|
||||
pub fn is_sanitizer_cfi_enabled(&self) -> bool {
|
||||
self.opts.unstable_opts.sanitizer.contains(SanitizerSet::CFI)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue