1
Fork 0

Put checks that detect UB under their own flag below debug_assertions

This commit is contained in:
Ben Kimock 2024-04-03 08:54:03 -04:00
parent 83d0a940c6
commit a7912cb421
42 changed files with 206 additions and 64 deletions

View file

@ -212,6 +212,10 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg {
ins_none!(sym::test);
}
if sess.ub_checks() {
ins_none!(sym::ub_checks);
}
ret
}
@ -367,6 +371,8 @@ impl CheckCfg {
ins!(sym::test, no_values);
ins!(sym::ub_checks, no_values);
ins!(sym::unix, no_values);
ins!(sym::windows, no_values);
}

View file

@ -1992,6 +1992,9 @@ written to standard error output)"),
"in diagnostics, use heuristics to shorten paths referring to items"),
tune_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
"select processor to schedule for (`rustc --print target-cpus` for details)"),
#[rustc_lint_opt_deny_field_access("use `Session::ub_checks` instead of this field")]
ub_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
"emit runtime checks for Undefined Behavior (default: -Cdebug-assertions)"),
ui_testing: bool = (false, parse_bool, [UNTRACKED],
"emit compiler diagnostics in a form suitable for UI testing (default: no)"),
uninit_const_chunk_threshold: usize = (16, parse_number, [TRACKED],

View file

@ -735,6 +735,10 @@ impl Session {
self.opts.cg.overflow_checks.unwrap_or(self.opts.debug_assertions)
}
pub fn ub_checks(&self) -> bool {
self.opts.unstable_opts.ub_checks.unwrap_or(self.opts.debug_assertions)
}
pub fn relocation_model(&self) -> RelocModel {
self.opts.cg.relocation_model.unwrap_or(self.target.relocation_model)
}