Skip to content

Commit d61a0a3

Browse files
author
git apple-llvm automerger
committed
Merge commit 'b4fe124415f4' from swift/release/5.6 into stable/20210726
2 parents 39c2c56 + b4fe124 commit d61a0a3

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

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

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,22 +1561,36 @@ CompilerType SwiftLanguageRuntimeImpl::GetChildCompilerTypeAtIndex(
15611561
NodePointer type_node = dem.demangleSymbol(mangled);
15621562
llvm::StringRef type_name = TypeSystemSwiftTypeRef::GetBaseName(
15631563
ts->CanonicalizeSugar(dem, type_node));
1564+
1565+
auto *reflection_ctx = GetReflectionContext();
1566+
if (!reflection_ctx)
1567+
return {};
1568+
CompilerType instance_type = valobj->GetCompilerType();
1569+
auto *instance_ts =
1570+
llvm::dyn_cast_or_null<TypeSystemSwift>(instance_type.GetTypeSystem());
1571+
if (!instance_ts)
1572+
return {};
1573+
1574+
// LLDBTypeInfoProvider needs to kept alive until as long as supers gets accessed.
15641575
llvm::SmallVector<SuperClassType, 2> supers;
1565-
ForEachSuperClassType(*valobj, [&](SuperClassType sc) -> bool {
1566-
if (!found_start) {
1567-
// The ValueObject always points to the same class instance,
1568-
// even when querying base classes. Drop base classes until we
1569-
// reach the requested type.
1570-
if (auto *tr = sc.get_typeref()) {
1571-
NodePointer base_class = tr->getDemangling(dem);
1572-
if (TypeSystemSwiftTypeRef::GetBaseName(base_class) != type_name)
1573-
return false;
1574-
found_start = true;
1575-
}
1576-
}
1577-
supers.push_back(sc);
1578-
return supers.size() >= 2;
1579-
});
1576+
LLDBTypeInfoProvider tip(*this, *instance_ts);
1577+
lldb::addr_t pointer = valobj->GetPointerValue();
1578+
reflection_ctx->ForEachSuperClassType(
1579+
&tip, pointer, [&](SuperClassType sc) -> bool {
1580+
if (!found_start) {
1581+
// The ValueObject always points to the same class instance,
1582+
// even when querying base classes. Drop base classes until we
1583+
// reach the requested type.
1584+
if (auto *tr = sc.get_typeref()) {
1585+
NodePointer base_class = tr->getDemangling(dem);
1586+
if (TypeSystemSwiftTypeRef::GetBaseName(base_class) != type_name)
1587+
return false;
1588+
found_start = true;
1589+
}
1590+
}
1591+
supers.push_back(sc);
1592+
return supers.size() >= 2;
1593+
});
15801594

15811595
if (supers.size() == 0) {
15821596
LLDB_LOGF(GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES),

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class SwiftLanguageRuntimeImpl {
247247
/// If \p instance points to a Swift object, retrieve its
248248
/// RecordTypeInfo and pass it to the callback \p fn. Repeat the
249249
/// process with all superclasses. If \p fn returns \p true, early
250-
/// exit and return \ptrue. Otherwise return \p false.
250+
/// exit and return \p true. Otherwise return \p false.
251251
bool ForEachSuperClassType(ValueObject &instance,
252252
std::function<bool(SuperClassType)> fn);
253253

0 commit comments

Comments
 (0)