diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2024-12-19 21:53:10 +1100 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2024-12-19 22:03:43 +1100 |
| commit | aced4dcf1047aab08b769b34fae9d4ba7de87f04 (patch) | |
| tree | 40131ad1857c729b5bf690ba554fdfee4e43eb31 /compiler/rustc_session/src | |
| parent | 837a25dd41a1cc58cee093159a01f73719f330e8 (diff) | |
| download | rust-aced4dcf1047aab08b769b34fae9d4ba7de87f04.tar.gz rust-aced4dcf1047aab08b769b34fae9d4ba7de87f04.zip | |
coverage: Add a synthetic test for when all spans are discarded
Diffstat (limited to 'compiler/rustc_session/src')
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_session/src/options.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 5 |
3 files changed, 14 insertions, 2 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 4784a4d1953..047e920e688 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -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. diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 3873a203bd3..3772a4a08af 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -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, } } diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 9f6106f9cfb..54bb4622963 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -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) } |
