@@ -1222,13 +1222,23 @@ CompilerType SwiftLanguageRuntimeImpl::DoArchetypeBindingForTypeRef(
1222
1222
});
1223
1223
1224
1224
// Nothing to do if there are no type parameters.
1225
- if (substitutions. empty ())
1225
+ auto get_canonical = [&]() {
1226
1226
return ts.GetTypeFromMangledTypename (ConstString (mangleNode (canonical)));
1227
+ };
1228
+ if (substitutions.empty ())
1229
+ return get_canonical ();
1227
1230
1228
1231
// 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 ();
1232
1242
1233
1243
// Apply the substitutions.
1234
1244
const swift::reflection::TypeRef *bound_type_ref =
@@ -1960,8 +1970,11 @@ SwiftLanguageRuntimeImpl::GetTypeRef(CompilerType type, Module *module) {
1960
1970
if (!reflection_ctx)
1961
1971
return nullptr ;
1962
1972
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 ();
1965
1978
return type_ref;
1966
1979
}
1967
1980
0 commit comments