[Lldb-commits] [PATCH] D152968: [lldb][NFCI] Remove use of ConstString in ProcessStructReader

Alex Langford via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 16 10:54:22 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG0b90d09898ca: [lldb][NFCI] Remove use of ConstString in ProcessStructReader (authored by bulbazord).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152968

Files:
  lldb/include/lldb/Target/ProcessStructReader.h
  lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp


Index: lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
===================================================================
--- lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
+++ lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
@@ -442,13 +442,13 @@
                                         dispatch_tsd_indexes_s);
 
       m_libdispatch_tsd_indexes.dti_version =
-          struct_reader.GetField<uint16_t>(ConstString("dti_version"));
+          struct_reader.GetField<uint16_t>("dti_version");
       m_libdispatch_tsd_indexes.dti_queue_index =
-          struct_reader.GetField<uint16_t>(ConstString("dti_queue_index"));
+          struct_reader.GetField<uint16_t>("dti_queue_index");
       m_libdispatch_tsd_indexes.dti_voucher_index =
-          struct_reader.GetField<uint16_t>(ConstString("dti_voucher_index"));
+          struct_reader.GetField<uint16_t>("dti_voucher_index");
       m_libdispatch_tsd_indexes.dti_qos_class_index =
-          struct_reader.GetField<uint16_t>(ConstString("dti_qos_class_index"));
+          struct_reader.GetField<uint16_t>("dti_qos_class_index");
     }
   }
 }
Index: lldb/include/lldb/Target/ProcessStructReader.h
===================================================================
--- lldb/include/lldb/Target/ProcessStructReader.h
+++ lldb/include/lldb/Target/ProcessStructReader.h
@@ -14,11 +14,12 @@
 
 #include "lldb/Symbol/CompilerType.h"
 #include "lldb/Target/Process.h"
-#include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/DataExtractor.h"
 #include "lldb/Utility/Status.h"
 
+#include "llvm/ADT/StringMap.h"
+
 #include <initializer_list>
 #include <map>
 #include <string>
@@ -32,7 +33,7 @@
     size_t size;
   };
 
-  std::map<ConstString, FieldImpl> m_fields;
+  llvm::StringMap<FieldImpl> m_fields;
   DataExtractor m_data;
   lldb::ByteOrder m_byte_order;
   size_t m_addr_byte_size;
@@ -62,10 +63,9 @@
       // no support for things larger than a uint64_t (yet)
       if (!size || *size > 8)
         return;
-      ConstString const_name = ConstString(name.c_str());
       size_t byte_index = static_cast<size_t>(bit_offset / 8);
-      m_fields[const_name] =
-          FieldImpl{field_type, byte_index, static_cast<size_t>(*size)};
+      m_fields.insert({name, FieldImpl{field_type, byte_index,
+                                       static_cast<size_t>(*size)}});
     }
     auto total_size = struct_type.GetByteSize(nullptr);
     if (!total_size)
@@ -80,7 +80,7 @@
   }
 
   template <typename RetType>
-  RetType GetField(ConstString name, RetType fail_value = RetType()) {
+  RetType GetField(llvm::StringRef name, RetType fail_value = RetType()) {
     auto iter = m_fields.find(name), end = m_fields.end();
     if (iter == end)
       return fail_value;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152968.532233.patch
Type: text/x-patch
Size: 2837 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230616/401755dc/attachment.bin>


More information about the lldb-commits mailing list