about summary refs log tree commit diff
path: root/src/librustc_session
diff options
context:
space:
mode:
authorAndrew Paverd <andrew.paverd@microsoft.com>2020-06-16 17:44:03 +0100
committerAndrew Paverd <andrew.paverd@microsoft.com>2020-06-16 17:44:03 +0100
commit83e6c0e98657d8df3dd4f45fa22baadcac986402 (patch)
treeabc701f2a87883d84a3b6e97f87abc71f45972ac /src/librustc_session
parentc8a9c340de32cb70c8bad8af1a4474f805c5a969 (diff)
Update CFGuard syntax
Diffstat (limited to 'src/librustc_session')
-rw-r--r--src/librustc_session/config.rs2
-rw-r--r--src/librustc_session/options.rs29
2 files changed, 22 insertions, 9 deletions
diff --git a/src/librustc_session/config.rs b/src/librustc_session/config.rs
index 411a6eecbba..562f71e8e92 100644
--- a/src/librustc_session/config.rs
+++ b/src/librustc_session/config.rs
@@ -82,7 +82,7 @@ pub enum Strip {
     Symbols,
 }
 
-/// The different settings that the `-Z control_flow_guard` flag can have.
+/// The different settings that the `-Z control-flow-guard` flag can have.
 #[derive(Clone, Copy, PartialEq, Hash, Debug)]
 pub enum CFGuard {
     /// Do not emit Control Flow Guard metadata or checks.
diff --git a/src/librustc_session/options.rs b/src/librustc_session/options.rs
index d22c6ec9d7d..e822e79bf4f 100644
--- a/src/librustc_session/options.rs
+++ b/src/librustc_session/options.rs
@@ -251,7 +251,8 @@ macro_rules! options {
         pub const parse_sanitizer: &str = "one of: `address`, `leak`, `memory` or `thread`";
         pub const parse_sanitizer_list: &str = "comma separated list of sanitizers";
         pub const parse_sanitizer_memory_track_origins: &str = "0, 1, or 2";
-        pub const parse_cfguard: &str = "either `disabled`, `nochecks`, or `checks`";
+        pub const parse_cfguard: &str =
+            "either a boolean (`yes`, `no`, `on`, `off`, etc), `checks`, or `nochecks`";
         pub const parse_strip: &str = "either `none`, `debuginfo`, or `symbols`";
         pub const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavor::one_of();
         pub const parse_optimization_fuel: &str = "crate=integer";
@@ -505,12 +506,24 @@ macro_rules! options {
         }
 
         fn parse_cfguard(slot: &mut CFGuard, v: Option<&str>) -> bool {
-            match v {
-                Some("disabled") => *slot = CFGuard::Disabled,
-                Some("nochecks") => *slot = CFGuard::NoChecks,
-                Some("checks") => *slot = CFGuard::Checks,
-                _ => return false,
+            if v.is_some() {
+                let mut bool_arg = None;
+                if parse_opt_bool(&mut bool_arg, v) {
+                    *slot = if bool_arg.unwrap() {
+                        CFGuard::Checks
+                    } else {
+                        CFGuard::Disabled
+                    };
+                    return true
+                }
             }
+
+            *slot = match v {
+                None => CFGuard::Checks,
+                Some("checks") => CFGuard::Checks,
+                Some("nochecks") => CFGuard::NoChecks,
+                Some(_) => return false,
+            };
             true
         }
 
@@ -806,8 +819,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
         "enable the experimental Chalk-based trait solving engine"),
     codegen_backend: Option<String> = (None, parse_opt_string, [TRACKED],
         "the backend to use"),
-    control_flow_guard: CFGuard = (CFGuard::Disabled, parse_cfguard, [UNTRACKED],
-        "use Windows Control Flow Guard (`disabled`, `nochecks` or `checks`)"),
+    control_flow_guard: CFGuard = (CFGuard::Disabled, parse_cfguard, [TRACKED],
+        "use Windows Control Flow Guard (default: no)"),
     crate_attr: Vec<String> = (Vec::new(), parse_string_push, [TRACKED],
         "inject the given attribute in the crate"),
     debug_macros: bool = (false, parse_bool, [TRACKED],