From 0e4c482124f098957fc13bcfbabc36775dd190ab Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Wed, 6 Mar 2019 21:22:25 +0000 Subject: Pass ConstString by value (NFC) My apologies for the large patch. With the exception of ConstString.h itself it was entirely produced by sed. ConstString has exactly one const char * data member, so passing a ConstString by reference is not any more efficient than copying it by value. In both cases a single pointer is passed. But passing it by value makes it harder to accidentally return the address of a local object. (This fixes rdar://problem/48640859 for the Apple folks) Differential Revision: https://reviews.llvm.org/D59030 llvm-svn: 355553 --- lldb/source/Breakpoint/Breakpoint.cpp | 8 ++++---- lldb/source/Breakpoint/BreakpointName.cpp | 2 +- lldb/source/Breakpoint/BreakpointResolverName.cpp | 2 +- lldb/source/Breakpoint/Watchpoint.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'lldb/source/Breakpoint') diff --git a/lldb/source/Breakpoint/Breakpoint.cpp b/lldb/source/Breakpoint/Breakpoint.cpp index 1232b6e21e9..d6cbe3ff86e 100644 --- a/lldb/source/Breakpoint/Breakpoint.cpp +++ b/lldb/source/Breakpoint/Breakpoint.cpp @@ -35,7 +35,7 @@ using namespace lldb; using namespace lldb_private; using namespace llvm; -const ConstString &Breakpoint::GetEventIdentifier() { +ConstString Breakpoint::GetEventIdentifier() { static ConstString g_identifier("event-identifier.breakpoint.changed"); return g_identifier; } @@ -972,7 +972,7 @@ void Breakpoint::GetResolverDescription(Stream *s) { m_resolver_sp->GetDescription(s); } -bool Breakpoint::GetMatchingFileLine(const ConstString &filename, +bool Breakpoint::GetMatchingFileLine(ConstString filename, uint32_t line_number, BreakpointLocationCollection &loc_coll) { // TODO: To be correct, this method needs to fill the breakpoint location @@ -1048,12 +1048,12 @@ Breakpoint::BreakpointEventData::BreakpointEventData( Breakpoint::BreakpointEventData::~BreakpointEventData() = default; -const ConstString &Breakpoint::BreakpointEventData::GetFlavorString() { +ConstString Breakpoint::BreakpointEventData::GetFlavorString() { static ConstString g_flavor("Breakpoint::BreakpointEventData"); return g_flavor; } -const ConstString &Breakpoint::BreakpointEventData::GetFlavor() const { +ConstString Breakpoint::BreakpointEventData::GetFlavor() const { return BreakpointEventData::GetFlavorString(); } diff --git a/lldb/source/Breakpoint/BreakpointName.cpp b/lldb/source/Breakpoint/BreakpointName.cpp index 46d877c2f0d..b822e3b9d96 100644 --- a/lldb/source/Breakpoint/BreakpointName.cpp +++ b/lldb/source/Breakpoint/BreakpointName.cpp @@ -28,7 +28,7 @@ const Flags::ValueType BreakpointName::Permissions::permissions_mask (0x5u) }; -BreakpointName::BreakpointName(const ConstString &name, const Breakpoint &bkpt, +BreakpointName::BreakpointName(ConstString name, const Breakpoint &bkpt, const char *help) : m_name(name), m_options(bkpt.GetOptions()) { diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp b/lldb/source/Breakpoint/BreakpointResolverName.cpp index 7c9fa8b77fa..0ffa5029b0d 100644 --- a/lldb/source/Breakpoint/BreakpointResolverName.cpp +++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp @@ -217,7 +217,7 @@ StructuredData::ObjectSP BreakpointResolverName::SerializeToStructuredData() { return WrapOptionsDict(options_dict_sp); } -void BreakpointResolverName::AddNameLookup(const ConstString &name, +void BreakpointResolverName::AddNameLookup(ConstString name, FunctionNameType name_type_mask) { ObjCLanguage::MethodName objc_method(name.GetCString(), false); if (objc_method.IsValid(false)) { diff --git a/lldb/source/Breakpoint/Watchpoint.cpp b/lldb/source/Breakpoint/Watchpoint.cpp index 6481ad1a714..e8a926527d2 100644 --- a/lldb/source/Breakpoint/Watchpoint.cpp +++ b/lldb/source/Breakpoint/Watchpoint.cpp @@ -325,12 +325,12 @@ Watchpoint::WatchpointEventData::WatchpointEventData( Watchpoint::WatchpointEventData::~WatchpointEventData() = default; -const ConstString &Watchpoint::WatchpointEventData::GetFlavorString() { +ConstString Watchpoint::WatchpointEventData::GetFlavorString() { static ConstString g_flavor("Watchpoint::WatchpointEventData"); return g_flavor; } -const ConstString &Watchpoint::WatchpointEventData::GetFlavor() const { +ConstString Watchpoint::WatchpointEventData::GetFlavor() const { return WatchpointEventData::GetFlavorString(); } -- cgit v1.2.3