[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
Fri Jun 9 17:10:04 PDT 2023
bulbazord created this revision.
bulbazord added reviewers: JDevlieghere, mib, fdeazeve, jingham.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
In an effort to keep the ConstString StringPool small, I plan on
removing use of ConstString in StructuredData. The only class that
really uses it is StructuredData::Dictionary.
This one was fairly easy to remove, I plan on removing the others in
follow-up changes.
Repository:
rG LLVM Github Monorepo
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(®_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.530120.patch
Type: text/x-patch
Size: 2373 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230610/9a0708f6/attachment.bin>
More information about the lldb-commits
mailing list