[Serialization] Recover from deserializing an enum from a missing module

rdar://problem/58022345
This commit is contained in:
Alexis Laferrière
2019-12-20 13:56:54 -08:00
parent fdb1926421
commit a4cf567ac4
2 changed files with 22 additions and 2 deletions

View File

@@ -1889,14 +1889,25 @@ DeclContext *ModuleFile::getLocalDeclContext(LocalDeclContextID DCID) {
}
DeclContext *ModuleFile::getDeclContext(DeclContextID DCID) {
auto deserialized = getDeclContextChecked(DCID);
if (!deserialized) {
fatal(deserialized.takeError());
}
return deserialized.get();
}
Expected<DeclContext *> ModuleFile::getDeclContextChecked(DeclContextID DCID) {
if (!DCID)
return FileContext;
if (Optional<LocalDeclContextID> contextID = DCID.getAsLocalDeclContextID())
return getLocalDeclContext(contextID.getValue());
auto D = getDecl(DCID.getAsDeclID().getValue());
auto deserialized = getDeclChecked(DCID.getAsDeclID().getValue());
if (!deserialized)
return deserialized.takeError();
auto D = deserialized.get();
if (auto GTD = dyn_cast<GenericTypeDecl>(D))
return GTD;
if (auto ED = dyn_cast<ExtensionDecl>(D))
@@ -3496,7 +3507,6 @@ public:
numConformances, numInherited,
rawInheritedAndDependencyIDs);
auto DC = MF.getDeclContext(contextID);
if (declOrOffset.isComplete())
return declOrOffset;
@@ -3510,6 +3520,11 @@ public:
}
}
auto DCOrError = MF.getDeclContextChecked(contextID);
if (!DCOrError)
return DCOrError.takeError();
auto DC = DCOrError.get();
auto genericParams = MF.maybeReadGenericParams(DC);
if (declOrOffset.isComplete())
return declOrOffset;