Skip to content

Commit 5b22e3f

Browse files
committed
[Swift] lldb: Adjust code after result type change in lldb_private::TypeSystem::GetIndexOfChildWithName
See llvm#136693. (cherry picked from commit 61cac61)
1 parent 8b31fb7 commit 5b22e3f

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntime.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,13 +1612,14 @@ class ProjectionSyntheticChildren : public SyntheticChildren {
16121612
return nullptr;
16131613
}
16141614

1615-
size_t GetIndexOfChildWithName(ConstString name) override {
1615+
llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
16161616
for (size_t idx = 0; idx < m_projection->field_projections.size();
16171617
idx++) {
16181618
if (m_projection->field_projections.at(idx).name == name)
16191619
return idx;
16201620
}
1621-
return UINT32_MAX;
1621+
return llvm::createStringError("Type has no child named '%s'",
1622+
name.AsCString());
16221623
}
16231624

16241625
lldb::ChildCacheState Update() override {

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,19 @@ bool TypeSystemSwift::ShouldTreatScalarValueAsAddress(
154154
.AnySet(eTypeInstanceIsPointer | eTypeIsReference);
155155
}
156156

157-
uint32_t TypeSystemSwift::GetIndexOfChildWithName(
157+
llvm::Expected<uint32_t> TypeSystemSwift::GetIndexOfChildWithName(
158158
opaque_compiler_type_t type, llvm::StringRef name,
159159
ExecutionContext *exe_ctx, bool omit_empty_base_classes) {
160160
std::vector<uint32_t> child_indexes;
161161
size_t num_child_indexes = GetIndexOfChildMemberWithName(
162162
type, name, exe_ctx, omit_empty_base_classes, child_indexes);
163-
return num_child_indexes == 1 ? child_indexes.front() : UINT32_MAX;
163+
164+
if (num_child_indexes == 1) {
165+
return child_indexes.front();
166+
}
167+
168+
return llvm::createStringError("Type has no child named '%s'",
169+
name.str().c_str());
164170
}
165171

166172
lldb::Format TypeSystemSwift::GetFormat(opaque_compiler_type_t type) {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,10 @@ class TypeSystemSwift : public TypeSystem {
327327

328328
/// Lookup a child given a name. This function will match base class names
329329
/// and member names in \p type only, not descendants.
330-
uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
331-
llvm::StringRef name,
332-
ExecutionContext *exe_ctx,
333-
bool omit_empty_base_classes) override;
330+
llvm::Expected<uint32_t>
331+
GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
332+
llvm::StringRef name, ExecutionContext *exe_ctx,
333+
bool omit_empty_base_classes) override;
334334

335335
CompilerType
336336
GetLValueReferenceType(lldb::opaque_compiler_type_t type) override {

0 commit comments

Comments
 (0)