Skip to content

Commit bca378f

Browse files
committed
[lldb][NFC] Overload raw_ostream operator << for ConstString
Summary: We are not doing this very often, but sometimes it's convenient when I can just << ConstStrings into llvm::errs() during testing. Reviewers: labath, JDevlieghere Reviewed By: labath, JDevlieghere Subscribers: JDevlieghere Differential Revision: https://reviews.llvm.org/D80310
1 parent cd921ac commit bca378f

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

lldb/include/lldb/Utility/ConstString.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,11 @@ template <> struct ScalarTraits<lldb_private::ConstString> {
490490
static QuotingType mustQuote(StringRef S) { return QuotingType::Double; }
491491
};
492492
} // namespace yaml
493+
494+
inline raw_ostream &operator<<(raw_ostream &os, lldb_private::ConstString s) {
495+
os << s.GetStringRef();
496+
return os;
497+
}
493498
} // namespace llvm
494499

495500
LLVM_YAML_IS_SEQUENCE_VECTOR(lldb_private::ConstString)

lldb/source/Core/Section.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ void Section::DumpName(llvm::raw_ostream &s) const {
337337
if (name && name[0])
338338
s << name << '.';
339339
}
340-
s << m_name.GetStringRef();
340+
s << m_name;
341341
}
342342

343343
bool Section::IsDescendant(const Section *section) {

lldb/source/Symbol/Function.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,9 @@ void Function::GetDescription(Stream *s, lldb::DescriptionLevel level,
374374

375375
*s << "id = " << (const UserID &)*this;
376376
if (name)
377-
*s << ", name = \"" << name.GetCString() << '"';
377+
s->AsRawOstream() << ", name = \"" << name << '"';
378378
if (mangled)
379-
*s << ", mangled = \"" << mangled.GetCString() << '"';
379+
s->AsRawOstream() << ", mangled = \"" << mangled << '"';
380380
*s << ", range = ";
381381
Address::DumpStyle fallback_style;
382382
if (level == eDescriptionLevelVerbose)

0 commit comments

Comments
 (0)