[Lldb-commits] [PATCH] D104525: [lldb] Assert that CommandResultObject error messages are not empty

David Blaikie via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 18 11:38:52 PDT 2021


dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Sounds good, if this already passes all tests/etc (ie: there actually aren't any callers passing empty strings/non-failed errors/etc)



================
Comment at: lldb/source/Interpreter/CommandReturnObject.cpp:122
   SetStatus(eReturnStatusFailed);
-  if (in_string.empty())
-    return;
+  assert(in_string.size() && "Expected a non-empty error message");
   GetErrorStream() << in_string;
----------------
I'd prefer to write that as `!in_string.empty()` - it's a somewhat more direct statement of the intent (& good habit to use empty on containers rather than size != 0 - some containers can have more expensive size operations).

Similarly above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104525



More information about the lldb-commits mailing list