diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h --- a/lldb/include/lldb/Symbol/CompilerType.h +++ b/lldb/include/lldb/Symbol/CompilerType.h @@ -397,7 +397,8 @@ /// vector> /// 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 &child_indexes) const; /// Return the number of template arguments the type has. diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -357,10 +357,9 @@ // TODO: Return all matches for a given name by returning a // vector> // 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 &child_indexes) = 0; + virtual size_t GetIndexOfChildMemberWithName( + lldb::opaque_compiler_type_t type, llvm::StringRef name, + bool omit_empty_base_classes, std::vector &child_indexes) = 0; virtual bool IsTemplateType(lldb::opaque_compiler_type_t type); diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -483,7 +483,7 @@ 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; diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -888,7 +888,8 @@ // 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 &child_indexes) override; bool IsTemplateType(lldb::opaque_compiler_type_t type) override; diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -6728,9 +6728,9 @@ // 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 &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 @@ // 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 @@ 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 @@ 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; diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp --- a/lldb/source/Symbol/CompilerType.cpp +++ b/lldb/source/Symbol/CompilerType.cpp @@ -741,9 +741,9 @@ // 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 &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);