Skip to content

Commit 7469032

Browse files
committed
[lldb] Constify methods in CommandReturnObject (NFC)
There's no reason these methods cannot be `const`. Currently this prevents us from passing around a const ref. This patch is in preparation for llvm#125006.
1 parent 08c7673 commit 7469032

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

lldb/include/lldb/Interpreter/CommandReturnObject.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ class CommandReturnObject {
3232
~CommandReturnObject() = default;
3333

3434
/// Format any inline diagnostics with an indentation of \c indent.
35-
std::string GetInlineDiagnosticString(unsigned indent);
35+
std::string GetInlineDiagnosticString(unsigned indent) const;
3636

37-
llvm::StringRef GetOutputString() {
37+
llvm::StringRef GetOutputString() const {
3838
lldb::StreamSP stream_sp(m_out_stream.GetStreamAtIndex(eStreamStringIndex));
3939
if (stream_sp)
4040
return std::static_pointer_cast<StreamString>(stream_sp)->GetString();
@@ -46,7 +46,7 @@ class CommandReturnObject {
4646
/// If \c with_diagnostics is true, all diagnostics are also
4747
/// rendered into the string. Otherwise the expectation is that they
4848
/// are fetched with \ref GetInlineDiagnosticString().
49-
std::string GetErrorString(bool with_diagnostics = true);
49+
std::string GetErrorString(bool with_diagnostics = true) const;
5050
StructuredData::ObjectSP GetErrorData();
5151

5252
Stream &GetOutputStream() {
@@ -95,11 +95,11 @@ class CommandReturnObject {
9595
m_err_stream.SetStreamAtIndex(eImmediateStreamIndex, stream_sp);
9696
}
9797

98-
lldb::StreamSP GetImmediateOutputStream() {
98+
lldb::StreamSP GetImmediateOutputStream() const {
9999
return m_out_stream.GetStreamAtIndex(eImmediateStreamIndex);
100100
}
101101

102-
lldb::StreamSP GetImmediateErrorStream() {
102+
lldb::StreamSP GetImmediateErrorStream() const {
103103
return m_err_stream.GetStreamAtIndex(eImmediateStreamIndex);
104104
}
105105

lldb/include/lldb/Utility/StreamTee.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class StreamTee : public Stream {
8585
return result;
8686
}
8787

88-
lldb::StreamSP GetStreamAtIndex(uint32_t idx) {
88+
lldb::StreamSP GetStreamAtIndex(uint32_t idx) const {
8989
lldb::StreamSP stream_sp;
9090
std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
9191
if (idx < m_streams.size())

lldb/source/Interpreter/CommandReturnObject.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ void CommandReturnObject::SetError(llvm::Error error) {
147147
}
148148
}
149149

150-
std::string CommandReturnObject::GetInlineDiagnosticString(unsigned indent) {
150+
std::string
151+
CommandReturnObject::GetInlineDiagnosticString(unsigned indent) const {
151152
StreamString diag_stream(m_colors);
152153
RenderDiagnosticDetails(diag_stream, indent, true, m_diagnostics);
153154
// Duplex the diagnostics to the secondary stream (but not inlined).
@@ -157,7 +158,7 @@ std::string CommandReturnObject::GetInlineDiagnosticString(unsigned indent) {
157158
return diag_stream.GetString().str();
158159
}
159160

160-
std::string CommandReturnObject::GetErrorString(bool with_diagnostics) {
161+
std::string CommandReturnObject::GetErrorString(bool with_diagnostics) const {
161162
StreamString stream(m_colors);
162163
if (with_diagnostics)
163164
RenderDiagnosticDetails(stream, std::nullopt, false, m_diagnostics);

0 commit comments

Comments
 (0)