This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG12ae3cb7ba53: [lldb] Assert that CommandResultObject error messages are not empty (authored by DavidSpickett).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D104525/new/ https://reviews.llvm.org/D104525 Files: lldb/source/Interpreter/CommandReturnObject.cpp Index: lldb/source/Interpreter/CommandReturnObject.cpp =================================================================== --- lldb/source/Interpreter/CommandReturnObject.cpp +++ lldb/source/Interpreter/CommandReturnObject.cpp @@ -99,24 +99,18 @@ void CommandReturnObject::AppendError(llvm::StringRef in_string) { SetStatus(eReturnStatusFailed); - if (in_string.empty()) - return; + assert(!in_string.empty() && "Expected a non-empty error message"); error(GetErrorStream()) << in_string.rtrim() << '\n'; } void CommandReturnObject::SetError(const Status &error, const char *fallback_error_cstr) { - const char *error_cstr = error.AsCString(); - if (error_cstr == nullptr) - error_cstr = fallback_error_cstr; - SetError(error_cstr); + assert(error.Fail() && "Expected a failed Status"); + SetError(error.AsCString(fallback_error_cstr)); } void CommandReturnObject::SetError(llvm::StringRef error_str) { SetStatus(eReturnStatusFailed); - if (error_str.empty()) - return; - AppendError(error_str); } @@ -125,8 +119,7 @@ void CommandReturnObject::AppendRawError(llvm::StringRef in_string) { SetStatus(eReturnStatusFailed); - if (in_string.empty()) - return; + assert(!in_string.empty() && "Expected a non-empty error message"); GetErrorStream() << in_string; }
Index: lldb/source/Interpreter/CommandReturnObject.cpp =================================================================== --- lldb/source/Interpreter/CommandReturnObject.cpp +++ lldb/source/Interpreter/CommandReturnObject.cpp @@ -99,24 +99,18 @@ void CommandReturnObject::AppendError(llvm::StringRef in_string) { SetStatus(eReturnStatusFailed); - if (in_string.empty()) - return; + assert(!in_string.empty() && "Expected a non-empty error message"); error(GetErrorStream()) << in_string.rtrim() << '\n'; } void CommandReturnObject::SetError(const Status &error, const char *fallback_error_cstr) { - const char *error_cstr = error.AsCString(); - if (error_cstr == nullptr) - error_cstr = fallback_error_cstr; - SetError(error_cstr); + assert(error.Fail() && "Expected a failed Status"); + SetError(error.AsCString(fallback_error_cstr)); } void CommandReturnObject::SetError(llvm::StringRef error_str) { SetStatus(eReturnStatusFailed); - if (error_str.empty()) - return; - AppendError(error_str); } @@ -125,8 +119,7 @@ void CommandReturnObject::AppendRawError(llvm::StringRef in_string) { SetStatus(eReturnStatusFailed); - if (in_string.empty()) - return; + assert(!in_string.empty() && "Expected a non-empty error message"); GetErrorStream() << in_string; }
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits