Skip to content

Commit 3c2c1d3

Browse files
authored
Merge pull request #2241 from apple/lldb-Lift-GetIndexOfChildWithName-into-TypeSystemSwift-base-class-next
[lldb] Lift GetIndexOfChildWithName into TypeSystemSwift base class
2 parents afc4bd0 + 262cf5c commit 3c2c1d3

File tree

6 files changed

+17
-31
lines changed

6 files changed

+17
-31
lines changed

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7379,21 +7379,6 @@ size_t SwiftASTContext::GetIndexOfChildMemberWithName(
73797379
return 0;
73807380
}
73817381

7382-
/// Get the index of the child of "clang_type" whose name matches. This
7383-
/// function doesn't descend into the children, but only looks one
7384-
/// level deep and name matches can include base class names.
7385-
uint32_t
7386-
SwiftASTContext::GetIndexOfChildWithName(opaque_compiler_type_t type,
7387-
const char *name,
7388-
bool omit_empty_base_classes) {
7389-
VALID_OR_RETURN(UINT32_MAX);
7390-
7391-
std::vector<uint32_t> child_indexes;
7392-
size_t num_child_indexes = GetIndexOfChildMemberWithName(
7393-
type, name, omit_empty_base_classes, child_indexes);
7394-
return num_child_indexes == 1 ? child_indexes.front() : UINT32_MAX;
7395-
}
7396-
73977382
size_t SwiftASTContext::GetNumTemplateArguments(opaque_compiler_type_t type) {
73987383
if (!type)
73997384
return 0;

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -600,12 +600,6 @@ class SwiftASTContext : public TypeSystemSwift {
600600
bool &child_is_base_class, bool &child_is_deref_of_parent,
601601
ValueObject *valobj, uint64_t &language_flags) override;
602602

603-
// Lookup a child given a name. This function will match base class names
604-
// and member names in "clang_type" only, not descendants.
605-
uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
606-
const char *name,
607-
bool omit_empty_base_classes) override;
608-
609603
// Lookup a child member given a name. This function will match member names
610604
// only and will descend into "clang_type" children in search for the first
611605
// member in this class, or any base class that matches "name".

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,13 @@ bool TypeSystemSwift::ShouldTreatScalarValueAsAddress(
101101
return Flags(GetTypeInfo(type, nullptr))
102102
.AnySet(eTypeInstanceIsPointer | eTypeIsReference);
103103
}
104+
105+
uint32_t
106+
TypeSystemSwift::GetIndexOfChildWithName(opaque_compiler_type_t type,
107+
const char *name,
108+
bool omit_empty_base_classes) {
109+
std::vector<uint32_t> child_indexes;
110+
size_t num_child_indexes = GetIndexOfChildMemberWithName(
111+
type, name, omit_empty_base_classes, child_indexes);
112+
return num_child_indexes == 1 ? child_indexes.front() : UINT32_MAX;
113+
}

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,13 @@ class TypeSystemSwift : public TypeSystem {
242242
}
243243
bool
244244
ShouldTreatScalarValueAsAddress(lldb::opaque_compiler_type_t type) override;
245+
246+
/// Lookup a child given a name. This function will match base class names
247+
/// and member names in \p type only, not descendants.
248+
uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
249+
const char *name,
250+
bool omit_empty_base_classes) override;
251+
245252
/// \}
246253
protected:
247254
/// Used in the logs.

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,13 +2355,6 @@ CompilerType TypeSystemSwiftTypeRef::GetChildCompilerTypeAtIndex(
23552355
ast_child_is_deref_of_parent, valobj, ast_language_flags));
23562356
}
23572357

2358-
uint32_t
2359-
TypeSystemSwiftTypeRef::GetIndexOfChildWithName(opaque_compiler_type_t type,
2360-
const char *name,
2361-
bool omit_empty_base_classes) {
2362-
return m_swift_ast_context->GetIndexOfChildWithName(
2363-
ReconstructType(type), name, omit_empty_base_classes);
2364-
}
23652358
size_t TypeSystemSwiftTypeRef::GetIndexOfChildMemberWithName(
23662359
opaque_compiler_type_t type, const char *name, bool omit_empty_base_classes,
23672360
std::vector<uint32_t> &child_indexes) {

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,6 @@ class TypeSystemSwiftTypeRef : public TypeSystemSwift {
163163
uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
164164
bool &child_is_base_class, bool &child_is_deref_of_parent,
165165
ValueObject *valobj, uint64_t &language_flags) override;
166-
uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
167-
const char *name,
168-
bool omit_empty_base_classes) override;
169166
size_t
170167
GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type,
171168
const char *name, bool omit_empty_base_classes,

0 commit comments

Comments
 (0)