[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
Wed Jun 14 15:17:20 PDT 2023
bulbazord created this revision.
bulbazord added reviewers: JDevlieghere, jingham, mib.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
std::map<ConstString, FieldImpl> is naturally replaced with
`llvm::StringMap<FieldImpl>` here.
Repository:
rG LLVM Github Monorepo
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.531536.patch
Type: text/x-patch
Size: 2837 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230614/77056ab2/attachment-0001.bin>
More information about the lldb-commits
mailing list