-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb] Rename CommandReturnObject::Get.*Data -> Get.*String #112062
[lldb] Rename CommandReturnObject::Get.*Data -> Get.*String #112062
Conversation
@llvm/pr-subscribers-lldb Author: Adrian Prantl (adrian-prantl) ChangesIn a later commit, I want to add a method to access diagnostics as actual structured data, which will make these function names rather confusing. Full diff: https://github.com/llvm/llvm-project/pull/112062.diff 6 Files Affected:
diff --git a/lldb/include/lldb/Interpreter/CommandReturnObject.h b/lldb/include/lldb/Interpreter/CommandReturnObject.h
index e13c3b7b8e0437..eda841869ba432 100644
--- a/lldb/include/lldb/Interpreter/CommandReturnObject.h
+++ b/lldb/include/lldb/Interpreter/CommandReturnObject.h
@@ -30,16 +30,17 @@ class CommandReturnObject {
~CommandReturnObject() = default;
- llvm::StringRef GetInlineDiagnosticsData(unsigned indent);
+ /// Format any inline diagnostics with an indentation of \c indent.
+ llvm::StringRef GetInlineDiagnosticString(unsigned indent);
- llvm::StringRef GetOutputData() {
+ llvm::StringRef GetOutputString() {
lldb::StreamSP stream_sp(m_out_stream.GetStreamAtIndex(eStreamStringIndex));
if (stream_sp)
return std::static_pointer_cast<StreamString>(stream_sp)->GetString();
return llvm::StringRef();
}
- llvm::StringRef GetErrorData();
+ llvm::StringRef GetErrorString();
Stream &GetOutputStream() {
// Make sure we at least have our normal string stream output stream
diff --git a/lldb/source/API/SBCommandReturnObject.cpp b/lldb/source/API/SBCommandReturnObject.cpp
index d0cdebe8c64911..a94eff75ffcb9e 100644
--- a/lldb/source/API/SBCommandReturnObject.cpp
+++ b/lldb/source/API/SBCommandReturnObject.cpp
@@ -85,27 +85,27 @@ SBCommandReturnObject::operator bool() const {
const char *SBCommandReturnObject::GetOutput() {
LLDB_INSTRUMENT_VA(this);
- ConstString output(ref().GetOutputData());
+ ConstString output(ref().GetOutputString());
return output.AsCString(/*value_if_empty*/ "");
}
const char *SBCommandReturnObject::GetError() {
LLDB_INSTRUMENT_VA(this);
- ConstString output(ref().GetErrorData());
+ ConstString output(ref().GetErrorString());
return output.AsCString(/*value_if_empty*/ "");
}
size_t SBCommandReturnObject::GetOutputSize() {
LLDB_INSTRUMENT_VA(this);
- return ref().GetOutputData().size();
+ return ref().GetOutputString().size();
}
size_t SBCommandReturnObject::GetErrorSize() {
LLDB_INSTRUMENT_VA(this);
- return ref().GetErrorData().size();
+ return ref().GetErrorString().size();
}
size_t SBCommandReturnObject::PutOutput(FILE *fh) {
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index 845b89a75b7b39..f069b2feb5cb7b 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -1099,7 +1099,7 @@ class CommandObjectPythonFunction : public CommandObjectRaw {
} else {
// Don't change the status if the command already set it...
if (result.GetStatus() == eReturnStatusInvalid) {
- if (result.GetOutputData().empty())
+ if (result.GetOutputString().empty())
result.SetStatus(eReturnStatusSuccessFinishNoResult);
else
result.SetStatus(eReturnStatusSuccessFinishResult);
@@ -1205,7 +1205,7 @@ class CommandObjectScriptingObjectRaw : public CommandObjectRaw {
} else {
// Don't change the status if the command already set it...
if (result.GetStatus() == eReturnStatusInvalid) {
- if (result.GetOutputData().empty())
+ if (result.GetOutputString().empty())
result.SetStatus(eReturnStatusSuccessFinishNoResult);
else
result.SetStatus(eReturnStatusSuccessFinishResult);
@@ -2137,7 +2137,7 @@ class CommandObjectScriptingObjectParsed : public CommandObjectParsed {
} else {
// Don't change the status if the command already set it...
if (result.GetStatus() == eReturnStatusInvalid) {
- if (result.GetOutputData().empty())
+ if (result.GetOutputString().empty())
result.SetStatus(eReturnStatusSuccessFinishNoResult);
else
result.SetStatus(eReturnStatusSuccessFinishResult);
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index e6b9eedd89b4e3..c666a753343c9d 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -784,9 +784,10 @@ void Debugger::Destroy(DebuggerSP &debugger_sp) {
CommandReturnObject result(debugger_sp->GetUseColor());
cmd_interpreter.SaveTranscript(result);
if (result.Succeeded())
- (*debugger_sp->GetAsyncOutputStream()) << result.GetOutputData() << '\n';
+ (*debugger_sp->GetAsyncOutputStream())
+ << result.GetOutputString() << '\n';
else
- (*debugger_sp->GetAsyncErrorStream()) << result.GetErrorData() << '\n';
+ (*debugger_sp->GetAsyncErrorStream()) << result.GetErrorString() << '\n';
}
debugger_sp->Clear();
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index b4a823310d0a66..19bb420f2116dc 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2094,11 +2094,11 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
// used instead of `GetSaveTrasncript()`. This is because the latter will
// fail when the command is "settings set interpreter.save-transcript true".
if (transcript_item) {
- m_transcript_stream << result.GetOutputData();
- m_transcript_stream << result.GetErrorData();
+ m_transcript_stream << result.GetOutputString();
+ m_transcript_stream << result.GetErrorString();
- transcript_item->AddStringItem("output", result.GetOutputData());
- transcript_item->AddStringItem("error", result.GetErrorData());
+ transcript_item->AddStringItem("output", result.GetOutputString());
+ transcript_item->AddStringItem("error", result.GetErrorString());
transcript_item->AddFloatItem("durationInSeconds",
execute_time.get().count());
}
@@ -2632,11 +2632,11 @@ void CommandInterpreter::HandleCommands(const StringList &commands,
if (options.GetPrintResults()) {
if (tmp_result.Succeeded())
- result.AppendMessage(tmp_result.GetOutputData());
+ result.AppendMessage(tmp_result.GetOutputString());
}
if (!success || !tmp_result.Succeeded()) {
- llvm::StringRef error_msg = tmp_result.GetErrorData();
+ llvm::StringRef error_msg = tmp_result.GetErrorString();
if (error_msg.empty())
error_msg = "<unknown error>.\n";
if (options.GetStopOnError()) {
@@ -3192,7 +3192,7 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
unsigned prompt_len = m_debugger.GetPrompt().size();
if (auto indent = result.GetDiagnosticIndent()) {
llvm::StringRef diags =
- result.GetInlineDiagnosticsData(prompt_len + *indent);
+ result.GetInlineDiagnosticString(prompt_len + *indent);
PrintCommandOutput(io_handler, diags, true);
}
}
@@ -3201,13 +3201,13 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
GetProcessOutput();
if (!result.GetImmediateOutputStream()) {
- llvm::StringRef output = result.GetOutputData();
+ llvm::StringRef output = result.GetOutputString();
PrintCommandOutput(io_handler, output, true);
}
// Now emit the command error text from the command we just executed.
if (!result.GetImmediateErrorStream()) {
- llvm::StringRef error = result.GetErrorData();
+ llvm::StringRef error = result.GetErrorString();
PrintCommandOutput(io_handler, error, false);
}
}
diff --git a/lldb/source/Interpreter/CommandReturnObject.cpp b/lldb/source/Interpreter/CommandReturnObject.cpp
index 7c9905bc57d992..28f76dc0c40f94 100644
--- a/lldb/source/Interpreter/CommandReturnObject.cpp
+++ b/lldb/source/Interpreter/CommandReturnObject.cpp
@@ -123,7 +123,8 @@ void CommandReturnObject::SetError(llvm::Error error) {
}
}
-llvm::StringRef CommandReturnObject::GetInlineDiagnosticsData(unsigned indent) {
+llvm::StringRef
+CommandReturnObject::GetInlineDiagnosticString(unsigned indent) {
RenderDiagnosticDetails(m_diag_stream, indent, true, m_diagnostics);
// Duplex the diagnostics to the secondary stream (but not inlined).
if (auto stream_sp = m_err_stream.GetStreamAtIndex(eStreamStringIndex))
@@ -134,7 +135,7 @@ llvm::StringRef CommandReturnObject::GetInlineDiagnosticsData(unsigned indent) {
return m_diag_stream.GetString();
}
-llvm::StringRef CommandReturnObject::GetErrorData() {
+llvm::StringRef CommandReturnObject::GetErrorString() {
// Diagnostics haven't been fetched; render them now (not inlined).
if (!m_diagnostics.empty()) {
RenderDiagnosticDetails(GetErrorStream(), std::nullopt, false,
|
In a later commit, I want to add a method to access diagnostics as actual structured data, which will make these function names rather confusing.
e0f65d0
to
c40bb5f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, LGTM!
The best I can reconstruct, these were GetData because of the StreamString API name. That's not a good reason, and after all they do return strings, so this makes sense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
) In a later commit, I want to add a method to access diagnostics as actual structured data, which will make these function names rather confusing. (cherry picked from commit c275080)
) In a later commit, I want to add a method to access diagnostics as actual structured data, which will make these function names rather confusing. (cherry picked from commit c275080)
@adrian-prantl It seems that this change is causing the 'lldb/unittests/ScriptInterpreter/Lua/ScriptInterpreterTests.cpp' to fail when building using GCC. c275080 [lldb] Rename CommandReturnObject::Get.*Data -> Get.*String (#112062)
After change:
Note: Top of Tree at: |
@JDevlieghere fixed this in 40ea92c |
@adrian-prantl, @JDevlieghere Thanks for the fix. |
In a later commit, I want to add a method to access diagnostics as actual structured data, which will make these function names rather confusing.