diff --git a/lldb/include/lldb/Utility/StructuredData.h b/lldb/include/lldb/Utility/StructuredData.h --- a/lldb/include/lldb/Utility/StructuredData.h +++ b/lldb/include/lldb/Utility/StructuredData.h @@ -536,26 +536,6 @@ return success; } - bool GetValueForKeyAsString(llvm::StringRef key, - ConstString &result) const { - ObjectSP value_sp = GetValueForKey(key); - if (value_sp.get()) { - if (auto string_value = value_sp->GetAsString()) { - result = ConstString(string_value->GetValue()); - return true; - } - } - return false; - } - - bool GetValueForKeyAsString(llvm::StringRef key, ConstString &result, - const char *default_val) const { - bool success = GetValueForKeyAsString(key, result); - if (!success) - result.SetCString(default_val); - return success; - } - bool GetValueForKeyAsDictionary(llvm::StringRef key, Dictionary *&result) const { result = nullptr; diff --git a/lldb/source/Target/DynamicRegisterInfo.cpp b/lldb/source/Target/DynamicRegisterInfo.cpp --- a/lldb/source/Target/DynamicRegisterInfo.cpp +++ b/lldb/source/Target/DynamicRegisterInfo.cpp @@ -238,17 +238,20 @@ std::vector invalidate_regs; memset(®_info, 0, sizeof(reg_info)); - ConstString name_val; - ConstString alt_name_val; - if (!reg_info_dict->GetValueForKeyAsString("name", name_val, nullptr)) { + llvm::StringRef name_val; + if (!reg_info_dict->GetValueForKeyAsString("name", name_val)) { Clear(); printf("error: registers must have valid names and offsets\n"); reg_info_dict->DumpToStdout(); return 0; } - reg_info.name = name_val.GetCString(); - reg_info_dict->GetValueForKeyAsString("alt-name", alt_name_val, nullptr); - reg_info.alt_name = alt_name_val.GetCString(); + reg_info.name = ConstString(name_val).GetCString(); + + llvm::StringRef alt_name_val; + if (reg_info_dict->GetValueForKeyAsString("alt-name", alt_name_val)) + reg_info.alt_name = ConstString(alt_name_val).GetCString(); + else + reg_info.alt_name = nullptr; llvm::Expected byte_offset = ByteOffsetFromRegInfoDict(i, *reg_info_dict, byte_order);