[Lldb-commits] [PATCH] D152597: [lldb][NFCI] Remove StructuredData::Dictionary::GetValueForKeyAsString overloads involving ConstString

Alex Langford via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 13 15:54:55 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGe669011c3cca: [lldb][NFCI] Remove StructuredData::Dictionary::GetValueForKeyAsString… (authored by bulbazord).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152597/new/

https://reviews.llvm.org/D152597

Files:
  lldb/include/lldb/Utility/StructuredData.h
  lldb/source/Target/DynamicRegisterInfo.cpp


Index: lldb/source/Target/DynamicRegisterInfo.cpp
===================================================================
--- lldb/source/Target/DynamicRegisterInfo.cpp
+++ lldb/source/Target/DynamicRegisterInfo.cpp
@@ -238,17 +238,20 @@
     std::vector<uint32_t> invalidate_regs;
     memset(&reg_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<uint32_t> byte_offset =
         ByteOffsetFromRegInfoDict(i, *reg_info_dict, byte_order);
Index: lldb/include/lldb/Utility/StructuredData.h
===================================================================
--- lldb/include/lldb/Utility/StructuredData.h
+++ 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152597.531099.patch
Type: text/x-patch
Size: 2373 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230613/35c72445/attachment.bin>


More information about the lldb-commits mailing list