diff --git a/clang/include/clang/Serialization/ModuleManager.h b/clang/include/clang/Serialization/ModuleManager.h --- a/clang/include/clang/Serialization/ModuleManager.h +++ b/clang/include/clang/Serialization/ModuleManager.h @@ -59,8 +59,8 @@ // to implement short-circuiting logic when running DFS over the dependencies. SmallVector Roots; - /// All loaded modules, indexed by name. - llvm::DenseMap Modules; + /// All loaded modules, indexed by file name. + llvm::StringMap Modules; /// FileManager that handles translating between filenames and /// FileEntry *. diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp --- a/clang/lib/Serialization/ModuleManager.cpp +++ b/clang/lib/Serialization/ModuleManager.cpp @@ -59,7 +59,7 @@ } ModuleFile *ModuleManager::lookup(const FileEntry *File) const { - auto Known = Modules.find(File); + auto Known = Modules.find(File->tryGetRealPathName()); if (Known == Modules.end()) return nullptr; @@ -133,7 +133,8 @@ } // Check whether we already loaded this module, before - if (ModuleFile *ModuleEntry = Modules.lookup(Entry)) { + auto EntryKey = Entry ? Entry->tryGetRealPathName() : FileName; + if (ModuleFile *ModuleEntry = Modules.lookup(EntryKey)) { // Check the stored signature. if (checkSignature(ModuleEntry->Signature, ExpectedSignature, ErrorStr)) return OutOfDate; @@ -208,7 +209,7 @@ return OutOfDate; // We're keeping this module. Store it everywhere. - Module = Modules[Entry] = NewModule.get(); + Module = Modules[EntryKey] = NewModule.get(); updateModuleImports(*NewModule, ImportedBy, ImportLoc); @@ -255,7 +256,7 @@ // Delete the modules and erase them from the various structures. for (ModuleIterator victim = First; victim != Last; ++victim) { - Modules.erase(victim->File); + Modules.erase(victim->File->tryGetRealPathName()); if (modMap) { StringRef ModuleName = victim->ModuleName;