From 0c7d30c23e0dca9bd7f62c2299be3dc652eb2fab Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sun, 9 Aug 2015 08:58:36 +0000 Subject: [PATCH] [modules] Remove now-dead code for lazy loading of files specified by -fmodule-file=. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244417 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Frontend/CompilerInstance.h | 7 ------- include/clang/Serialization/ASTBitCodes.h | 4 ---- include/clang/Serialization/ModuleManager.h | 19 ------------------- lib/Frontend/CompilerInstance.cpp | 20 +++----------------- lib/Serialization/ASTReader.cpp | 17 ----------------- lib/Serialization/ASTWriter.cpp | 10 ---------- lib/Serialization/ModuleManager.cpp | 11 ----------- 7 files changed, 3 insertions(+), 85 deletions(-) diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h index 45e5ed1204..99a9d733d2 100644 --- a/include/clang/Frontend/CompilerInstance.h +++ b/include/clang/Frontend/CompilerInstance.h @@ -126,13 +126,6 @@ class CompilerInstance : public ModuleLoader { /// along with the module map llvm::DenseMap KnownModules; - /// \brief Module names that have an override for the target file. - llvm::StringMap ModuleFileOverrides; - - /// \brief Module files that we've explicitly loaded via \ref loadModuleFile, - /// and their dependencies. - llvm::StringSet<> ExplicitlyLoadedModuleFiles; - /// \brief The location of the module-import keyword for the last module /// import. SourceLocation LastModuleImportLoc; diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h index ea3a9c203b..7edf2704c8 100644 --- a/include/clang/Serialization/ASTBitCodes.h +++ b/include/clang/Serialization/ASTBitCodes.h @@ -296,10 +296,6 @@ namespace clang { /// \brief Record code for the module build directory. MODULE_DIRECTORY = 16, - - /// \brief Record code for the list of other AST files made available by - /// this AST file but not actually used by it. - KNOWN_MODULE_FILES = 17, }; /// \brief Record types that occur within the input-files block diff --git a/include/clang/Serialization/ModuleManager.h b/include/clang/Serialization/ModuleManager.h index 8b879ab18e..08e7d4049e 100644 --- a/include/clang/Serialization/ModuleManager.h +++ b/include/clang/Serialization/ModuleManager.h @@ -46,12 +46,6 @@ class ModuleManager { /// \brief All loaded modules, indexed by name. llvm::DenseMap Modules; - typedef llvm::SetVector AdditionalKnownModuleFileSet; - - /// \brief Additional module files that are known but not loaded. Tracked - /// here so that we can re-export them if necessary. - AdditionalKnownModuleFileSet AdditionalKnownModuleFiles; - /// \brief FileManager that handles translating between filenames and /// FileEntry *. FileManager &FileMgr; @@ -242,19 +236,6 @@ public: /// has been "accepted", and will not (can not) be unloaded. void moduleFileAccepted(ModuleFile *MF); - /// \brief Notification from the frontend that the given module file is - /// part of this compilation (even if not imported) and, if this compilation - /// is exported, should be made available to importers of it. - bool addKnownModuleFile(StringRef FileName); - - /// \brief Get a list of additional module files that are not currently - /// loaded but are considered to be part of the current compilation. - llvm::iterator_range - getAdditionalKnownModuleFiles() { - return llvm::make_range(AdditionalKnownModuleFiles.begin(), - AdditionalKnownModuleFiles.end()); - } - /// \brief Visit each of the modules. /// /// This routine visits each of the modules, starting with the diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index 7d9efd4e9b..740f1db825 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -1372,13 +1372,8 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, return ModuleLoadResult(); } - // FIXME: Rmove ModuleFileOverrides - auto Override = ModuleFileOverrides.find(ModuleName); - bool Explicit = Override != ModuleFileOverrides.end(); - std::string ModuleFileName = - Explicit ? Override->second - : PP->getHeaderSearchInfo().getModuleFileName(Module); + PP->getHeaderSearchInfo().getModuleFileName(Module); if (ModuleFileName.empty()) { getDiagnostics().Report(ModuleNameLoc, diag::err_module_build_disabled) << ModuleName; @@ -1396,24 +1391,15 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, llvm::TimeRegion TimeLoading(FrontendTimerGroup ? &Timer : nullptr); // Try to load the module file. - unsigned ARRFlags = - Explicit ? 0 : ASTReader::ARR_OutOfDate | ASTReader::ARR_Missing; + unsigned ARRFlags = ASTReader::ARR_OutOfDate | ASTReader::ARR_Missing; switch (ModuleManager->ReadAST(ModuleFileName, - Explicit ? serialization::MK_ExplicitModule - : serialization::MK_ImplicitModule, + serialization::MK_ImplicitModule, ImportLoc, ARRFlags)) { case ASTReader::Success: break; case ASTReader::OutOfDate: case ASTReader::Missing: { - if (Explicit) { - // ReadAST has already complained for us. - ModuleLoader::HadFatalFailure = true; - KnownModules[Path[0].first] = nullptr; - return ModuleLoadResult(); - } - // The module file is missing or out-of-date. Build it. assert(Module && "missing module file"); // Check whether there is a cycle in the module graph. diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 29a935c909..b951b578ab 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -2227,9 +2227,6 @@ ASTReader::ReadControlBlock(ModuleFile &F, break; } - case KNOWN_MODULE_FILES: - break; - case LANGUAGE_OPTIONS: { bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0; // FIXME: The &F == *ModuleMgr.begin() check is wrong for modules. @@ -4215,20 +4212,6 @@ bool ASTReader::readASTFileControlBlock( break; } - case KNOWN_MODULE_FILES: { - // Known-but-not-technically-used module files are treated as imports. - if (!NeedsImports) - break; - - unsigned Idx = 0, N = Record.size(); - while (Idx < N) { - std::string Filename = ReadString(Record, Idx); - ResolveImportedPath(Filename, ModuleDir); - Listener.visitImport(Filename); - } - break; - } - default: // No other validation to perform. break; diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 366d4b39fc..0a731f0d94 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -877,7 +877,6 @@ void ASTWriter::WriteBlockInfoBlock() { RECORD(MODULE_NAME); RECORD(MODULE_MAP_FILE); RECORD(IMPORTS); - RECORD(KNOWN_MODULE_FILES); RECORD(LANGUAGE_OPTIONS); RECORD(TARGET_OPTIONS); RECORD(ORIGINAL_FILE); @@ -1245,15 +1244,6 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context, AddPath(M->FileName, Record); } Stream.EmitRecord(IMPORTS, Record); - - // Also emit a list of known module files that were not imported, - // but are made available by this module. - // FIXME: Should we also include a signature here? - Record.clear(); - for (auto *E : Mgr.getAdditionalKnownModuleFiles()) - AddPath(E->getName(), Record); - if (!Record.empty()) - Stream.EmitRecord(KNOWN_MODULE_FILES, Record); } // Language options. diff --git a/lib/Serialization/ModuleManager.cpp b/lib/Serialization/ModuleManager.cpp index 895743f60e..f9d0fa469b 100644 --- a/lib/Serialization/ModuleManager.cpp +++ b/lib/Serialization/ModuleManager.cpp @@ -249,15 +249,6 @@ ModuleManager::addInMemoryBuffer(StringRef FileName, InMemoryBuffers[Entry] = std::move(Buffer); } -bool ModuleManager::addKnownModuleFile(StringRef FileName) { - const FileEntry *File; - if (lookupModuleFile(FileName, 0, 0, File)) - return true; - if (!Modules.count(File)) - AdditionalKnownModuleFiles.insert(File); - return false; -} - ModuleManager::VisitState *ModuleManager::allocateVisitState() { // Fast path: if we have a cached state, use it. if (FirstVisitState) { @@ -294,8 +285,6 @@ void ModuleManager::setGlobalIndex(GlobalModuleIndex *Index) { } void ModuleManager::moduleFileAccepted(ModuleFile *MF) { - AdditionalKnownModuleFiles.remove(MF->File); - if (!GlobalIndex || GlobalIndex->loadedModuleFile(MF)) return; -- 2.40.0