[Lldb-commits] [lldb] r302875 - Update StructuredData::String to return StringRefs.

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Thu May 11 22:49:55 PDT 2017


Author: zturner
Date: Fri May 12 00:49:54 2017
New Revision: 302875

URL: http://llvm.org/viewvc/llvm-project?rev=302875&view=rev
Log:
Update StructuredData::String to return StringRefs.

It was returning const std::string& which was leading to
unnecessary copies all over the place, and preventing people
from doing things like Dict->GetValueForKeyAsString("foo", ref);

Modified:
    lldb/trunk/include/lldb/Breakpoint/Breakpoint.h
    lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h
    lldb/trunk/include/lldb/Core/SearchFilter.h
    lldb/trunk/include/lldb/Core/StructuredData.h
    lldb/trunk/include/lldb/Target/ThreadSpec.h
    lldb/trunk/include/lldb/Utility/UUID.h
    lldb/trunk/source/API/SBThread.cpp
    lldb/trunk/source/Breakpoint/Breakpoint.cpp
    lldb/trunk/source/Breakpoint/BreakpointOptions.cpp
    lldb/trunk/source/Breakpoint/BreakpointResolver.cpp
    lldb/trunk/source/Breakpoint/BreakpointResolverAddress.cpp
    lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
    lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp
    lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
    lldb/trunk/source/Core/FormatEntity.cpp
    lldb/trunk/source/Core/SearchFilter.cpp
    lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
    lldb/trunk/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp
    lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
    lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
    lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
    lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.cpp
    lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.h
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
    lldb/trunk/source/Target/Process.cpp
    lldb/trunk/source/Target/Thread.cpp
    lldb/trunk/source/Target/ThreadSpec.cpp
    lldb/trunk/source/Utility/UUID.cpp

Modified: lldb/trunk/include/lldb/Breakpoint/Breakpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/Breakpoint.h?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/Breakpoint.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/Breakpoint.h Fri May 12 00:49:54 2017
@@ -613,7 +613,7 @@ public:
 
   lldb::SearchFilterSP GetSearchFilter() { return m_filter_sp; }
 
-  bool AddName(const char *new_name, Status &error);
+  bool AddName(llvm::StringRef new_name, Status &error);
 
   void RemoveName(const char *name_to_remove) {
     if (name_to_remove)

Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h Fri May 12 00:49:54 2017
@@ -192,7 +192,7 @@ public:
 
   static const char *ResolverTyToName(enum ResolverTy);
 
-  static ResolverTy NameToResolverTy(const char *name);
+  static ResolverTy NameToResolverTy(llvm::StringRef name);
 
   virtual lldb::BreakpointResolverSP
   CopyForBreakpoint(Breakpoint &breakpoint) = 0;

Modified: lldb/trunk/include/lldb/Core/SearchFilter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/SearchFilter.h?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/SearchFilter.h (original)
+++ lldb/trunk/include/lldb/Core/SearchFilter.h Fri May 12 00:49:54 2017
@@ -285,7 +285,7 @@ public:
 
   static const char *FilterTyToName(enum FilterTy);
 
-  static FilterTy NameToFilterTy(const char *name);
+  static FilterTy NameToFilterTy(llvm::StringRef name);
 
 protected:
   // Serialization of SearchFilter options:

Modified: lldb/trunk/include/lldb/Core/StructuredData.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StructuredData.h?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/StructuredData.h (original)
+++ lldb/trunk/include/lldb/Core/StructuredData.h Fri May 12 00:49:54 2017
@@ -143,15 +143,12 @@ public:
                                             : nullptr);
     }
 
-    std::string GetStringValue(const char *fail_value = nullptr) {
+    llvm::StringRef GetStringValue(const char *fail_value = nullptr) {
       String *s = GetAsString();
       if (s)
         return s->GetValue();
 
-      if (fail_value && fail_value[0])
-        return std::string(fail_value);
-
-      return std::string();
+      return fail_value;
     }
 
     Generic *GetAsGeneric() {
@@ -220,7 +217,7 @@ public:
       return success;
     }
 
-    bool GetItemAtIndexAsString(size_t idx, std::string &result) const {
+    bool GetItemAtIndexAsString(size_t idx, llvm::StringRef &result) const {
       ObjectSP value_sp = GetItemAtIndex(idx);
       if (value_sp.get()) {
         if (auto string_value = value_sp->GetAsString()) {
@@ -231,8 +228,8 @@ public:
       return false;
     }
 
-    bool GetItemAtIndexAsString(size_t idx, std::string &result,
-                                const std::string &default_val) const {
+    bool GetItemAtIndexAsString(size_t idx, llvm::StringRef &result,
+                                llvm::StringRef default_val) const {
       bool success = GetItemAtIndexAsString(idx, result);
       if (!success)
         result = default_val;
@@ -339,18 +336,13 @@ public:
 
   class String : public Object {
   public:
-    String(const char *cstr = nullptr) : Object(Type::eTypeString), m_value() {
-      if (cstr)
-        m_value = cstr;
-    }
-
-    String(const std::string &s) : Object(Type::eTypeString), m_value(s) {}
-
-    String(const std::string &&s) : Object(Type::eTypeString), m_value(s) {}
+    String() : Object(Type::eTypeString) {}
+    explicit String(llvm::StringRef S)
+        : Object(Type::eTypeString), m_value(S) {}
 
-    void SetValue(const std::string &string) { m_value = string; }
+    void SetValue(llvm::StringRef S) { m_value = S; }
 
-    const std::string &GetValue() { return m_value; }
+    llvm::StringRef GetValue() { return m_value; }
 
     void Dump(Stream &s, bool pretty_print = true) const override;
 
@@ -430,7 +422,7 @@ public:
     }
 
     bool GetValueForKeyAsString(llvm::StringRef key,
-                                std::string &result) const {
+                                llvm::StringRef &result) const {
       ObjectSP value_sp = GetValueForKey(key);
       if (value_sp.get()) {
         if (auto string_value = value_sp->GetAsString()) {
@@ -441,14 +433,14 @@ public:
       return false;
     }
 
-    bool GetValueForKeyAsString(llvm::StringRef key, std::string &result,
+    bool GetValueForKeyAsString(llvm::StringRef key, llvm::StringRef &result,
                                 const char *default_val) const {
       bool success = GetValueForKeyAsString(key, result);
       if (!success) {
         if (default_val)
           result = default_val;
         else
-          result.clear();
+          result = llvm::StringRef();
       }
       return success;
     }
@@ -513,7 +505,7 @@ public:
       AddItem(key, std::make_shared<Float>(value));
     }
 
-    void AddStringItem(llvm::StringRef key, std::string value) {
+    void AddStringItem(llvm::StringRef key, llvm::StringRef value) {
       AddItem(key, std::make_shared<String>(std::move(value)));
     }
 

Modified: lldb/trunk/include/lldb/Target/ThreadSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadSpec.h?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ThreadSpec.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadSpec.h Fri May 12 00:49:54 2017
@@ -55,9 +55,9 @@ public:
 
   void SetTID(lldb::tid_t tid) { m_tid = tid; }
 
-  void SetName(const char *name) { m_name = name; }
+  void SetName(llvm::StringRef name) { m_name = name; }
 
-  void SetQueueName(const char *queue_name) { m_queue_name = queue_name; }
+  void SetQueueName(llvm::StringRef queue_name) { m_queue_name = queue_name; }
 
   uint32_t GetIndex() const { return m_index; }
 

Modified: lldb/trunk/include/lldb/Utility/UUID.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/UUID.h?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/UUID.h (original)
+++ lldb/trunk/include/lldb/Utility/UUID.h Fri May 12 00:49:54 2017
@@ -54,6 +54,7 @@ public:
 
   std::string GetAsString(const char *separator = nullptr) const;
 
+  size_t SetFromStringRef(llvm::StringRef str, uint32_t num_uuid_bytes = 16);
   size_t SetFromCString(const char *c_str, uint32_t num_uuid_bytes = 16);
 
   // Decode as many UUID bytes (up to 16) as possible from the C string "cstr"

Modified: lldb/trunk/source/API/SBThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThread.cpp (original)
+++ lldb/trunk/source/API/SBThread.cpp Fri May 12 00:49:54 2017
@@ -562,7 +562,7 @@ bool SBThread::GetInfoItemByPathAsString
             info_root_sp->GetObjectForDotSeparatedPath(path);
         if (node) {
           if (node->GetType() == StructuredData::Type::eTypeString) {
-            strm.Printf("%s", node->GetAsString()->GetValue().c_str());
+            strm.Printf("%s", node->GetAsString()->GetValue().str().c_str());
             success = true;
           }
           if (node->GetType() == StructuredData::Type::eTypeInteger) {

Modified: lldb/trunk/source/Breakpoint/Breakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Breakpoint.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/Breakpoint.cpp (original)
+++ lldb/trunk/source/Breakpoint/Breakpoint.cpp Fri May 12 00:49:54 2017
@@ -207,10 +207,10 @@ lldb::BreakpointSP Breakpoint::CreateFro
   if (success && names_array) {
     size_t num_names = names_array->GetSize();
     for (size_t i = 0; i < num_names; i++) {
-      std::string name;
+      llvm::StringRef name;
       Status error;
       success = names_array->GetItemAtIndexAsString(i, name);
-      result_sp->AddName(name.c_str(), error);
+      result_sp->AddName(name, error);
     }
   }
 
@@ -242,7 +242,7 @@ bool Breakpoint::SerializedBreakpointMat
   std::vector<std::string>::iterator end = names.end();
 
   for (size_t i = 0; i < num_names; i++) {
-    std::string name;
+    llvm::StringRef name;
     if (names_array->GetItemAtIndexAsString(i, name)) {
       if (std::find(begin, end, name) != end) {
         return true;
@@ -833,10 +833,10 @@ size_t Breakpoint::GetNumResolvedLocatio
 
 size_t Breakpoint::GetNumLocations() const { return m_locations.GetSize(); }
 
-bool Breakpoint::AddName(const char *new_name, Status &error) {
-  if (!new_name)
+bool Breakpoint::AddName(llvm::StringRef new_name, Status &error) {
+  if (new_name.empty())
     return false;
-  if (!BreakpointID::StringIsBreakpointName(llvm::StringRef(new_name), error)) {
+  if (!BreakpointID::StringIsBreakpointName(new_name, error)) {
     error.SetErrorStringWithFormat("input name \"%s\" not a breakpoint name.",
                                    new_name);
     return false;

Modified: lldb/trunk/source/Breakpoint/BreakpointOptions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointOptions.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointOptions.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointOptions.cpp Fri May 12 00:49:54 2017
@@ -73,7 +73,7 @@ BreakpointOptions::CommandData::CreateFr
   if (success)
     found_something = true;
 
-  std::string interpreter_str;
+  llvm::StringRef interpreter_str;
   ScriptLanguage interp_language;
   success = options_dict.GetValueForKeyAsString(
       GetKey(OptionNames::Interpreter), interpreter_str);
@@ -99,7 +99,7 @@ BreakpointOptions::CommandData::CreateFr
     found_something = true;
     size_t num_elems = user_source->GetSize();
     for (size_t i = 0; i < num_elems; i++) {
-      std::string elem_string;
+      llvm::StringRef elem_string;
       success = user_source->GetItemAtIndexAsString(i, elem_string);
       if (success)
         data_up->user_source.AppendString(elem_string);

Modified: lldb/trunk/source/Breakpoint/BreakpointResolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolver.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointResolver.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointResolver.cpp Fri May 12 00:49:54 2017
@@ -56,9 +56,9 @@ const char *BreakpointResolver::Resolver
 }
 
 BreakpointResolver::ResolverTy
-BreakpointResolver::NameToResolverTy(const char *name) {
+BreakpointResolver::NameToResolverTy(llvm::StringRef name) {
   for (size_t i = 0; i < LastKnownResolverType; i++) {
-    if (strcmp(name, g_ty_to_name[i]) == 0)
+    if (name == g_ty_to_name[i])
       return (ResolverTy)i;
   }
   return UnknownResolver;
@@ -79,7 +79,7 @@ BreakpointResolverSP BreakpointResolver:
     return result_sp;
   }
 
-  std::string subclass_name;
+  llvm::StringRef subclass_name;
 
   bool success = resolver_dict.GetValueForKeyAsString(
       GetSerializationSubclassKey(), subclass_name);
@@ -90,10 +90,10 @@ BreakpointResolverSP BreakpointResolver:
     return result_sp;
   }
 
-  ResolverTy resolver_type = NameToResolverTy(subclass_name.c_str());
+  ResolverTy resolver_type = NameToResolverTy(subclass_name);
   if (resolver_type == UnknownResolver) {
-    error.SetErrorStringWithFormat("Unknown resolver type: %s.",
-                                   subclass_name.c_str());
+    error.SetErrorStringWithFormatv("Unknown resolver type: {0}.",
+                                    subclass_name);
     return result_sp;
   }
 

Modified: lldb/trunk/source/Breakpoint/BreakpointResolverAddress.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverAddress.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointResolverAddress.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointResolverAddress.cpp Fri May 12 00:49:54 2017
@@ -45,7 +45,7 @@ BreakpointResolverAddress::~BreakpointRe
 BreakpointResolver *BreakpointResolverAddress::CreateFromStructuredData(
     Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
     Status &error) {
-  std::string module_name;
+  llvm::StringRef module_name;
   lldb::addr_t addr_offset;
   FileSpec module_filespec;
   bool success;

Modified: lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp Fri May 12 00:49:54 2017
@@ -39,7 +39,7 @@ BreakpointResolverFileLine::~BreakpointR
 BreakpointResolver *BreakpointResolverFileLine::CreateFromStructuredData(
     Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
     Status &error) {
-  std::string filename;
+  llvm::StringRef filename;
   uint32_t line_no;
   bool check_inlines;
   bool skip_prologue;

Modified: lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp Fri May 12 00:49:54 2017
@@ -40,7 +40,7 @@ BreakpointResolver *BreakpointResolverFi
     Status &error) {
   bool success;
 
-  std::string regex_string;
+  llvm::StringRef regex_string;
   success = options_dict.GetValueForKeyAsString(
       GetKey(OptionNames::RegexString), regex_string);
   if (!success) {
@@ -65,7 +65,7 @@ BreakpointResolver *BreakpointResolverFi
   if (success && names_array) {
     size_t num_names = names_array->GetSize();
     for (size_t i = 0; i < num_names; i++) {
-      std::string name;
+      llvm::StringRef name;
       success = names_array->GetItemAtIndexAsString(i, name);
       if (!success) {
         error.SetErrorStringWithFormat(

Modified: lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp Fri May 12 00:49:54 2017
@@ -94,14 +94,14 @@ BreakpointResolver *BreakpointResolverNa
     Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
     Status &error) {
   LanguageType language = eLanguageTypeUnknown;
-  std::string language_name;
+  llvm::StringRef language_name;
   bool success = options_dict.GetValueForKeyAsString(
       GetKey(OptionNames::LanguageName), language_name);
   if (success) {
     language = Language::GetLanguageTypeFromString(language_name);
     if (language == eLanguageTypeUnknown) {
-      error.SetErrorStringWithFormat("BRN::CFSD: Unknown language: %s.",
-                                     language_name.c_str());
+      error.SetErrorStringWithFormatv("BRN::CFSD: Unknown language: {0}.",
+                                      language_name);
       return nullptr;
     }
   }
@@ -122,7 +122,7 @@ BreakpointResolver *BreakpointResolverNa
     return nullptr;
   }
 
-  std::string regex_text;
+  llvm::StringRef regex_text;
   success = options_dict.GetValueForKeyAsString(
       GetKey(OptionNames::RegexString), regex_text);
   if (success) {
@@ -162,7 +162,7 @@ BreakpointResolver *BreakpointResolverNa
     std::vector<uint32_t> name_masks;
     for (size_t i = 0; i < num_elem; i++) {
       uint32_t name_mask;
-      std::string name;
+      llvm::StringRef name;
 
       success = names_array->GetItemAtIndexAsString(i, name);
       if (!success) {

Modified: lldb/trunk/source/Core/FormatEntity.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatEntity.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Core/FormatEntity.cpp (original)
+++ lldb/trunk/source/Core/FormatEntity.cpp Fri May 12 00:49:54 2017
@@ -1050,7 +1050,7 @@ static bool FormatThreadExtendedInfoRecu
       s.Printf("%f", value->GetAsFloat()->GetValue());
       return true;
     } else if (value->GetType() == StructuredData::Type::eTypeString) {
-      s.Printf("%s", value->GetAsString()->GetValue().c_str());
+      s.Format("{0}", value->GetAsString()->GetValue());
       return true;
     } else if (value->GetType() == StructuredData::Type::eTypeArray) {
       if (value->GetAsArray()->GetSize() > 0) {

Modified: lldb/trunk/source/Core/SearchFilter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/SearchFilter.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Core/SearchFilter.cpp (original)
+++ lldb/trunk/source/Core/SearchFilter.cpp Fri May 12 00:49:54 2017
@@ -55,9 +55,9 @@ const char *SearchFilter::FilterTyToName
   return g_ty_to_name[type];
 }
 
-SearchFilter::FilterTy SearchFilter::NameToFilterTy(const char *name) {
+SearchFilter::FilterTy SearchFilter::NameToFilterTy(llvm::StringRef name) {
   for (size_t i = 0; i <= LastKnownFilterType; i++) {
-    if (strcmp(name, g_ty_to_name[i]) == 0)
+    if (name == g_ty_to_name[i])
       return (FilterTy)i;
   }
   return UnknownFilter;
@@ -87,7 +87,7 @@ SearchFilterSP SearchFilter::CreateFromS
     return result_sp;
   }
 
-  std::string subclass_name;
+  llvm::StringRef subclass_name;
 
   bool success = filter_dict.GetValueForKeyAsString(
       GetSerializationSubclassKey(), subclass_name);
@@ -96,10 +96,9 @@ SearchFilterSP SearchFilter::CreateFromS
     return result_sp;
   }
 
-  FilterTy filter_type = NameToFilterTy(subclass_name.c_str());
+  FilterTy filter_type = NameToFilterTy(subclass_name);
   if (filter_type == UnknownFilter) {
-    error.SetErrorStringWithFormat("Unknown filter type: %s.",
-                                   subclass_name.c_str());
+    error.SetErrorStringWithFormatv("Unknown filter type: {0}.", subclass_name);
     return result_sp;
   }
 
@@ -484,7 +483,7 @@ SearchFilterSP SearchFilterByModule::Cre
     return nullptr;
   }
 
-  std::string module;
+  llvm::StringRef module;
   success = modules_array->GetItemAtIndexAsString(0, module);
   if (!success) {
     error.SetErrorString("SFBM::CFSD: filter module item not a string.");
@@ -639,7 +638,7 @@ SearchFilterSP SearchFilterByModuleList:
   if (success) {
     size_t num_modules = modules_array->GetSize();
     for (size_t i = 0; i < num_modules; i++) {
-      std::string module;
+      llvm::StringRef module;
       success = modules_array->GetItemAtIndexAsString(i, module);
       if (!success) {
         error.SetErrorStringWithFormat(
@@ -704,7 +703,7 @@ lldb::SearchFilterSP SearchFilterByModul
   if (success) {
     size_t num_modules = modules_array->GetSize();
     for (size_t i = 0; i < num_modules; i++) {
-      std::string module;
+      llvm::StringRef module;
       success = modules_array->GetItemAtIndexAsString(i, module);
       if (!success) {
         error.SetErrorStringWithFormat(
@@ -726,7 +725,7 @@ lldb::SearchFilterSP SearchFilterByModul
   size_t num_cus = cus_array->GetSize();
   FileSpecList cus;
   for (size_t i = 0; i < num_cus; i++) {
-    std::string cu;
+    llvm::StringRef cu;
     success = cus_array->GetItemAtIndexAsString(i, cu);
     if (!success) {
       error.SetErrorStringWithFormat(

Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp Fri May 12 00:49:54 2017
@@ -440,8 +440,8 @@ bool DynamicLoaderDarwin::JSONImageInfor
       Segment segment;
       StructuredData::Dictionary *seg =
           segments->GetItemAtIndex(j)->GetAsDictionary();
-      segment.name = ConstString(
-          seg->GetValueForKey("name")->GetAsString()->GetValue().c_str());
+      segment.name =
+          ConstString(seg->GetValueForKey("name")->GetAsString()->GetValue());
       segment.vmaddr =
           seg->GetValueForKey("vmaddr")->GetAsInteger()->GetValue();
       segment.vmsize =
@@ -478,8 +478,8 @@ bool DynamicLoaderDarwin::JSONImageInfor
       image_infos[i].segments.push_back(segment);
     }
 
-    image_infos[i].uuid.SetFromCString(
-        image->GetValueForKey("uuid")->GetAsString()->GetValue().c_str());
+    image_infos[i].uuid.SetFromStringRef(
+        image->GetValueForKey("uuid")->GetAsString()->GetValue());
 
     // All sections listed in the dyld image info structure will all
     // either be fixed up already, or they will all be off by a single

Modified: lldb/trunk/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp (original)
+++ lldb/trunk/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp Fri May 12 00:49:54 2017
@@ -340,8 +340,8 @@ bool OperatingSystemGo::UpdateThreadList
         memory_thread->IsValid()) {
       memory_thread->ClearBackingThread();
     } else {
-      memory_thread.reset(new ThreadMemory(
-          *m_process, goroutine.m_goid, nullptr, nullptr, goroutine.m_gobuf));
+      memory_thread.reset(new ThreadMemory(*m_process, goroutine.m_goid, "", "",
+                                           goroutine.m_gobuf));
     }
     // Search for the backing thread if the goroutine is running.
     if (2 == (goroutine.m_status & 0xfff)) {

Modified: lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp (original)
+++ lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp Fri May 12 00:49:54 2017
@@ -240,8 +240,8 @@ ThreadSP OperatingSystemPython::CreateTh
 
   uint32_t core_number;
   addr_t reg_data_addr;
-  std::string name;
-  std::string queue;
+  llvm::StringRef name;
+  llvm::StringRef queue;
 
   thread_dict.GetValueForKeyAsInteger("core", core_number, UINT32_MAX);
   thread_dict.GetValueForKeyAsInteger("register_data_addr", reg_data_addr,
@@ -266,8 +266,8 @@ ThreadSP OperatingSystemPython::CreateTh
   if (!thread_sp) {
     if (did_create_ptr)
       *did_create_ptr = true;
-    thread_sp.reset(new ThreadMemory(*m_process, tid, name.c_str(),
-                                     queue.c_str(), reg_data_addr));
+    thread_sp.reset(
+        new ThreadMemory(*m_process, tid, name, queue, reg_data_addr));
   }
 
   if (core_number < core_thread_list.GetSize(false)) {

Modified: lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp Fri May 12 00:49:54 2017
@@ -784,7 +784,7 @@ const UnixSignalsSP &PlatformRemoteGDBSe
         if (!dict->GetValueForKeyAsInteger("signo", signo))
           return false;
 
-        std::string name;
+        llvm::StringRef name;
         if (!dict->GetValueForKeyAsString("name", name))
           return false;
 
@@ -809,7 +809,7 @@ const UnixSignalsSP &PlatformRemoteGDBSe
         if (object_sp && object_sp->IsValid())
           description = object_sp->GetStringValue();
 
-        remote_signals_sp->AddSignal(signo, name.c_str(), suppress, stop,
+        remote_signals_sp->AddSignal(signo, name.str().c_str(), suppress, stop,
                                      notify, description.c_str());
         return true;
       });

Modified: lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp Fri May 12 00:49:54 2017
@@ -48,10 +48,10 @@ DynamicRegisterInfo::SetRegisterInfo(con
   if (dict.GetValueForKeyAsArray("sets", sets)) {
     const uint32_t num_sets = sets->GetSize();
     for (uint32_t i = 0; i < num_sets; ++i) {
-      std::string set_name_str;
+      llvm::StringRef set_name_str;
       ConstString set_name;
       if (sets->GetItemAtIndexAsString(i, set_name_str))
-        set_name.SetCString(set_name_str.c_str());
+        set_name.SetString(set_name_str);
       if (set_name) {
         RegisterSet new_set = {set_name.AsCString(), NULL, 0, NULL};
         m_sets.push_back(new_set);
@@ -115,7 +115,7 @@ DynamicRegisterInfo::SetRegisterInfo(con
       // expression
       // we can calculate the offset
       bool success = false;
-      std::string slice_str;
+      llvm::StringRef slice_str;
       if (reg_info_dict->GetValueForKeyAsString("slice", slice_str, nullptr)) {
         // Slices use the following format:
         //  REGNAME[MSBIT:LSBIT]
@@ -131,9 +131,9 @@ DynamicRegisterInfo::SetRegisterInfo(con
           llvm::StringRef reg_name_str;
           std::string msbit_str;
           std::string lsbit_str;
-          if (regex_match.GetMatchAtIndex(slice_str.c_str(), 1, reg_name_str) &&
-              regex_match.GetMatchAtIndex(slice_str.c_str(), 2, msbit_str) &&
-              regex_match.GetMatchAtIndex(slice_str.c_str(), 3, lsbit_str)) {
+          if (regex_match.GetMatchAtIndex(slice_str, 1, reg_name_str) &&
+              regex_match.GetMatchAtIndex(slice_str, 2, msbit_str) &&
+              regex_match.GetMatchAtIndex(slice_str, 3, lsbit_str)) {
             const uint32_t msbit =
                 StringConvert::ToUInt32(msbit_str.c_str(), UINT32_MAX);
             const uint32_t lsbit =
@@ -269,17 +269,15 @@ DynamicRegisterInfo::SetRegisterInfo(con
 
     reg_info.byte_size = bitsize / 8;
 
-    std::string dwarf_opcode_string;
+    llvm::StringRef dwarf_opcode_string;
     if (reg_info_dict->GetValueForKeyAsString("dynamic_size_dwarf_expr_bytes",
                                               dwarf_opcode_string)) {
-      reg_info.dynamic_size_dwarf_len = dwarf_opcode_string.length() / 2;
+      reg_info.dynamic_size_dwarf_len = dwarf_opcode_string.size() / 2;
       assert(reg_info.dynamic_size_dwarf_len > 0);
 
       std::vector<uint8_t> dwarf_opcode_bytes(reg_info.dynamic_size_dwarf_len);
       uint32_t j;
-      StringExtractor opcode_extractor;
-      // Swap "dwarf_opcode_string" over into "opcode_extractor"
-      opcode_extractor.GetStringRef().swap(dwarf_opcode_string);
+      StringExtractor opcode_extractor(dwarf_opcode_string);
       uint32_t ret_val = opcode_extractor.GetHexBytesAvail(dwarf_opcode_bytes);
       UNUSED_IF_ASSERT_DISABLED(ret_val);
       assert(ret_val == reg_info.dynamic_size_dwarf_len);
@@ -290,9 +288,9 @@ DynamicRegisterInfo::SetRegisterInfo(con
       reg_info.dynamic_size_dwarf_expr_bytes = m_dynamic_reg_size_map[i].data();
     }
 
-    std::string format_str;
+    llvm::StringRef format_str;
     if (reg_info_dict->GetValueForKeyAsString("format", format_str, nullptr)) {
-      if (Args::StringToFormat(format_str.c_str(), reg_info.format, NULL)
+      if (Args::StringToFormat(format_str.str().c_str(), reg_info.format, NULL)
               .Fail()) {
         Clear();
         printf("error: invalid 'format' value in register dictionary\n");
@@ -304,7 +302,7 @@ DynamicRegisterInfo::SetRegisterInfo(con
                                              eFormatHex);
     }
 
-    std::string encoding_str;
+    llvm::StringRef encoding_str;
     if (reg_info_dict->GetValueForKeyAsString("encoding", encoding_str))
       reg_info.encoding = Args::StringToEncoding(encoding_str, eEncodingUint);
     else
@@ -334,7 +332,7 @@ DynamicRegisterInfo::SetRegisterInfo(con
     reg_info.kinds[lldb::eRegisterKindEHFrame] = eh_frame_regno;
     reg_info_dict->GetValueForKeyAsInteger(
         "dwarf", reg_info.kinds[lldb::eRegisterKindDWARF], LLDB_INVALID_REGNUM);
-    std::string generic_str;
+    llvm::StringRef generic_str;
     if (reg_info_dict->GetValueForKeyAsString("generic", generic_str))
       reg_info.kinds[lldb::eRegisterKindGeneric] =
           Args::StringToGenericRegister(generic_str);

Modified: lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.cpp Fri May 12 00:49:54 2017
@@ -24,15 +24,11 @@ ThreadMemory::ThreadMemory(Process &proc
     : Thread(process, tid), m_backing_thread_sp(),
       m_thread_info_valobj_sp(thread_info_valobj_sp), m_name(), m_queue() {}
 
-ThreadMemory::ThreadMemory(Process &process, lldb::tid_t tid, const char *name,
-                           const char *queue, lldb::addr_t register_data_addr)
+ThreadMemory::ThreadMemory(Process &process, lldb::tid_t tid,
+                           llvm::StringRef name, llvm::StringRef queue,
+                           lldb::addr_t register_data_addr)
     : Thread(process, tid), m_backing_thread_sp(), m_thread_info_valobj_sp(),
-      m_name(), m_queue(), m_register_data_addr(register_data_addr) {
-  if (name)
-    m_name = name;
-  if (queue)
-    m_queue = queue;
-}
+      m_name(name), m_queue(queue), m_register_data_addr(register_data_addr) {}
 
 ThreadMemory::~ThreadMemory() { DestroyThread(); }
 

Modified: lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.h?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.h Fri May 12 00:49:54 2017
@@ -24,7 +24,7 @@ public:
                const lldb::ValueObjectSP &thread_info_valobj_sp);
 
   ThreadMemory(lldb_private::Process &process, lldb::tid_t tid,
-               const char *name, const char *queue,
+               llvm::StringRef name, llvm::StringRef queue,
                lldb::addr_t register_data_addr);
 
   ~ThreadMemory() override;

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Fri May 12 00:49:54 2017
@@ -3224,12 +3224,12 @@ ParseModuleSpec(StructuredData::Dictiona
   if (!dict)
     return llvm::None;
 
-  std::string string;
+  llvm::StringRef string;
   uint64_t integer;
 
   if (!dict->GetValueForKeyAsString("uuid", string))
     return llvm::None;
-  result.GetUUID().SetFromCString(string.c_str(), string.size());
+  result.GetUUID().SetFromStringRef(string, string.size());
 
   if (!dict->GetValueForKeyAsInteger("file_offset", integer))
     return llvm::None;
@@ -3241,7 +3241,7 @@ ParseModuleSpec(StructuredData::Dictiona
 
   if (!dict->GetValueForKeyAsString("triple", string))
     return llvm::None;
-  result.GetArchitecture().SetTriple(string.c_str());
+  result.GetArchitecture().SetTriple(string);
 
   if (!dict->GetValueForKeyAsString("file_path", string))
     return llvm::None;

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp Fri May 12 00:49:54 2017
@@ -1140,7 +1140,7 @@ GDBRemoteCommunicationServerCommon::Hand
         packet_array->GetItemAtIndex(i)->GetAsDictionary();
     if (!query)
       continue;
-    std::string file, triple;
+    llvm::StringRef file, triple;
     if (!query->GetValueForKeyAsString("file", file) ||
         !query->GetValueForKeyAsString("triple", triple))
       continue;
@@ -1278,9 +1278,10 @@ FileSpec GDBRemoteCommunicationServerCom
 #endif
 }
 
-ModuleSpec GDBRemoteCommunicationServerCommon::GetModuleInfo(
-    const std::string &module_path, const std::string &triple) {
-  ArchSpec arch(triple.c_str());
+ModuleSpec
+GDBRemoteCommunicationServerCommon::GetModuleInfo(llvm::StringRef module_path,
+                                                  llvm::StringRef triple) {
+  ArchSpec arch(triple);
 
   const FileSpec req_module_path_spec(module_path, true);
   const FileSpec module_path_spec =

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h Fri May 12 00:49:54 2017
@@ -153,8 +153,7 @@ protected:
                                   const ArchSpec &arch);
 
 private:
-  ModuleSpec GetModuleInfo(const std::string &module_path,
-                           const std::string &triple);
+  ModuleSpec GetModuleInfo(llvm::StringRef module_path, llvm::StringRef triple);
 };
 
 } // namespace process_gdb_remote

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri May 12 00:49:54 2017
@@ -2113,9 +2113,9 @@ ProcessGDBRemote::SetThreadStopInfo(Stru
             if (mem_cache_dict->GetValueForKeyAsInteger<lldb::addr_t>(
                     "address", mem_cache_addr)) {
               if (mem_cache_addr != LLDB_INVALID_ADDRESS) {
-                StringExtractor bytes;
-                if (mem_cache_dict->GetValueForKeyAsString(
-                        "bytes", bytes.GetStringRef())) {
+                llvm::StringRef str;
+                if (mem_cache_dict->GetValueForKeyAsString("bytes", str)) {
+                  StringExtractor bytes(str);
                   bytes.SetFilePos(0);
 
                   const size_t byte_size = bytes.GetStringRef().size() / 2;

Modified: lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp (original)
+++ lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp Fri May 12 00:49:54 2017
@@ -1817,7 +1817,7 @@ StructuredDataDarwinLog::DumpHeader(Stre
   }
 
   if (options_sp->GetDisplayActivityChain()) {
-    std::string activity_chain;
+    llvm::StringRef activity_chain;
     if (event.GetValueForKeyAsString("activity-chain", activity_chain) &&
         !activity_chain.empty()) {
       if (header_count > 0)
@@ -1856,7 +1856,7 @@ StructuredDataDarwinLog::DumpHeader(Stre
   }
 
   if (options_sp->GetDisplaySubsystem()) {
-    std::string subsystem;
+    llvm::StringRef subsystem;
     if (event.GetValueForKeyAsString("subsystem", subsystem) &&
         !subsystem.empty()) {
       if (header_count > 0)
@@ -1868,7 +1868,7 @@ StructuredDataDarwinLog::DumpHeader(Stre
   }
 
   if (options_sp->GetDisplayCategory()) {
-    std::string category;
+    llvm::StringRef category;
     if (event.GetValueForKeyAsString("category", category) &&
         !category.empty()) {
       if (header_count > 0)
@@ -1901,16 +1901,16 @@ size_t StructuredDataDarwinLog::HandleDi
   size_t total_bytes = 0;
 
   // Grab the message content.
-  std::string message;
+  llvm::StringRef message;
   if (!event.GetValueForKeyAsString("message", message))
     return true;
 
   // Display the log entry.
-  const auto len = message.length();
+  const auto len = message.size();
 
   total_bytes += DumpHeader(stream, event);
 
-  stream.Write(message.c_str(), len);
+  stream.Write(message.data(), len);
   total_bytes += len;
 
   // Add an end of line.

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Fri May 12 00:49:54 2017
@@ -6162,8 +6162,7 @@ void Process::MapSupportedStructuredData
         }
 
         const_type_names.insert(ConstString(type_name->GetValue()));
-        if (log)
-          log->Printf("- %s", type_name->GetValue().c_str());
+        LLDB_LOG(log, "- {0}", type_name->GetValue());
         return true;
       });
 

Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Fri May 12 00:49:54 2017
@@ -2001,8 +2001,8 @@ bool Thread::GetDescription(Stream &strm
       StructuredData::ObjectSP name = activity_dict->GetValueForKey("name");
       if (name && name->GetType() == StructuredData::Type::eTypeString && id &&
           id->GetType() == StructuredData::Type::eTypeInteger) {
-        strm.Printf("  Activity '%s', 0x%" PRIx64 "\n",
-                    name->GetAsString()->GetValue().c_str(),
+        strm.Format("  Activity '{0}', {1:x}\n",
+                    name->GetAsString()->GetValue(),
                     id->GetAsInteger()->GetValue());
       }
       printed_activity = true;
@@ -2018,8 +2018,8 @@ bool Thread::GetDescription(Stream &strm
           breadcrumb_dict->GetValueForKey("name");
       if (breadcrumb_text &&
           breadcrumb_text->GetType() == StructuredData::Type::eTypeString) {
-        strm.Printf("  Current Breadcrumb: %s\n",
-                    breadcrumb_text->GetAsString()->GetValue().c_str());
+        strm.Format("  Current Breadcrumb: {0}\n",
+                    breadcrumb_text->GetAsString()->GetValue());
       }
       printed_breadcrumb = true;
     }
@@ -2040,8 +2040,7 @@ bool Thread::GetDescription(Stream &strm
                 message_dict->GetValueForKey("message");
             if (message_text &&
                 message_text->GetType() == StructuredData::Type::eTypeString) {
-              strm.Printf("    %s\n",
-                          message_text->GetAsString()->GetValue().c_str());
+              strm.Format("    {0}\n", message_text->GetAsString()->GetValue());
             }
           }
         }

Modified: lldb/trunk/source/Target/ThreadSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadSpec.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadSpec.cpp (original)
+++ lldb/trunk/source/Target/ThreadSpec.cpp Fri May 12 00:49:54 2017
@@ -42,8 +42,8 @@ std::unique_ptr<ThreadSpec> ThreadSpec::
     const StructuredData::Dictionary &spec_dict, Status &error) {
   uint32_t index = UINT32_MAX;
   lldb::tid_t tid = LLDB_INVALID_THREAD_ID;
-  std::string name;
-  std::string queue_name;
+  llvm::StringRef name;
+  llvm::StringRef queue_name;
 
   std::unique_ptr<ThreadSpec> thread_spec_up(new ThreadSpec());
   bool success = spec_dict.GetValueForKeyAsInteger(
@@ -59,12 +59,12 @@ std::unique_ptr<ThreadSpec> ThreadSpec::
   success =
       spec_dict.GetValueForKeyAsString(GetKey(OptionNames::ThreadName), name);
   if (success)
-    thread_spec_up->SetName(name.c_str());
+    thread_spec_up->SetName(name);
 
   success = spec_dict.GetValueForKeyAsString(GetKey(OptionNames::ThreadName),
                                              queue_name);
   if (success)
-    thread_spec_up->SetQueueName(queue_name.c_str());
+    thread_spec_up->SetQueueName(queue_name);
 
   return thread_spec_up;
 }

Modified: lldb/trunk/source/Utility/UUID.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/UUID.cpp?rev=302875&r1=302874&r2=302875&view=diff
==============================================================================
--- lldb/trunk/source/Utility/UUID.cpp (original)
+++ lldb/trunk/source/Utility/UUID.cpp Fri May 12 00:49:54 2017
@@ -160,12 +160,9 @@ llvm::StringRef UUID::DecodeUUIDBytesFro
   bytes_decoded = uuid_byte_idx;
   return p;
 }
-size_t UUID::SetFromCString(const char *cstr, uint32_t num_uuid_bytes) {
-  if (cstr == NULL)
-    return 0;
 
-  llvm::StringRef orig(cstr);
-  llvm::StringRef p = orig;
+size_t UUID::SetFromStringRef(llvm::StringRef str, uint32_t num_uuid_bytes) {
+  llvm::StringRef p = str;
 
   // Skip leading whitespace characters
   p = p.ltrim();
@@ -178,12 +175,19 @@ size_t UUID::SetFromCString(const char *
   // were consumed
   if (bytes_decoded == num_uuid_bytes) {
     m_num_uuid_bytes = num_uuid_bytes;
-    return orig.size() - rest.size();
+    return str.size() - rest.size();
   }
 
   // Else return zero to indicate we were not able to parse a UUID value
   return 0;
 }
+
+size_t UUID::SetFromCString(const char *cstr, uint32_t num_uuid_bytes) {
+  if (cstr == NULL)
+    return 0;
+
+  return SetFromStringRef(cstr, num_uuid_bytes);
+}
 }
 
 bool lldb_private::operator==(const lldb_private::UUID &lhs,




More information about the lldb-commits mailing list