Skip to content

Commit 170b552

Browse files
authored
[lldb] Scalar::GetValue() should take a Stream by reference (#69231)
This function always expects the pointer to be valid, a reference seems more appropriate.
1 parent 5990850 commit 170b552

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

lldb/include/lldb/Utility/Scalar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class Scalar {
101101

102102
const char *GetTypeAsCString() const { return GetValueTypeAsCString(m_type); }
103103

104-
void GetValue(Stream *s, bool show_type) const;
104+
void GetValue(Stream &s, bool show_type) const;
105105

106106
bool IsValid() const { return (m_type >= e_int) && (m_type <= e_float); }
107107

lldb/source/Core/Value.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ void Value::AppendBytes(const void *bytes, int len) {
9898
}
9999

100100
void Value::Dump(Stream *strm) {
101-
m_value.GetValue(strm, true);
101+
if (!strm)
102+
return;
103+
m_value.GetValue(*strm, true);
102104
strm->Printf(", value_type = %s, context = %p, context_type = %s",
103105
Value::GetValueTypeAsCString(m_value_type), m_context,
104106
Value::GetContextTypeAsCString(m_context_type));

lldb/source/Interpreter/CommandInterpreter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1773,7 +1773,7 @@ CommandInterpreter::PreprocessToken(std::string &expr_str) {
17731773

17741774
StreamString value_strm;
17751775
const bool show_type = false;
1776-
scalar.GetValue(&value_strm, show_type);
1776+
scalar.GetValue(value_strm, show_type);
17771777
size_t value_string_size = value_strm.GetSize();
17781778
if (value_string_size) {
17791779
expr_str = value_strm.GetData();

lldb/source/Utility/Scalar.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,20 +153,20 @@ bool Scalar::IsZero() const {
153153
return false;
154154
}
155155

156-
void Scalar::GetValue(Stream *s, bool show_type) const {
156+
void Scalar::GetValue(Stream &s, bool show_type) const {
157157
if (show_type)
158-
s->Printf("(%s) ", GetTypeAsCString());
158+
s.Printf("(%s) ", GetTypeAsCString());
159159

160160
switch (m_type) {
161161
case e_void:
162162
break;
163163
case e_int:
164-
s->PutCString(llvm::toString(m_integer, 10));
164+
s.PutCString(llvm::toString(m_integer, 10));
165165
break;
166166
case e_float:
167167
llvm::SmallString<24> string;
168168
m_float.toString(string);
169-
s->PutCString(string);
169+
s.PutCString(string);
170170
break;
171171
}
172172
}
@@ -894,6 +894,6 @@ bool Scalar::SetBit(uint32_t bit) {
894894

895895
llvm::raw_ostream &lldb_private::operator<<(llvm::raw_ostream &os, const Scalar &scalar) {
896896
StreamString s;
897-
scalar.GetValue(&s, /*show_type*/ true);
897+
scalar.GetValue(s, /*show_type*/ true);
898898
return os << s.GetString();
899899
}

lldb/unittests/Utility/ScalarTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ TEST(ScalarTest, ExtractBitfield) {
241241

242242
template <typename T> static std::string ScalarGetValue(T value) {
243243
StreamString stream;
244-
Scalar(value).GetValue(&stream, false);
244+
Scalar(value).GetValue(stream, false);
245245
return std::string(stream.GetString());
246246
}
247247

0 commit comments

Comments
 (0)