[Serialization] Delay adding ModuleFiles until they're loaded

Rather than adding a ModuleFile to a parent module
and then removing it afterwards if it fails to
load, let's wait until we've loaded the file before
deciding to add it to the parent module. This then
allows us to get rid of `ModuleDecl::removeFile`.

In addition, push down the calls to `addFile` into
the callers of `loadAST` in preparation for
`addFile` being replaced with a one-time-only call
to a `setFiles` method.
This commit is contained in:
Hamish Knight
2020-05-28 12:09:10 -07:00
parent f810cfcc45
commit 6477cc68eb
5 changed files with 21 additions and 27 deletions

View File

@@ -195,6 +195,7 @@ static void indexModule(llvm::MemoryBuffer *Input,
return;
}
Mod->addFile(*FUnit);
Mod->setHasResolvedImports();
}