Block,
}
+/// The different settings that the `-Z instrument-coverage` flag can have.
+///
+/// Coverage instrumentation now supports combining `-Z instrument-coverage`
+/// with compiler and linker optimization (enabled with `-O` or `-C opt-level=1`
+/// and higher). Nevertheless, there are many variables, depending on options
+/// selected, code structure, and enabled attributes. If errors are encountered,
+/// either while compiling or when generating `llvm-cov show` reports, consider
+/// lowering the optimization level, including or excluding `-C link-dead-code`,
+/// or using `-Z instrument-coverage=except-unused-functions` or `-Z
+/// instrument-coverage=except-unused-generics`.
+///
+/// Note that `ExceptUnusedFunctions` means: When `mapgen.rs` generates the
+/// coverage map, it will not attempt to generate synthetic functions for unused
+/// (and not code-generated) functions (whether they are generic or not). As a
+/// result, non-codegenned functions will not be included in the coverage map,
+/// and will not appear, as covered or uncovered, in coverage reports.
+///
+/// `ExceptUnusedGenerics` will add synthetic functions to the coverage map,
+/// unless the function has type parameters.
+#[derive(Clone, Copy, PartialEq, Hash, Debug)]
+pub enum InstrumentCoverage {
+ /// Default `-Z instrument-coverage` or `-Z instrument-coverage=statement`
+ All,
+ /// `-Z instrument-coverage=except-unused-generics`
+ ExceptUnusedGenerics,
+ /// `-Z instrument-coverage=except-unused-functions`
+ ExceptUnusedFunctions,
+ /// `-Z instrument-coverage=off` (or `no`, etc.)
+ Off,
+}
+
#[derive(Clone, PartialEq, Hash)]
pub enum LinkerPluginLto {
LinkerPlugin(PathBuf),
}
impl Externs {
+ /// Used for testing.
pub fn new(data: BTreeMap<String, ExternEntry>) -> Externs {
Externs(data)
}
}
}
- pub fn get_input(&mut self) -> Option<&mut String> {
- match *self {
- Input::File(_) => None,
- Input::Str { ref mut input, .. } => Some(input),
- }
- }
-
pub fn source_name(&self) -> FileName {
match *self {
Input::File(ref ifile) => ifile.clone().into(),
|| self.debugging_opts.query_dep_graph
}
- #[inline(always)]
- pub fn enable_dep_node_debug_strs(&self) -> bool {
- cfg!(debug_assertions)
- && (self.debugging_opts.query_dep_graph || self.debugging_opts.incremental_info)
- }
-
pub fn file_path_mapping(&self) -> FilePathMapping {
FilePathMapping::new(self.remap_path_prefix.clone())
}
opts.error_format,
&format!(
"Error loading target specification: {}. \
- Use `--print target-list` for a list of built-in targets",
+ Run `rustc --print target-list` for a list of built-in targets",
e
),
)
pub fn flag_s(a: S, b: S, c: S) -> R {
stable(longer(a, b), move |opts| opts.optflag(a, b, c))
}
- pub fn flagopt_s(a: S, b: S, c: S, d: S) -> R {
- stable(longer(a, b), move |opts| opts.optflagopt(a, b, c, d))
- }
pub fn flagmulti_s(a: S, b: S, c: S) -> R {
stable(longer(a, b), move |opts| opts.optflagmulti(a, b, c))
}
pub fn multi(a: S, b: S, c: S, d: S) -> R {
unstable(longer(a, b), move |opts| opts.optmulti(a, b, c, d))
}
- pub fn flag(a: S, b: S, c: S) -> R {
- unstable(longer(a, b), move |opts| opts.optflag(a, b, c))
- }
- pub fn flagopt(a: S, b: S, c: S, d: S) -> R {
- unstable(longer(a, b), move |opts| opts.optflagopt(a, b, c, d))
- }
- pub fn flagmulti(a: S, b: S, c: S) -> R {
- unstable(longer(a, b), move |opts| opts.optflagmulti(a, b, c))
- }
}
/// Returns the "short" subset of the rustc command line options,
);
}
- if debugging_opts.instrument_coverage {
+ if debugging_opts.instrument_coverage.is_some()
+ && debugging_opts.instrument_coverage != Some(InstrumentCoverage::Off)
+ {
if cg.profile_generate.enabled() || cg.profile_use.is_some() {
early_error(
error_format,
pub fn needs_analysis(&self) -> bool {
use PpMode::*;
- matches!(*self, Mir | MirCFG)
+ matches!(*self, Mir | MirCFG | ThirTree)
}
}
/// how the hash should be calculated when adding a new command-line argument.
crate mod dep_tracking {
use super::{
- CFGuard, CrateType, DebugInfo, ErrorOutputType, LinkerPluginLto, LtoCli, OptLevel,
- OutputTypes, Passes, SanitizerSet, SourceFileHashAlgorithm, SwitchWithOptPath,
- SymbolManglingVersion, TrimmedDefPaths,
+ CFGuard, CrateType, DebugInfo, ErrorOutputType, InstrumentCoverage, LinkerPluginLto,
+ LtoCli, OptLevel, OutputTypes, Passes, SanitizerSet, SourceFileHashAlgorithm,
+ SwitchWithOptPath, SymbolManglingVersion, TrimmedDefPaths,
};
use crate::lint;
use crate::options::WasiExecModel;
impl_dep_tracking_hash_via_hash!(Option<WasiExecModel>);
impl_dep_tracking_hash_via_hash!(Option<PanicStrategy>);
impl_dep_tracking_hash_via_hash!(Option<RelroLevel>);
+ impl_dep_tracking_hash_via_hash!(Option<InstrumentCoverage>);
impl_dep_tracking_hash_via_hash!(Option<lint::Level>);
impl_dep_tracking_hash_via_hash!(Option<PathBuf>);
impl_dep_tracking_hash_via_hash!(CrateType);
}
// This is a stable hash because BTreeMap is a sorted container
- pub fn stable_hash(
+ crate fn stable_hash(
sub_hashes: BTreeMap<&'static str, &dyn DepTrackingHash>,
hasher: &mut DefaultHasher,
error_format: ErrorOutputType,