/// along with the module map
llvm::DenseMap<const IdentifierInfo *, Module *> KnownModules;
- /// \brief Module names that have an override for the target file.
- llvm::StringMap<std::string> 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;
/// \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
/// \brief All loaded modules, indexed by name.
llvm::DenseMap<const FileEntry *, ModuleFile *> Modules;
- typedef llvm::SetVector<const FileEntry *> 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;
/// 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<AdditionalKnownModuleFileSet::const_iterator>
- 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
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;
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.
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.
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;
RECORD(MODULE_NAME);
RECORD(MODULE_MAP_FILE);
RECORD(IMPORTS);
- RECORD(KNOWN_MODULE_FILES);
RECORD(LANGUAGE_OPTIONS);
RECORD(TARGET_OPTIONS);
RECORD(ORIGINAL_FILE);
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.
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) {
}
void ModuleManager::moduleFileAccepted(ModuleFile *MF) {
- AdditionalKnownModuleFiles.remove(MF->File);
-
if (!GlobalIndex || GlobalIndex->loadedModuleFile(MF))
return;