Make llvm::StringRef to std::string conversions explicit.
This is how it should've been and brings it more in line with
std::string_view. There should be no functional change here.
This is mostly mechanical from a custom clang-tidy check, with a lot of
manual fixups. It uncovers a lot of minor inefficiencies.
This doesn't actually modify StringRef yet, I'll do that in a follow-up.
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index f6f2203..4940564 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -383,9 +383,10 @@
mh->GetValueForKey("filetype")->GetAsInteger()->GetValue();
if (image->HasKey("min_version_os_name")) {
- std::string os_name = image->GetValueForKey("min_version_os_name")
- ->GetAsString()
- ->GetValue();
+ std::string os_name =
+ std::string(image->GetValueForKey("min_version_os_name")
+ ->GetAsString()
+ ->GetValue());
if (os_name == "macosx")
image_infos[i].os_type = llvm::Triple::MacOSX;
else if (os_name == "ios" || os_name == "iphoneos")
@@ -403,9 +404,9 @@
}
if (image->HasKey("min_version_os_sdk")) {
image_infos[i].min_version_os_sdk =
- image->GetValueForKey("min_version_os_sdk")
- ->GetAsString()
- ->GetValue();
+ std::string(image->GetValueForKey("min_version_os_sdk")
+ ->GetAsString()
+ ->GetValue());
}
// Fields that aren't used by DynamicLoaderDarwin so debugserver doesn't
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
index 1563279..a9e674e 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
@@ -481,8 +481,8 @@
info_dict->HasKey("shared_cache_base_address")) {
base_address = info_dict->GetValueForKey("shared_cache_base_address")
->GetIntegerValue(LLDB_INVALID_ADDRESS);
- std::string uuid_str =
- info_dict->GetValueForKey("shared_cache_uuid")->GetStringValue();
+ std::string uuid_str = std::string(
+ info_dict->GetValueForKey("shared_cache_uuid")->GetStringValue());
if (!uuid_str.empty())
uuid.SetFromStringRef(uuid_str);
if (!info_dict->GetValueForKey("no_shared_cache")->GetBooleanValue())