[Lldb-commits] [lldb] 57c122d - [lldb] Take StringRef name in GetIndexOfChildMemberWithName (NFC)
Dave Lee via lldb-commits
lldb-commits at lists.llvm.org
Wed May 31 11:02:50 PDT 2023
Author: Dave Lee
Date: 2023-05-31T11:02:44-07:00
New Revision: 57c122d0ea1db38116ea9128a2c273204248bc67
URL: https://github.com/llvm/llvm-project/commit/57c122d0ea1db38116ea9128a2c273204248bc67
DIFF: https://github.com/llvm/llvm-project/commit/57c122d0ea1db38116ea9128a2c273204248bc67.diff
LOG: [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
Added:
Modified:
lldb/include/lldb/Symbol/CompilerType.h
lldb/include/lldb/Symbol/TypeSystem.h
lldb/source/Core/ValueObject.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/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h
index 50587f4aab827..ba75eb9abd4b3 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -397,7 +397,8 @@ class CompilerType {
/// 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.
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h
index dfef87232628b..21e5915fab0ce 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -357,10 +357,9 @@ class TypeSystem : public PluginInterface,
// 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);
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 48cdcb913f129..2041a54feafa2 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -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;
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index fa6ab9b2f86b5..d0222bce6c67a 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -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;
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index 414b51911cf89..68d11d3c1785b 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -888,7 +888,8 @@ class TypeSystemClang : public TypeSystem {
// 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;
diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp
index d6dc43c05d1bd..1314ad4ed85e8 100644
--- a/lldb/source/Symbol/CompilerType.cpp
+++ b/lldb/source/Symbol/CompilerType.cpp
@@ -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);
More information about the lldb-commits
mailing list