Make module files passed to a module build via -fmodule-file= available to

consumers of that module.

Previously, such a file would only be available if the module happened to
actually import something from that module.

llvm-svn: 232583
This commit is contained in:
Richard Smith
2015-03-18 01:42:29 +00:00
parent 59aca19708
commit 7f330cdb31
9 changed files with 104 additions and 10 deletions

View File

@@ -227,6 +227,15 @@ 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) {
@@ -263,6 +272,8 @@ void ModuleManager::setGlobalIndex(GlobalModuleIndex *Index) {
}
void ModuleManager::moduleFileAccepted(ModuleFile *MF) {
AdditionalKnownModuleFiles.remove(MF->File);
if (!GlobalIndex || GlobalIndex->loadedModuleFile(MF))
return;