[Lldb-commits] [PATCH] D110298: Add "command multiword add" and the ability to add script commands into a user multiword hierarchy

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 12 12:26:03 PDT 2021


jingham added inline comments.


================
Comment at: lldb/source/Commands/CommandObjectMultiword.cpp:121-129
+  const char *error_str = nullptr;
+  if (!can_replace)
+    error_str = "sub-command already exists";
+  if (!(*pos).second->IsUserCommand())
+    error_str = "can't replace a builtin subcommand";
+
+  if (error_str) {
----------------
JDevlieghere wrote:
> This inline diff looks more confusing than anything, but basically I just switched the errors around (instead of the current fall-through) and return the error immediately. 
This isn't an early return vrs. not early return thing, since the if's are just deciding which error to print, then we return directly if there was an error.

TTTT, I like my version better.  Your version hides the error message in the middle of two copies of all the llvm::createStringError goo, which makes it much harder to read, IMO.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110298/new/

https://reviews.llvm.org/D110298



More information about the lldb-commits mailing list