Skip to content

[lldb] Lift GetIndexOfChildWithName into TypeSystemSwift base class #2237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7438,21 +7438,6 @@ size_t SwiftASTContext::GetIndexOfChildMemberWithName(
return 0;
}

/// Get the index of the child of "clang_type" whose name matches. This
/// function doesn't descend into the children, but only looks one
/// level deep and name matches can include base class names.
uint32_t
SwiftASTContext::GetIndexOfChildWithName(opaque_compiler_type_t type,
const char *name,
bool omit_empty_base_classes) {
VALID_OR_RETURN(UINT32_MAX);

std::vector<uint32_t> child_indexes;
size_t num_child_indexes = GetIndexOfChildMemberWithName(
type, name, omit_empty_base_classes, child_indexes);
return num_child_indexes == 1 ? child_indexes.front() : UINT32_MAX;
}

size_t SwiftASTContext::GetNumTemplateArguments(opaque_compiler_type_t type) {
if (!type)
return 0;
Expand Down
6 changes: 0 additions & 6 deletions lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -602,12 +602,6 @@ class SwiftASTContext : public TypeSystemSwift {
bool &child_is_base_class, bool &child_is_deref_of_parent,
ValueObject *valobj, uint64_t &language_flags) override;

// Lookup a child given a name. This function will match base class names
// and member names in "clang_type" only, not descendants.
uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
const char *name,
bool omit_empty_base_classes) override;

// Lookup a child member given a name. This function will match member names
// only and will descend into "clang_type" children in search for the first
// member in this class, or any base class that matches "name".
Expand Down
10 changes: 10 additions & 0 deletions lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,13 @@ bool TypeSystemSwift::ShouldTreatScalarValueAsAddress(
return Flags(GetTypeInfo(type, nullptr))
.AnySet(eTypeInstanceIsPointer | eTypeIsReference);
}

uint32_t
TypeSystemSwift::GetIndexOfChildWithName(opaque_compiler_type_t type,
const char *name,
bool omit_empty_base_classes) {
std::vector<uint32_t> child_indexes;
size_t num_child_indexes = GetIndexOfChildMemberWithName(
type, name, omit_empty_base_classes, child_indexes);
return num_child_indexes == 1 ? child_indexes.front() : UINT32_MAX;
}
7 changes: 7 additions & 0 deletions lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ class TypeSystemSwift : public TypeSystem {
}
bool
ShouldTreatScalarValueAsAddress(lldb::opaque_compiler_type_t type) override;

/// Lookup a child given a name. This function will match base class names
/// and member names in \p type only, not descendants.
uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
const char *name,
bool omit_empty_base_classes) override;

/// \}
protected:
/// Used in the logs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2306,13 +2306,6 @@ CompilerType TypeSystemSwiftTypeRef::GetChildCompilerTypeAtIndex(
ast_child_is_deref_of_parent, valobj, ast_language_flags));
}

uint32_t
TypeSystemSwiftTypeRef::GetIndexOfChildWithName(opaque_compiler_type_t type,
const char *name,
bool omit_empty_base_classes) {
return m_swift_ast_context->GetIndexOfChildWithName(
ReconstructType(type), name, omit_empty_base_classes);
}
size_t TypeSystemSwiftTypeRef::GetIndexOfChildMemberWithName(
opaque_compiler_type_t type, const char *name, bool omit_empty_base_classes,
std::vector<uint32_t> &child_indexes) {
Expand Down
3 changes: 0 additions & 3 deletions lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@ class TypeSystemSwiftTypeRef : public TypeSystemSwift {
uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset,
bool &child_is_base_class, bool &child_is_deref_of_parent,
ValueObject *valobj, uint64_t &language_flags) override;
uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
const char *name,
bool omit_empty_base_classes) override;
size_t
GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type,
const char *name, bool omit_empty_base_classes,
Expand Down