[Lldb-commits] [lldb] 00e52cc - [lldb] Take StringRef names in GetChildAtNamePath (NFC)
Dave Lee via lldb-commits
lldb-commits at lists.llvm.org
Thu Jun 1 20:42:35 PDT 2023
Author: Dave Lee
Date: 2023-06-01T20:42:29-07:00
New Revision: 00e52cc4a8cc06cfafe787caea686810ac6c37ac
URL: https://github.com/llvm/llvm-project/commit/00e52cc4a8cc06cfafe787caea686810ac6c37ac
DIFF: https://github.com/llvm/llvm-project/commit/00e52cc4a8cc06cfafe787caea686810ac6c37ac.diff
LOG: [lldb] Take StringRef names in GetChildAtNamePath (NFC)
Following D151810, this changes `GetChildAtNamePath` to take a path of `StringRef`
values instead of `ConstString`.
Differential Revision: https://reviews.llvm.org/D151813
Added:
Modified:
lldb/include/lldb/Core/ValueObject.h
lldb/source/Core/ValueObject.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h
index e422deeab0142..9f7bdf61e402b 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -480,8 +480,7 @@ class ValueObject {
size_t *index_of_error = nullptr);
// this will always create the children if necessary
- lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef<ConstString> names,
- ConstString *name_of_error = nullptr);
+ lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef<llvm::StringRef> names);
lldb::ValueObjectSP
GetChildAtNamePath(llvm::ArrayRef<std::pair<ConstString, bool>> names,
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 2a11d9724a226..1e18210a72379 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -427,16 +427,13 @@ lldb::ValueObjectSP ValueObject::GetChildAtIndexPath(
}
lldb::ValueObjectSP
-ValueObject::GetChildAtNamePath(llvm::ArrayRef<ConstString> names,
- ConstString *name_of_error) {
+ValueObject::GetChildAtNamePath(llvm::ArrayRef<llvm::StringRef> names) {
if (names.size() == 0)
return GetSP();
ValueObjectSP root(GetSP());
- for (ConstString name : names) {
+ for (llvm::StringRef name : names) {
root = root->GetChildMemberWithName(name, true);
if (!root) {
- if (name_of_error)
- *name_of_error = name;
return root;
}
}
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 127ce07f2ff35..16f3688303f75 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -153,10 +153,10 @@ bool lldb_private::formatters::LibcxxSmartPointerSummaryProvider(
if (!valobj_sp)
return false;
ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName("__ptr_", true));
- ValueObjectSP count_sp(valobj_sp->GetChildAtNamePath(
- {ConstString("__cntrl_"), ConstString("__shared_owners_")}));
- ValueObjectSP weakcount_sp(valobj_sp->GetChildAtNamePath(
- {ConstString("__cntrl_"), ConstString("__shared_weak_owners_")}));
+ ValueObjectSP count_sp(
+ valobj_sp->GetChildAtNamePath({"__cntrl_", "__shared_owners_"}));
+ ValueObjectSP weakcount_sp(
+ valobj_sp->GetChildAtNamePath({"__cntrl_", "__shared_weak_owners_"}));
if (!ptr_sp)
return false;
@@ -810,8 +810,7 @@ ExtractLibcxxStringInfo(ValueObject &valobj) {
return {};
ValueObjectSP is_long = short_sp->GetChildMemberWithName("__is_long_", true);
- ValueObjectSP size_sp =
- short_sp->GetChildAtNamePath({ConstString("__size_")});
+ ValueObjectSP size_sp = short_sp->GetChildMemberWithName("__size_", true);
if (!size_sp)
return {};
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
index 6a29abee8181d..deaa25deb8856 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
@@ -241,9 +241,6 @@ size_t lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::
}
bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType() {
- static ConstString g_tree_("__tree_");
- static ConstString g_pair3("__pair3_");
-
if (m_element_type.IsValid())
return true;
m_element_type.Clear();
@@ -257,7 +254,7 @@ bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType() {
m_element_type = deref->GetCompilerType();
return true;
}
- deref = m_backend.GetChildAtNamePath({g_tree_, g_pair3});
+ deref = m_backend.GetChildAtNamePath({"__tree_", "__pair3_"});
if (!deref)
return false;
m_element_type = deref->GetCompilerType()
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
index d681b7066efcf..a4c6326666cb6 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -112,8 +112,7 @@ lldb::ValueObjectSP lldb_private::formatters::
ValueObjectSP hash_sp = node_sp->GetChildMemberWithName("__hash_", true);
if (!hash_sp || !value_sp) {
if (!m_element_type) {
- auto p1_sp = m_backend.GetChildAtNamePath({ConstString("__table_"),
- ConstString("__p1_")});
+ auto p1_sp = m_backend.GetChildAtNamePath({"__table_", "__p1_"});
if (!p1_sp)
return nullptr;
@@ -199,21 +198,19 @@ bool lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
ValueObjectSP p2_sp = table_sp->GetChildMemberWithName("__p2_", true);
ValueObjectSP num_elements_sp = nullptr;
- llvm::SmallVector<ConstString, 3> next_path;
+ llvm::SmallVector<llvm::StringRef, 3> next_path;
switch (p2_sp->GetCompilerType().GetNumDirectBaseClasses()) {
case 1:
// Assume a pre llvm r300140 __compressed_pair implementation:
num_elements_sp = p2_sp->GetChildMemberWithName("__first_", true);
- next_path.append({ConstString("__p1_"), ConstString("__first_"),
- ConstString("__next_")});
+ next_path.append({"__p1_", "__first_", "__next_"});
break;
case 2: {
// Assume a post llvm r300140 __compressed_pair implementation:
ValueObjectSP first_elem_parent = p2_sp->GetChildAtIndex(0, true);
num_elements_sp =
first_elem_parent->GetChildMemberWithName("__value_", true);
- next_path.append({ConstString("__p1_"), ConstString("__value_"),
- ConstString("__next_")});
+ next_path.append({"__p1_", "__value_", "__next_"});
break;
}
default:
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
index 76b934ca4e6af..d52ff9bddf34d 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
@@ -437,9 +437,8 @@ bool lldb_private::formatters::LibStdcppSmartPointerSummaryProvider(
if (!ptr_sp)
return false;
- ValueObjectSP usecount_sp(valobj_sp->GetChildAtNamePath(
- {ConstString("_M_refcount"), ConstString("_M_pi"),
- ConstString("_M_use_count")}));
+ ValueObjectSP usecount_sp(
+ valobj_sp->GetChildAtNamePath({"_M_refcount", "_M_pi", "_M_use_count"}));
if (!usecount_sp)
return false;
More information about the lldb-commits
mailing list