Add a few deserialization recovery paths.

This avoids cross-reference modularization error crashes in
lldb/lldb-dap on Windows, seen with our internal app, reported at
https://github.com/apple/swift/issues/69374.
This commit is contained in:
Hiroshi Yamauchi
2023-10-23 16:06:41 -07:00
parent 58a6bfb82e
commit c4864d2395
2 changed files with 29 additions and 8 deletions

View File

@@ -440,7 +440,14 @@ TypeDecl *ModuleFile::lookupNestedType(Identifier name,
Decl *decl = declOrOffset;
if (decl != parent)
continue;
return cast<TypeDecl>(getDecl(entry.second));
Expected<Decl *> typeOrErr = getDeclChecked(entry.second);
if (!typeOrErr) {
if (!getContext().LangOpts.EnableDeserializationRecovery)
fatal(typeOrErr.takeError());
diagnoseAndConsumeError(typeOrErr.takeError());
continue;
}
return cast<TypeDecl>(typeOrErr.get());
}
}
}