Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 081cef3

Browse files
committed
[lldb] Lift GetIndexOfChildWithName into TypeSystemSwift base class
1 parent 2a12a45 commit 081cef3

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

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

-15
Original file line numberDiff line numberDiff line change
@@ -7442,21 +7442,6 @@ size_t SwiftASTContext::GetIndexOfChildMemberWithName(
74427442
return 0;
74437443
}
74447444

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

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

-6
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

+13
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,16 @@ bool TypeSystemSwift::ShouldTreatScalarValueAsAddress(
101101
return Flags(GetTypeInfo(type, nullptr))
102102
.AnySet(eTypeInstanceIsPointer | eTypeIsReference);
103103
}
104+
105+
/// Get the index of the child of "clang_type" whose name matches. This function
106+
/// doesn't descend into the children, but only looks one level deep and name
107+
/// matches can include base class names.
108+
uint32_t
109+
TypeSystemSwift::GetIndexOfChildWithName(opaque_compiler_type_t type,
110+
const char *name,
111+
bool omit_empty_base_classes) {
112+
std::vector<uint32_t> child_indexes;
113+
size_t num_child_indexes = GetIndexOfChildMemberWithName(
114+
type, name, omit_empty_base_classes, child_indexes);
115+
return num_child_indexes == 1 ? child_indexes.front() : UINT32_MAX;
116+
}

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

+7
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 "clang_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.

0 commit comments

Comments
 (0)