Skip to content

Commit 74d407a

Browse files
committed
fix superclass iteration
1 parent d89aacb commit 74d407a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lldb/source/Target/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,15 +1221,18 @@ llvm::Optional<size_t> SwiftLanguageRuntimeImpl::GetIndexOfChildMemberWithName(
12211221
auto &builder = reflection_ctx->getBuilder();
12221222
auto tc = TypeConverter(builder);
12231223
auto tip = LLDBTypeInfoProvider(*this, *ts);
1224-
auto *class_ti = tc.getClassInstanceTypeInfo(tr, 0, &tip);
1225-
while (auto *record_ti = llvm::cast_or_null<RecordTypeInfo>(class_ti)) {
1226-
auto super_tr = builder.lookupSuperclass(tr);
1227-
uint32_t offset = super_tr ? 1 : 0;
1224+
// The class_tr pointer is used to iterate the class hierarchy, from the
1225+
// current class, each superclass, and ends on null.
1226+
auto *class_tr = tr;
1227+
while (class_tr) {
1228+
auto *record_ti = llvm::cast<RecordTypeInfo>(
1229+
tc.getClassInstanceTypeInfo(tr, 0, &tip));
1230+
class_tr = builder.lookupSuperclass(class_tr);
1231+
uint32_t offset = class_tr ? 1 : 0;
12281232
if (auto size = findFieldWithName(record_ti->getFields(), name,
12291233
child_indexes, offset)) {
12301234
return size;
12311235
}
1232-
class_ti = reflection_ctx->getTypeInfo(super_tr, &tip);
12331236
}
12341237
return {};
12351238
}

0 commit comments

Comments
 (0)