[Lldb-commits] [lldb] e669011 - [lldb][NFCI] Remove StructuredData::Dictionary::GetValueForKeyAsString overloads involving ConstString
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Tue Jun 13 15:54:45 PDT 2023
Author: Alex Langford
Date: 2023-06-13T15:51:56-07:00
New Revision: e669011c3cca4b7b4a1c2e8d96467cecbc05df4d
URL: https://github.com/llvm/llvm-project/commit/e669011c3cca4b7b4a1c2e8d96467cecbc05df4d
DIFF: https://github.com/llvm/llvm-project/commit/e669011c3cca4b7b4a1c2e8d96467cecbc05df4d.diff
LOG: [lldb][NFCI] Remove StructuredData::Dictionary::GetValueForKeyAsString overloads involving ConstString
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.
Differential Revision: https://reviews.llvm.org/D152597
Added:
Modified:
lldb/include/lldb/Utility/StructuredData.h
lldb/source/Target/DynamicRegisterInfo.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Utility/StructuredData.h b/lldb/include/lldb/Utility/StructuredData.h
index d6b51f7c58c12..28c71a8ca827a 100644
--- a/lldb/include/lldb/Utility/StructuredData.h
+++ b/lldb/include/lldb/Utility/StructuredData.h
@@ -536,26 +536,6 @@ class StructuredData {
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;
diff --git a/lldb/source/Target/DynamicRegisterInfo.cpp b/lldb/source/Target/DynamicRegisterInfo.cpp
index d20f7c0bf98a0..700619959f5c8 100644
--- a/lldb/source/Target/DynamicRegisterInfo.cpp
+++ b/lldb/source/Target/DynamicRegisterInfo.cpp
@@ -238,17 +238,20 @@ DynamicRegisterInfo::SetRegisterInfo(const StructuredData::Dictionary &dict,
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);
More information about the lldb-commits
mailing list