Skip to content

Commit 81ea6d8

Browse files
authored
Merge pull request #2237 from apple/lldb-Lift-GetIndexOfChildWithName-into-TypeSystemSwift-base-class
[lldb] Lift GetIndexOfChildWithName into TypeSystemSwift base class
2 parents 70537e5 + dc9b844 commit 81ea6d8

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
@@ -7438,21 +7438,6 @@ size_t SwiftASTContext::GetIndexOfChildMemberWithName(
74387438
return 0;
74397439
}
74407440

7441-
/// Get the index of the child of "clang_type" whose name matches. This
7442-
/// function doesn't descend into the children, but only looks one
7443-
/// level deep and name matches can include base class names.
7444-
uint32_t
7445-
SwiftASTContext::GetIndexOfChildWithName(opaque_compiler_type_t type,
7446-
const char *name,
7447-
bool omit_empty_base_classes) {
7448-
VALID_OR_RETURN(UINT32_MAX);
7449-
7450-
std::vector<uint32_t> child_indexes;
7451-
size_t num_child_indexes = GetIndexOfChildMemberWithName(
7452-
type, name, omit_empty_base_classes, child_indexes);
7453-
return num_child_indexes == 1 ? child_indexes.front() : UINT32_MAX;
7454-
}
7455-
74567441
size_t SwiftASTContext::GetNumTemplateArguments(opaque_compiler_type_t type) {
74577442
if (!type)
74587443
return 0;

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

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

605-
// Lookup a child given a name. This function will match base class names
606-
// and member names in "clang_type" only, not descendants.
607-
uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
608-
const char *name,
609-
bool omit_empty_base_classes) override;
610-
611605
// Lookup a child member given a name. This function will match member names
612606
// only and will descend into "clang_type" children in search for the first
613607
// 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
@@ -2358,13 +2358,6 @@ CompilerType TypeSystemSwiftTypeRef::GetChildCompilerTypeAtIndex(
23582358
ast_child_is_deref_of_parent, valobj, ast_language_flags));
23592359
}
23602360

2361-
uint32_t
2362-
TypeSystemSwiftTypeRef::GetIndexOfChildWithName(opaque_compiler_type_t type,
2363-
const char *name,
2364-
bool omit_empty_base_classes) {
2365-
return m_swift_ast_context->GetIndexOfChildWithName(
2366-
ReconstructType(type), name, omit_empty_base_classes);
2367-
}
23682361
size_t TypeSystemSwiftTypeRef::GetIndexOfChildMemberWithName(
23692362
opaque_compiler_type_t type, const char *name, bool omit_empty_base_classes,
23702363
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
@@ -165,9 +165,6 @@ class TypeSystemSwiftTypeRef : public TypeSystemSwift {
165165
uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
166166
bool &child_is_base_class, bool &child_is_deref_of_parent,
167167
ValueObject *valobj, uint64_t &language_flags) override;
168-
uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
169-
const char *name,
170-
bool omit_empty_base_classes) override;
171168
size_t
172169
GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type,
173170
const char *name, bool omit_empty_base_classes,

0 commit comments

Comments
 (0)