diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -490,7 +490,7 @@ 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 --- a/lldb/include/lldb/Core/ValueObjectRegister.h +++ b/lldb/include/lldb/Core/ValueObjectRegister.h @@ -55,7 +55,7 @@ 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 --- a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h +++ b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h @@ -56,7 +56,7 @@ 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 --- a/lldb/include/lldb/Symbol/CompilerType.h +++ b/lldb/include/lldb/Symbol/CompilerType.h @@ -387,7 +387,7 @@ /// 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 --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -348,7 +348,7 @@ // 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 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -687,7 +687,7 @@ 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 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -460,9 +460,9 @@ 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 --- a/lldb/source/Core/ValueObjectRegister.cpp +++ b/lldb/source/Core/ValueObjectRegister.cpp @@ -142,11 +142,9 @@ 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 --- 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 @@ 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 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -793,7 +793,7 @@ 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.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 @@ -877,7 +877,7 @@ // 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/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 @@ -6966,9 +6966,9 @@ 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 @@ // 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 @@ 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(qual_type.getTypePtr()); assert(objc_class_type); @@ -7045,7 +7043,7 @@ 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 @@ } 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/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp --- a/lldb/source/Symbol/CompilerType.cpp +++ b/lldb/source/Symbol/CompilerType.cpp @@ -810,12 +810,12 @@ // 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; }