[Lldb-commits] [lldb] Start to clean up the process of defining command arguments. (PR #83097)

Med Ismail Bennani via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 26 19:59:44 PST 2024


================
@@ -694,27 +712,32 @@ void CommandObject::GenerateHelpText(Stream &output_strm) {
   }
 }
 
-void CommandObject::AddIDsArgumentData(CommandArgumentEntry &arg,
-                                       CommandArgumentType ID,
-                                       CommandArgumentType IDRange) {
+void CommandObject::AddIDsArgumentData(CommandObject::IDType type) {
+  CommandArgumentEntry arg;
   CommandArgumentData id_arg;
   CommandArgumentData id_range_arg;
 
   // Create the first variant for the first (and only) argument for this
   // command.
-  id_arg.arg_type = ID;
+  switch (type) {
+    case eBreakpointArgs:
+      id_arg.arg_type = eArgTypeBreakpointID;
+      id_range_arg.arg_type = eArgTypeBreakpointIDRange;
+      break;
+    case eWatchpointArgs:
+      id_arg.arg_type = eArgTypeWatchpointID;
+      id_range_arg.arg_type = eArgTypeWatchpointIDRange;
+      break;
+  }
----------------
medismailben wrote:

This looks repetitive ... I wonder if every case of this switch could be a macro that uses string substitution, to simplify it even more.

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


More information about the lldb-commits mailing list