[lldb] Take StringRef name in GetIndexOfChildMemberWithName (NFC)

Change the type of the `name` parameter from `char *` to `StringRef`.

Follow up to D151615.

Differential Revision: https://reviews.llvm.org/D151810
This commit is contained in:
Dave Lee 2023-05-28 12:08:19 -07:00
parent 731f9ac6e5
commit 57c122d0ea
6 changed files with 14 additions and 15 deletions

View File

@ -397,7 +397,8 @@ public:
/// vector<vector<uint32_t>>
/// so we catch all names that match a given child name, not just the first.
size_t
GetIndexOfChildMemberWithName(const char *name, bool omit_empty_base_classes,
GetIndexOfChildMemberWithName(llvm::StringRef name,
bool omit_empty_base_classes,
std::vector<uint32_t> &child_indexes) const;
/// Return the number of template arguments the type has.

View File

@ -357,10 +357,9 @@ public:
// TODO: Return all matches for a given name by returning a
// vector<vector<uint32_t>>
// so we catch all names that match a given child name, not just the first.
virtual size_t
GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type,
const char *name, bool omit_empty_base_classes,
std::vector<uint32_t> &child_indexes) = 0;
virtual size_t GetIndexOfChildMemberWithName(
lldb::opaque_compiler_type_t type, llvm::StringRef name,
bool omit_empty_base_classes, std::vector<uint32_t> &child_indexes) = 0;
virtual bool IsTemplateType(lldb::opaque_compiler_type_t type);

View File

@ -483,7 +483,7 @@ ValueObjectSP ValueObject::GetChildMemberWithName(llvm::StringRef name,
const size_t num_child_indexes =
GetCompilerType().GetIndexOfChildMemberWithName(
name.str().data(), omit_empty_base_classes, child_indexes);
name, omit_empty_base_classes, child_indexes);
if (num_child_indexes == 0)
return nullptr;

View File

@ -6728,9 +6728,9 @@ uint32_t TypeSystemClang::GetIndexForRecordChild(
// index 1 is the child index for "m_b" within class A
size_t TypeSystemClang::GetIndexOfChildMemberWithName(
lldb::opaque_compiler_type_t type, const char *name,
lldb::opaque_compiler_type_t type, llvm::StringRef name,
bool omit_empty_base_classes, std::vector<uint32_t> &child_indexes) {
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();
switch (type_class) {
@ -6748,7 +6748,6 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName(
// 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) {
@ -6761,7 +6760,7 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName(
return child_indexes.size();
child_indexes.pop_back();
} else if (field_name.equals(name_sref)) {
} else if (field_name.equals(name)) {
// We have to add on the number of base classes to this index!
child_indexes.push_back(
child_idx + TypeSystemClang::GetNumBaseClasses(
@ -6774,8 +6773,7 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName(
const clang::RecordDecl *parent_record_decl = cxx_record_decl;
// Didn't find things easily, lets let clang do its thang...
clang::IdentifierInfo &ident_ref =
getASTContext().Idents.get(name_sref);
clang::IdentifierInfo &ident_ref = getASTContext().Idents.get(name);
clang::DeclarationName decl_name(&ident_ref);
clang::CXXBasePaths paths;

View File

@ -888,7 +888,8 @@ public:
// so we catch all names that match a given child name, not just the first.
size_t
GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type,
const char *name, bool omit_empty_base_classes,
llvm::StringRef name,
bool omit_empty_base_classes,
std::vector<uint32_t> &child_indexes) override;
bool IsTemplateType(lldb::opaque_compiler_type_t type) override;

View File

@ -741,9 +741,9 @@ CompilerType CompilerType::GetChildCompilerTypeAtIndex(
// index 1 is the child index for "m_b" within class A
size_t CompilerType::GetIndexOfChildMemberWithName(
const char *name, bool omit_empty_base_classes,
llvm::StringRef name, bool omit_empty_base_classes,
std::vector<uint32_t> &child_indexes) const {
if (IsValid() && name && name[0]) {
if (IsValid() && !name.empty()) {
if (auto type_system_sp = GetTypeSystem())
return type_system_sp->GetIndexOfChildMemberWithName(
m_type, name, omit_empty_base_classes, child_indexes);