[lldb] Remove asserts in CommandReturnObject SetError and AppendError
authorDavid Spickett <david.spickett@linaro.org>
Wed, 23 Jun 2021 11:28:16 +0000 (11:28 +0000)
committerDavid Spickett <david.spickett@linaro.org>
Wed, 23 Jun 2021 13:11:14 +0000 (13:11 +0000)
I added asserts to these in https://reviews.llvm.org/D104525.
They are available (directly or otherwise) via the API so we
should not assert.

Restore the previous behaviour. If the message
is empty, we return early before printing anything.
For SetError don't assert that the error is a failure.

The remaining assert is in AppendRawError which
is not part of the API.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D104778

lldb/source/Interpreter/CommandReturnObject.cpp

index 85cfd9a..506b0d6 100644 (file)
@@ -99,13 +99,13 @@ void CommandReturnObject::AppendWarning(llvm::StringRef in_string) {
 
 void CommandReturnObject::AppendError(llvm::StringRef in_string) {
   SetStatus(eReturnStatusFailed);
-  assert(!in_string.empty() && "Expected a non-empty error message");
+  if (in_string.empty())
+    return;
   error(GetErrorStream()) << in_string.rtrim() << '\n';
 }
 
 void CommandReturnObject::SetError(const Status &error,
                                    const char *fallback_error_cstr) {
-  assert(error.Fail() && "Expected a failed Status");
   AppendError(error.AsCString(fallback_error_cstr));
 }