@@ -1470,9 +1470,11 @@ bool SwiftLanguageRuntimeImpl::ForEachSuperClassType(
1470
1470
ExecutionContext exe_ctx (instance.GetExecutionContextRef ());
1471
1471
LLDBTypeInfoProvider tip (*this , &exe_ctx);
1472
1472
lldb::addr_t pointer = instance.GetPointerValue ();
1473
+ auto tr_ts = ts->GetTypeSystemSwiftTypeRef ();
1474
+ if (!tr_ts)
1475
+ return false ;
1473
1476
return reflection_ctx->ForEachSuperClassType (
1474
- &tip, ts->GetTypeSystemSwiftTypeRef ().GetDescriptorFinder (),
1475
- pointer, fn);
1477
+ &tip, tr_ts->GetDescriptorFinder (), pointer, fn);
1476
1478
}
1477
1479
1478
1480
bool SwiftLanguageRuntime::IsSelf (Variable &variable) {
@@ -1803,7 +1805,9 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Class(
1803
1805
if (!tss)
1804
1806
return false ;
1805
1807
address.SetRawAddress (instance_ptr);
1806
- auto &ts = tss->GetTypeSystemSwiftTypeRef ();
1808
+ auto ts = tss->GetTypeSystemSwiftTypeRef ();
1809
+ if (!ts)
1810
+ return false ;
1807
1811
// Ask the Objective-C runtime about Objective-C types.
1808
1812
if (tss->IsImportedType (class_type.GetOpaqueQualType (), nullptr ))
1809
1813
if (auto *objc_runtime = SwiftLanguageRuntime::GetObjCRuntime (m_process)) {
@@ -1820,7 +1824,7 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Class(
1820
1824
// useful to users.
1821
1825
if (IsPrivateNSClass (node))
1822
1826
return false ;
1823
- class_type_or_name.SetCompilerType (ts. RemangleAsType (dem, node));
1827
+ class_type_or_name.SetCompilerType (ts-> RemangleAsType (dem, node));
1824
1828
found = true ;
1825
1829
return true ;
1826
1830
}
@@ -1836,14 +1840,14 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Class(
1836
1840
return false ;
1837
1841
1838
1842
const auto *typeref = reflection_ctx->ReadTypeFromInstance (
1839
- instance_ptr, ts. GetDescriptorFinder (), true );
1843
+ instance_ptr, ts-> GetDescriptorFinder (), true );
1840
1844
1841
1845
// If we couldn't find the typeref from the instance, the best we can do is
1842
1846
// use the static type. This is a valid use case when the binary doesn't
1843
1847
// contain any metadata (for example, embedded Swift).
1844
- if (!typeref)
1848
+ if (!typeref)
1845
1849
typeref = reflection_ctx->GetTypeRefOrNull (class_type.GetMangledTypeName (),
1846
- ts. GetDescriptorFinder ());
1850
+ ts-> GetDescriptorFinder ());
1847
1851
1848
1852
if (!typeref) {
1849
1853
HEALTH_LOG (" could not read typeref for type: {0} (instance_ptr = {0:x})" ,
@@ -1852,7 +1856,7 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Class(
1852
1856
}
1853
1857
swift::Demangle::Demangler dem;
1854
1858
swift::Demangle::NodePointer node = typeref->getDemangling (dem);
1855
- CompilerType dynamic_type = ts. RemangleAsType (dem, node);
1859
+ CompilerType dynamic_type = ts-> RemangleAsType (dem, node);
1856
1860
LLDB_LOG (log, " dynamic type of instance_ptr {0:x} is {1}" , instance_ptr,
1857
1861
class_type.GetMangledTypeName ());
1858
1862
class_type_or_name.SetCompilerType (dynamic_type);
@@ -1950,7 +1954,7 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Existential(
1950
1954
}
1951
1955
1952
1956
const swift::reflection::TypeRef *existential_typeref =
1953
- GetTypeRef (existential_type, & tss->GetTypeSystemSwiftTypeRef ());
1957
+ GetTypeRef (existential_type, tss->GetTypeSystemSwiftTypeRef (). get ());
1954
1958
if (!existential_typeref) {
1955
1959
if (log)
1956
1960
log->Printf (" Could not get existential typeref" );
@@ -1995,10 +1999,12 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Existential(
1995
1999
ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ();
1996
2000
if (!reflection_ctx)
1997
2001
return false ;
1998
-
2002
+ auto tr_ts = tss->GetTypeSystemSwiftTypeRef ();
2003
+ if (!tr_ts)
2004
+ return false ;
1999
2005
auto pair = reflection_ctx->ProjectExistentialAndUnwrapClass (
2000
2006
remote_existential, *existential_typeref,
2001
- tss-> GetTypeSystemSwiftTypeRef (). GetDescriptorFinder ());
2007
+ tr_ts-> GetDescriptorFinder ());
2002
2008
if (use_local_buffer)
2003
2009
PopLocalBuffer ();
2004
2010
@@ -2011,10 +2017,12 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Existential(
2011
2017
const swift::reflection::TypeRef *typeref;
2012
2018
swift::remote::RemoteAddress out_address (nullptr );
2013
2019
std::tie (typeref, out_address) = *pair;
2014
- auto &ts = tss->GetTypeSystemSwiftTypeRef ();
2020
+ auto ts = tss->GetTypeSystemSwiftTypeRef ();
2021
+ if (!ts)
2022
+ return false ;
2015
2023
swift::Demangle::Demangler dem;
2016
2024
swift::Demangle::NodePointer node = typeref->getDemangling (dem);
2017
- class_type_or_name.SetCompilerType (ts. RemangleAsType (dem, node));
2025
+ class_type_or_name.SetCompilerType (ts-> RemangleAsType (dem, node));
2018
2026
address.SetRawAddress (out_address.getAddressData ());
2019
2027
2020
2028
#ifndef NDEBUG
@@ -2057,9 +2065,12 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_ExistentialMetatype(
2057
2065
if (!tss)
2058
2066
return false ;
2059
2067
2068
+ auto tr_ts = tss->GetTypeSystemSwiftTypeRef ();
2069
+ if (!tr_ts)
2070
+ return false ;
2071
+
2060
2072
const swift::reflection::TypeRef *type_ref =
2061
- reflection_ctx->ReadTypeFromMetadata (
2062
- ptr, tss->GetTypeSystemSwiftTypeRef ().GetDescriptorFinder ());
2073
+ reflection_ctx->ReadTypeFromMetadata (ptr, tr_ts->GetDescriptorFinder ());
2063
2074
2064
2075
if (!type_ref)
2065
2076
return false ;
@@ -2076,7 +2087,7 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_ExistentialMetatype(
2076
2087
meta->addChild (node, dem);
2077
2088
wrapped->addChild (meta,dem);
2078
2089
2079
- meta_type = tss-> GetTypeSystemSwiftTypeRef (). RemangleAsType (dem, wrapped);
2090
+ meta_type = tr_ts-> RemangleAsType (dem, wrapped);
2080
2091
class_type_or_name.SetCompilerType (meta_type);
2081
2092
address.SetRawAddress (ptr);
2082
2093
return true ;
@@ -2092,14 +2103,17 @@ CompilerType SwiftLanguageRuntimeImpl::GetTypeFromMetadata(TypeSystemSwift &ts,
2092
2103
if (!reflection_ctx)
2093
2104
return {};
2094
2105
2106
+ auto tr_ts = ts.GetTypeSystemSwiftTypeRef ();
2107
+ if (!tr_ts)
2108
+ return {};
2109
+
2095
2110
const swift::reflection::TypeRef *type_ref =
2096
- reflection_ctx->ReadTypeFromMetadata (
2097
- ptr, ts.GetTypeSystemSwiftTypeRef ().GetDescriptorFinder ());
2111
+ reflection_ctx->ReadTypeFromMetadata (ptr, tr_ts->GetDescriptorFinder ());
2098
2112
2099
2113
using namespace swift ::Demangle;
2100
2114
Demangler dem;
2101
2115
NodePointer node = type_ref->getDemangling (dem);
2102
- return ts. GetTypeSystemSwiftTypeRef (). RemangleAsType (dem, node);
2116
+ return tr_ts-> RemangleAsType (dem, node);
2103
2117
}
2104
2118
2105
2119
std::optional<lldb::addr_t >
@@ -2171,9 +2185,13 @@ CompilerType SwiftLanguageRuntimeImpl::BindGenericTypeParameters(
2171
2185
Demangler dem;
2172
2186
NodePointer unbound_node =
2173
2187
dem.demangleSymbol (unbound_type.GetMangledTypeName ().GetStringRef ());
2188
+
2189
+ auto tr_ts = ts->GetTypeSystemSwiftTypeRef ();
2190
+ if (!tr_ts)
2191
+ return unbound_type;
2192
+
2174
2193
auto type_ref = reflection_ctx->GetTypeRefOrNull (
2175
- dem, unbound_node,
2176
- ts->GetTypeSystemSwiftTypeRef ().GetDescriptorFinder ());
2194
+ dem, unbound_node, tr_ts->GetDescriptorFinder ());
2177
2195
if (!type_ref) {
2178
2196
LLDB_LOG (GetLog (LLDBLog::Expressions | LLDBLog::Types),
2179
2197
" Couldn't get TypeRef of unbound type" );
@@ -2198,7 +2216,7 @@ CompilerType SwiftLanguageRuntimeImpl::BindGenericTypeParameters(
2198
2216
2199
2217
const auto *type_ref = reflection_ctx->GetTypeRefOrNull (
2200
2218
type.GetMangledTypeName ().GetStringRef (),
2201
- ts-> GetTypeSystemSwiftTypeRef (). GetDescriptorFinder ());
2219
+ tr_ts-> GetDescriptorFinder ());
2202
2220
if (!type_ref) {
2203
2221
LLDB_LOG (GetLog (LLDBLog::Expressions | LLDBLog::Types),
2204
2222
" Couldn't get TypeRef when binding generic type parameters." );
@@ -2216,9 +2234,9 @@ CompilerType SwiftLanguageRuntimeImpl::BindGenericTypeParameters(
2216
2234
const swift::reflection::TypeRef *bound_type_ref =
2217
2235
reflection_ctx->ApplySubstitutions (
2218
2236
type_ref, substitutions,
2219
- ts-> GetTypeSystemSwiftTypeRef (). GetDescriptorFinder ());
2237
+ tr_ts-> GetDescriptorFinder ());
2220
2238
NodePointer node = bound_type_ref->getDemangling (dem);
2221
- return ts-> GetTypeSystemSwiftTypeRef (). RemangleAsType (dem, node);
2239
+ return tr_ts-> RemangleAsType (dem, node);
2222
2240
}
2223
2241
2224
2242
CompilerType
@@ -2932,6 +2950,9 @@ SwiftLanguageRuntimeImpl::GetTypeRef(CompilerType type,
2932
2950
if (it != known_types_with_redefined_modules.end ())
2933
2951
mangled_name = it->second ;
2934
2952
2953
+ if (!module_holder)
2954
+ return nullptr ;
2955
+
2935
2956
swift::Demangle::NodePointer node =
2936
2957
module_holder->GetCanonicalDemangleTree (dem, mangled_name);
2937
2958
if (!node)
@@ -2971,6 +2992,9 @@ SwiftLanguageRuntimeImpl::GetSwiftRuntimeTypeInfo(
2971
2992
auto ts = type.GetTypeSystem ().dyn_cast_or_null <TypeSystemSwift>();
2972
2993
if (!ts)
2973
2994
return nullptr ;
2995
+ auto tr_ts = ts->GetTypeSystemSwiftTypeRef ();
2996
+ if (!tr_ts)
2997
+ return nullptr ;
2974
2998
2975
2999
// Resolve all type aliases.
2976
3000
type = type.GetCanonicalType ();
@@ -2988,8 +3012,7 @@ SwiftLanguageRuntimeImpl::GetSwiftRuntimeTypeInfo(
2988
3012
// BindGenericTypeParameters imports the type into the scratch
2989
3013
// context, but we need to resolve (any DWARF links in) the typeref
2990
3014
// in the original module.
2991
- const swift::reflection::TypeRef *type_ref =
2992
- GetTypeRef (type, &ts->GetTypeSystemSwiftTypeRef ());
3015
+ const swift::reflection::TypeRef *type_ref = GetTypeRef (type, tr_ts.get ());
2993
3016
if (!type_ref)
2994
3017
return nullptr ;
2995
3018
@@ -3001,9 +3024,8 @@ SwiftLanguageRuntimeImpl::GetSwiftRuntimeTypeInfo(
3001
3024
return nullptr ;
3002
3025
3003
3026
LLDBTypeInfoProvider provider (*this , exe_scope);
3004
- return reflection_ctx->GetTypeInfo (
3005
- type_ref, &provider,
3006
- ts->GetTypeSystemSwiftTypeRef ().GetDescriptorFinder ());
3027
+ return reflection_ctx->GetTypeInfo (type_ref, &provider,
3028
+ tr_ts->GetDescriptorFinder ());
3007
3029
}
3008
3030
3009
3031
bool SwiftLanguageRuntimeImpl::IsStoredInlineInBuffer (CompilerType type) {
0 commit comments