Skip to content

Commit 16bcb30

Browse files
committed
Adapt to upstream changes introducing type lookup errors.
1 parent 79ebfdf commit 16bcb30

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

lldb/source/Target/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,13 +1222,23 @@ CompilerType SwiftLanguageRuntimeImpl::DoArchetypeBindingForTypeRef(
12221222
});
12231223

12241224
// Nothing to do if there are no type parameters.
1225-
if (substitutions.empty())
1225+
auto get_canonical = [&]() {
12261226
return ts.GetTypeFromMangledTypename(ConstString(mangleNode(canonical)));
1227+
};
1228+
if (substitutions.empty())
1229+
return get_canonical();
12271230

12281231
// Build a TypeRef from the demangle tree.
1229-
const swift::reflection::TypeRef *type_ref =
1230-
swift::Demangle::decodeMangledType(reflection_ctx->getBuilder(),
1231-
canonical);
1232+
auto type_ref_or_err =
1233+
swift::Demangle::decodeMangledType(reflection_ctx->getBuilder(),
1234+
canonical);
1235+
if (type_ref_or_err.isError()) {
1236+
LLDB_LOG(
1237+
GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_TYPES),
1238+
"Couldn't get TypeRef");
1239+
return get_canonical();
1240+
}
1241+
const swift::reflection::TypeRef *type_ref = type_ref_or_err.getType();
12321242

12331243
// Apply the substitutions.
12341244
const swift::reflection::TypeRef *bound_type_ref =
@@ -1960,8 +1970,11 @@ SwiftLanguageRuntimeImpl::GetTypeRef(CompilerType type, Module *module) {
19601970
if (!reflection_ctx)
19611971
return nullptr;
19621972

1963-
const swift::reflection::TypeRef *type_ref =
1964-
swift::Demangle::decodeMangledType(reflection_ctx->getBuilder(), node);
1973+
auto type_ref_or_err =
1974+
swift::Demangle::decodeMangledType(reflection_ctx->getBuilder(), node);
1975+
if (type_ref_or_err.isError())
1976+
return nullptr;
1977+
const swift::reflection::TypeRef *type_ref = type_ref_or_err.getType();
19651978
return type_ref;
19661979
}
19671980

0 commit comments

Comments
 (0)