[Lldb-commits] [lldb] [lldb][NFCI] Remove CommandObjectProcessHandle::VerifyCommandOptionValue (PR #79901)

via lldb-commits lldb-commits at lists.llvm.org
Mon Jan 29 17:21:37 PST 2024


================
@@ -1666,33 +1646,52 @@ class CommandObjectProcessHandle : public CommandObjectParsed {
     // the user's options.
     ProcessSP process_sp = target.GetProcessSP();
 
-    int stop_action = -1;   // -1 means leave the current setting alone
-    int pass_action = -1;   // -1 means leave the current setting alone
-    int notify_action = -1; // -1 means leave the current setting alone
+    std::optional<bool> stop_action = {};
+    std::optional<bool> pass_action = {};
+    std::optional<bool> notify_action = {};
 
-    if (!m_options.stop.empty() &&
-        !VerifyCommandOptionValue(m_options.stop, stop_action)) {
-      result.AppendError("Invalid argument for command option --stop; must be "
-                         "true or false.\n");
-      return;
+    if (!m_options.stop.empty()) {
+      bool success = false;
+      bool value = OptionArgParser::ToBoolean(m_options.stop, false, &success);
+      if (!success) {
+        result.AppendError(
----------------
jimingham wrote:

I don't think this is up to you, since the old code also lied.  But this error is not true, the values can also be `yes`, `no`, `1`, `0`.  Really should be: "should be a <boolean> value", and then all we have to do is teach `help <boolean>`:
`(lldb) help <boolean>
  <boolean> -- A Boolean value: 'true' or 'false'
`

It might be nice if these OptionArgParser::ToWhatever functions could help produce the error string, it's awkward that everybody has to make up their own version of the "what is right" string.

https://github.com/llvm/llvm-project/pull/79901


More information about the lldb-commits mailing list