mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[serialization] Remove FALL_BACK_TO_TRANSLATION_UNIT hack.
As a bring-up hack, the module serializer would write a special record, FALL_BACK_TO_TRANSLATION_UNIT, if it encountered something it didn't know how to serialize. This then directed the deserializer to ignore the contents of the module file and instead reload the original source file. Now that we can serialize pretty much everything*, though, we don't need this, and instead we'd rather know where the serialization coverage has gaps (by asserting). Swift SVN r7752
This commit is contained in:
@@ -79,42 +79,6 @@ static llvm::error_code findModule(ASTContext &ctx, AccessPathElem moduleID,
|
||||
return err;
|
||||
}
|
||||
|
||||
static Module *makeTU(ASTContext &ctx, AccessPathElem moduleID,
|
||||
ArrayRef<StringRef> inputPaths) {
|
||||
// FIXME: The kind of the TU should be read from the serialized file.
|
||||
Component *comp = new (ctx.Allocate<Component>(1)) Component();
|
||||
TranslationUnit *TU = new (ctx) TranslationUnit(moduleID.first, comp, ctx,
|
||||
TranslationUnit::Library);
|
||||
|
||||
TU->HasBuiltinModuleAccess = (moduleID.first.str() == "swift");
|
||||
performAutoImport(TU);
|
||||
|
||||
ctx.LoadedModules[moduleID.first.str()] = TU;
|
||||
|
||||
std::vector<unsigned> BufferIDs;
|
||||
for (auto &path : inputPaths) {
|
||||
// Open the input file.
|
||||
llvm::OwningPtr<llvm::MemoryBuffer> InputFile;
|
||||
if (llvm::MemoryBuffer::getFileOrSTDIN(path, InputFile))
|
||||
return nullptr;
|
||||
|
||||
// Transfer ownership of the MemoryBuffer to the SourceMgr.
|
||||
// FIXME: include location
|
||||
BufferIDs.push_back(ctx.SourceMgr.addNewSourceBuffer(InputFile.take(),
|
||||
moduleID.second));
|
||||
}
|
||||
|
||||
for (auto &BufferID : BufferIDs) {
|
||||
bool Done;
|
||||
do {
|
||||
parseIntoTranslationUnit(TU, BufferID, &Done);
|
||||
} while (!Done);
|
||||
}
|
||||
|
||||
performTypeChecking(TU);
|
||||
|
||||
return TU;
|
||||
}
|
||||
|
||||
Module *SerializedModuleLoader::loadModule(SourceLoc importLoc,
|
||||
Module::AccessPathTy path) {
|
||||
@@ -156,8 +120,6 @@ Module *SerializedModuleLoader::loadModule(SourceLoc importLoc,
|
||||
std::unique_ptr<ModuleFile> loadedModuleFile;
|
||||
ModuleStatus err = ModuleFile::load(std::move(inputFile), loadedModuleFile);
|
||||
switch (err) {
|
||||
case ModuleStatus::FallBackToTranslationUnit:
|
||||
return makeTU(Ctx, moduleID, loadedModuleFile->getInputSourcePaths());
|
||||
case ModuleStatus::Valid:
|
||||
Ctx.bumpGeneration();
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user