[Lldb-commits] [lldb] 0b90d09 - [lldb][NFCI] Remove use of ConstString in ProcessStructReader

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


Author: Alex Langford
Date: 2023-06-16T10:53:24-07:00
New Revision: 0b90d09898cadc89105c3caf0d01f09e66c49993

URL: https://github.com/llvm/llvm-project/commit/0b90d09898cadc89105c3caf0d01f09e66c49993
DIFF: https://github.com/llvm/llvm-project/commit/0b90d09898cadc89105c3caf0d01f09e66c49993.diff

LOG: [lldb][NFCI] Remove use of ConstString in ProcessStructReader

std::map<ConstString, FieldImpl> is naturally replaced with
`llvm::StringMap<FieldImpl>` here.

Differential Revision: https://reviews.llvm.org/D152968

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Target/ProcessStructReader.h b/lldb/include/lldb/Target/ProcessStructReader.h
index ceb70528cf2d1..0f0b3f69d5509 100644
--- a/lldb/include/lldb/Target/ProcessStructReader.h
+++ b/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 @@ class ProcessStructReader {
     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 @@ class ProcessStructReader {
       // 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 @@ class ProcessStructReader {
   }
 
   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;

diff  --git a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
index ae5e1b7baed57..f4ddc9e869148 100644
--- a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
+++ b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
@@ -442,13 +442,13 @@ void SystemRuntimeMacOSX::ReadLibdispatchTSDIndexes() {
                                         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");
     }
   }
 }


        


More information about the lldb-commits mailing list