coverage: Simplify access to debug/testing -Zcoverage-options flags
This commit is contained in:
parent
fb39d3ed88
commit
f496e83fe9
3 changed files with 9 additions and 6 deletions
|
|
@ -131,7 +131,7 @@ fn fill_region_tables<'tcx>(
|
|||
// codegen needs to handle that gracefully to avoid #133606.
|
||||
// It's hard for tests to trigger this organically, so instead we set
|
||||
// `-Zcoverage-options=discard-all-spans-in-codegen` to force it to occur.
|
||||
let discard_all = tcx.sess.coverage_discard_all_spans_in_codegen();
|
||||
let discard_all = tcx.sess.coverage_options().discard_all_spans_in_codegen;
|
||||
let make_coords = |span: Span| {
|
||||
if discard_all { None } else { spans::make_coords(source_map, &source_file, span) }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -182,6 +182,7 @@ pub enum InstrumentCoverage {
|
|||
pub struct CoverageOptions {
|
||||
pub level: CoverageLevel,
|
||||
|
||||
/// **(internal test-only flag)**
|
||||
/// `-Zcoverage-options=discard-all-spans-in-codegen`: During codegen,
|
||||
/// discard all coverage spans as though they were invalid. Needed by
|
||||
/// regression tests for #133606, because we don't have an easy way to
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ use rustc_target::spec::{
|
|||
use crate::code_stats::CodeStats;
|
||||
pub use crate::code_stats::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo};
|
||||
use crate::config::{
|
||||
self, CoverageLevel, CrateType, DebugInfo, ErrorOutputType, FunctionReturn, Input,
|
||||
InstrumentCoverage, OptLevel, OutFileName, OutputType, RemapPathScopeComponents,
|
||||
self, CoverageLevel, CoverageOptions, CrateType, DebugInfo, ErrorOutputType, FunctionReturn,
|
||||
Input, InstrumentCoverage, OptLevel, OutFileName, OutputType, RemapPathScopeComponents,
|
||||
SwitchWithOptPath,
|
||||
};
|
||||
use crate::filesearch::FileSearch;
|
||||
|
|
@ -359,9 +359,11 @@ impl Session {
|
|||
&& self.opts.unstable_opts.coverage_options.level >= CoverageLevel::Mcdc
|
||||
}
|
||||
|
||||
/// 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
|
||||
/// Provides direct access to the `CoverageOptions` struct, so that
|
||||
/// individual flags for debugging/testing coverage instrumetation don't
|
||||
/// need separate accessors.
|
||||
pub fn coverage_options(&self) -> &CoverageOptions {
|
||||
&self.opts.unstable_opts.coverage_options
|
||||
}
|
||||
|
||||
pub fn is_sanitizer_cfi_enabled(&self) -> bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue