diff options
| author | Pavel Labath <pavel@labath.sk> | 2019-08-14 08:11:20 +0000 |
|---|---|---|
| committer | Pavel Labath <pavel@labath.sk> | 2019-08-14 08:11:20 +0000 |
| commit | 72ef113d40ef57d9dd4cf7ba6819e2048df99fc6 (patch) | |
| tree | 2f9a8ca0bdf41f0e1f550713d67aced265fc8616 /lldb/source/API/SBCommandReturnObject.cpp | |
| parent | 1427226fe8c363b454a06ead02b041b1f658fe8f (diff) | |
[API] Have SBCommandReturnObject::GetOutput/Error return "" instead of nullptr
Summary:
It seems this was an unintended side-effect of D26698. AFAICT, these
functions did return an empty string before that patch, and the patch
contained code which attempted to ensure that, but those efforts were
negated by ConstString::AsCString, which by default returns a nullptr
even for empty strings.
This patch:
- fixes the GetOutput/Error methods to really return empty strings
- adds and explicit test for that
- removes a workaround in lldbtest.py, which was masking this problem
from our other tests
Reviewers: jingham, clayborg
Subscribers: zturner, lldb-commits
Differential Revision: https://reviews.llvm.org/D65739
llvm-svn: 368806
Diffstat (limited to 'lldb/source/API/SBCommandReturnObject.cpp')
| -rw-r--r-- | lldb/source/API/SBCommandReturnObject.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/lldb/source/API/SBCommandReturnObject.cpp b/lldb/source/API/SBCommandReturnObject.cpp index 94e89916f7f6..58740eeaade5 100644 --- a/lldb/source/API/SBCommandReturnObject.cpp +++ b/lldb/source/API/SBCommandReturnObject.cpp @@ -72,10 +72,8 @@ const char *SBCommandReturnObject::GetOutput() { LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommandReturnObject, GetOutput); if (m_opaque_up) { - llvm::StringRef output = m_opaque_up->GetOutputData(); - ConstString result(output.empty() ? llvm::StringRef("") : output); - - return result.AsCString(); + ConstString output(m_opaque_up->GetOutputData()); + return output.AsCString(/*value_if_empty*/ ""); } return nullptr; @@ -85,9 +83,8 @@ const char *SBCommandReturnObject::GetError() { LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommandReturnObject, GetError); if (m_opaque_up) { - llvm::StringRef output = m_opaque_up->GetErrorData(); - ConstString result(output.empty() ? llvm::StringRef("") : output); - return result.AsCString(); + ConstString output(m_opaque_up->GetErrorData()); + return output.AsCString(/*value_if_empty*/ ""); } return nullptr; |
