[Lldb-commits] [lldb] 5dae706 - [lldb] Take StringRef name in GetIndexOfChildWithName (NFC)
Dave Lee via lldb-commits
lldb-commits at lists.llvm.org
Thu Jun 1 20:24:07 PDT 2023
Author: Dave Lee
Date: 2023-06-01T20:24:01-07:00
New Revision: 5dae706259da2ef8d51439e29a8764461da63cf7
URL: https://github.com/llvm/llvm-project/commit/5dae706259da2ef8d51439e29a8764461da63cf7
DIFF: https://github.com/llvm/llvm-project/commit/5dae706259da2ef8d51439e29a8764461da63cf7.diff
LOG: [lldb] Take StringRef name in GetIndexOfChildWithName (NFC)
As with D151615, which changed `GetIndexOfChildMemberWithName` to take a `StringRef`
instead of a `ConstString`, this change does the same for `GetIndexOfChildWithName`.
Differential Revision: https://reviews.llvm.org/D151811
Added:
Modified:
lldb/include/lldb/Core/ValueObject.h
lldb/include/lldb/Core/ValueObjectRegister.h
lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
lldb/include/lldb/Symbol/CompilerType.h
lldb/include/lldb/Symbol/TypeSystem.h
lldb/source/API/SBValue.cpp
lldb/source/Core/ValueObject.cpp
lldb/source/Core/ValueObjectRegister.cpp
lldb/source/Core/ValueObjectSyntheticFilter.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
lldb/source/Symbol/CompilerType.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h
index 00fdb87c79279..e422deeab0142 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -490,7 +490,7 @@ class ValueObject {
virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
bool can_create);
- virtual size_t GetIndexOfChildWithName(ConstString name);
+ virtual size_t GetIndexOfChildWithName(llvm::StringRef name);
size_t GetNumChildren(uint32_t max = UINT32_MAX);
diff --git a/lldb/include/lldb/Core/ValueObjectRegister.h b/lldb/include/lldb/Core/ValueObjectRegister.h
index 96e8b3067efb4..9859b9e8d645f 100644
--- a/lldb/include/lldb/Core/ValueObjectRegister.h
+++ b/lldb/include/lldb/Core/ValueObjectRegister.h
@@ -55,7 +55,7 @@ class ValueObjectRegisterSet : public ValueObject {
lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
bool can_create) override;
- size_t GetIndexOfChildWithName(ConstString name) override;
+ size_t GetIndexOfChildWithName(llvm::StringRef name) override;
protected:
bool UpdateValue() override;
diff --git a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
index a65e7eb1b8081..8e20e05c27522 100644
--- a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
+++ b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
@@ -56,7 +56,7 @@ class ValueObjectSynthetic : public ValueObject {
lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
bool can_create) override;
- size_t GetIndexOfChildWithName(ConstString name) override;
+ size_t GetIndexOfChildWithName(llvm::StringRef name) override;
lldb::ValueObjectSP
GetDynamicValue(lldb::DynamicValueType valueType) override;
diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h
index ba75eb9abd4b3..1d2244297cb0a 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -387,7 +387,7 @@ class CompilerType {
/// Lookup a child given a name. This function will match base class names and
/// member member names in "clang_type" only, not descendants.
- uint32_t GetIndexOfChildWithName(const char *name,
+ uint32_t GetIndexOfChildWithName(llvm::StringRef name,
bool omit_empty_base_classes) const;
/// Lookup a child member given a name. This function will match member names
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h
index 21e5915fab0ce..7b5be3aabaf58 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -348,7 +348,7 @@ class TypeSystem : public PluginInterface,
// Lookup a child given a name. This function will match base class names and
// member member names in "clang_type" only, not descendants.
virtual uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
- const char *name,
+ llvm::StringRef name,
bool omit_empty_base_classes) = 0;
// Lookup a child member given a name. This function will match member names
diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index 573ee3a82fa03..aee9e86fdde12 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -687,7 +687,7 @@ uint32_t SBValue::GetIndexOfChildWithName(const char *name) {
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp) {
- idx = value_sp->GetIndexOfChildWithName(ConstString(name));
+ idx = value_sp->GetIndexOfChildWithName(name);
}
return idx;
}
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 2041a54feafa2..2a11d9724a226 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -460,9 +460,9 @@ lldb::ValueObjectSP ValueObject::GetChildAtNamePath(
return root;
}
-size_t ValueObject::GetIndexOfChildWithName(ConstString name) {
+size_t ValueObject::GetIndexOfChildWithName(llvm::StringRef name) {
bool omit_empty_base_classes = true;
- return GetCompilerType().GetIndexOfChildWithName(name.GetCString(),
+ return GetCompilerType().GetIndexOfChildWithName(name,
omit_empty_base_classes);
}
diff --git a/lldb/source/Core/ValueObjectRegister.cpp b/lldb/source/Core/ValueObjectRegister.cpp
index 8a807c3243de4..798868997a05c 100644
--- a/lldb/source/Core/ValueObjectRegister.cpp
+++ b/lldb/source/Core/ValueObjectRegister.cpp
@@ -142,11 +142,9 @@ ValueObjectRegisterSet::GetChildMemberWithName(llvm::StringRef name,
return ValueObjectSP();
}
-size_t
-ValueObjectRegisterSet::GetIndexOfChildWithName(ConstString name) {
+size_t ValueObjectRegisterSet::GetIndexOfChildWithName(llvm::StringRef name) {
if (m_reg_ctx_sp && m_reg_set) {
- const RegisterInfo *reg_info =
- m_reg_ctx_sp->GetRegisterInfoByName(name.GetStringRef());
+ const RegisterInfo *reg_info = m_reg_ctx_sp->GetRegisterInfoByName(name);
if (reg_info != nullptr)
return reg_info->kinds[eRegisterKindLLDB];
}
diff --git a/lldb/source/Core/ValueObjectSyntheticFilter.cpp b/lldb/source/Core/ValueObjectSyntheticFilter.cpp
index 315ab2b6182a7..cfa450eb0f8a7 100644
--- a/lldb/source/Core/ValueObjectSyntheticFilter.cpp
+++ b/lldb/source/Core/ValueObjectSyntheticFilter.cpp
@@ -12,6 +12,7 @@
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Status.h"
@@ -318,9 +319,11 @@ ValueObjectSynthetic::GetChildMemberWithName(llvm::StringRef name,
return GetChildAtIndex(index, can_create);
}
-size_t ValueObjectSynthetic::GetIndexOfChildWithName(ConstString name) {
+size_t ValueObjectSynthetic::GetIndexOfChildWithName(llvm::StringRef name_ref) {
UpdateValueIfNeeded();
+ ConstString name(name_ref);
+
uint32_t found_index = UINT32_MAX;
bool did_find;
{
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 12d32c9b9f38e..127ce07f2ff35 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -793,7 +793,7 @@ ExtractLibcxxStringInfo(ValueObject &valobj) {
if (!l)
return {};
- StringLayout layout = l->GetIndexOfChildWithName(ConstString("__data_")) == 0
+ StringLayout layout = l->GetIndexOfChildWithName("__data_") == 0
? StringLayout::DSC
: StringLayout::CSD;
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index d0222bce6c67a..b7ecde9790e05 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -6966,9 +6966,9 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName(
uint32_t
TypeSystemClang::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
- const char *name,
+ llvm::StringRef name,
bool omit_empty_base_classes) {
- if (type && name && name[0]) {
+ if (type && !name.empty()) {
clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type));
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
@@ -7013,11 +7013,10 @@ TypeSystemClang::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
// Try and find a field that matches NAME
clang::RecordDecl::field_iterator field, field_end;
- llvm::StringRef name_sref(name);
for (field = record_decl->field_begin(),
field_end = record_decl->field_end();
field != field_end; ++field, ++child_idx) {
- if (field->getName().equals(name_sref))
+ if (field->getName().equals(name))
return child_idx;
}
}
@@ -7026,7 +7025,6 @@ TypeSystemClang::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
case clang::Type::ObjCObject:
case clang::Type::ObjCInterface:
if (GetCompleteType(type)) {
- llvm::StringRef name_sref(name);
const clang::ObjCObjectType *objc_class_type =
llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
assert(objc_class_type);
@@ -7045,7 +7043,7 @@ TypeSystemClang::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
ivar_pos != ivar_end; ++ivar_pos, ++child_idx) {
const clang::ObjCIvarDecl *ivar_decl = *ivar_pos;
- if (ivar_decl->getName().equals(name_sref)) {
+ if (ivar_decl->getName().equals(name)) {
if ((!omit_empty_base_classes && superclass_interface_decl) ||
(omit_empty_base_classes &&
ObjCDeclHasIVars(superclass_interface_decl, true)))
@@ -7056,7 +7054,7 @@ TypeSystemClang::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
}
if (superclass_interface_decl) {
- if (superclass_interface_decl->getName().equals(name_sref))
+ if (superclass_interface_decl->getName().equals(name))
return 0;
}
}
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index 68d11d3c1785b..7ab588656666b 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -877,7 +877,7 @@ class TypeSystemClang : public TypeSystem {
// Lookup a child given a name. This function will match base class names and
// member member names in "clang_type" only, not descendants.
uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
- const char *name,
+ llvm::StringRef name,
bool omit_empty_base_classes) override;
// Lookup a child member given a name. This function will match member names
diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp
index 1314ad4ed85e8..4bce2c5071bf3 100644
--- a/lldb/source/Symbol/CompilerType.cpp
+++ b/lldb/source/Symbol/CompilerType.cpp
@@ -810,12 +810,12 @@ bool CompilerType::IsMeaninglessWithoutDynamicResolution() const {
// matches can include base class names.
uint32_t
-CompilerType::GetIndexOfChildWithName(const char *name,
+CompilerType::GetIndexOfChildWithName(llvm::StringRef name,
bool omit_empty_base_classes) const {
- if (IsValid() && name && name[0]) {
+ if (IsValid() && !name.empty()) {
if (auto type_system_sp = GetTypeSystem())
return type_system_sp->GetIndexOfChildWithName(m_type, name,
- omit_empty_base_classes);
+ omit_empty_base_classes);
}
return UINT32_MAX;
}
More information about the lldb-commits
mailing list