Merge pull request #41647 from xymus/recover-from-anyobject-lookup

[Serialization] Recover from failures under AnyObjectLookup
This commit is contained in:
Alexis Laferrière
2022-03-04 11:07:44 -05:00
committed by GitHub
4 changed files with 64 additions and 3 deletions

View File

@@ -774,7 +774,15 @@ void ModuleFile::lookupClassMember(ImportPath::Access accessPath,
// one.
if (name.isSimpleName()) {
for (auto item : *iter) {
auto vd = cast<ValueDecl>(getDecl(item.second));
auto declOrError = getDeclChecked(item.second);
if (!declOrError) {
if (!getContext().LangOpts.EnableDeserializationRecovery)
fatal(declOrError.takeError());
consumeError(declOrError.takeError());
continue;
}
auto vd = cast<ValueDecl>(declOrError.get());
auto dc = vd->getDeclContext();
while (!dc->getParent()->isModuleScopeContext())
dc = dc->getParent();
@@ -784,7 +792,15 @@ void ModuleFile::lookupClassMember(ImportPath::Access accessPath,
}
} else {
for (auto item : *iter) {
auto vd = cast<ValueDecl>(getDecl(item.second));
auto declOrError = getDeclChecked(item.second);
if (!declOrError) {
if (!getContext().LangOpts.EnableDeserializationRecovery)
fatal(declOrError.takeError());
consumeError(declOrError.takeError());
continue;
}
auto vd = cast<ValueDecl>(declOrError.get());
if (!vd->getName().matchesRef(name))
continue;
@@ -800,7 +816,15 @@ void ModuleFile::lookupClassMember(ImportPath::Access accessPath,
}
for (auto item : *iter) {
auto vd = cast<ValueDecl>(getDecl(item.second));
auto declOrError = getDeclChecked(item.second);
if (!declOrError) {
if (!getContext().LangOpts.EnableDeserializationRecovery)
fatal(declOrError.takeError());
consumeError(declOrError.takeError());
continue;
}
auto vd = cast<ValueDecl>(declOrError.get());
results.push_back(vd);
}
}
@@ -818,6 +842,8 @@ void ModuleFile::lookupClassMembers(ImportPath::Access accessPath,
for (auto item : list) {
auto decl = getDeclChecked(item.second);
if (!decl) {
if (!getContext().LangOpts.EnableDeserializationRecovery)
fatal(decl.takeError());
llvm::consumeError(decl.takeError());
continue;
}
@@ -839,6 +865,8 @@ void ModuleFile::lookupClassMembers(ImportPath::Access accessPath,
for (auto item : list) {
auto decl = getDeclChecked(item.second);
if (!decl) {
if (!getContext().LangOpts.EnableDeserializationRecovery)
fatal(decl.takeError());
llvm::consumeError(decl.takeError());
continue;
}