tapaswenipathak created this revision. tapaswenipathak added a reviewer: v.g.vassilev. tapaswenipathak added a project: clang. Herald added a project: All. tapaswenipathak requested review of this revision. Herald added a subscriber: cfe-commits.
Ref: https://github.com/vgvassilev/clang/commit/758e42e823. It can have a test adding `FileManagerTestHelper` as a `friend` function and checking on a few variables. Should it be added? Pre: https://reviews.llvm.org/D126266. Authored-by: Vassil Vassilev <vvasi...@cern.ch> Submitted-by: Tapasweni Pathak <tapaswenipat...@gmail.com> Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D128257 Files: clang/lib/Serialization/ModuleManager.cpp Index: clang/lib/Serialization/ModuleManager.cpp =================================================================== --- clang/lib/Serialization/ModuleManager.cpp +++ clang/lib/Serialization/ModuleManager.cpp @@ -232,9 +232,15 @@ // Read the signature eagerly now so that we can check it. Avoid calling // ReadSignature unless there's something to check though. if (ExpectedSignature && checkSignature(ReadSignature(NewModule->Data), - ExpectedSignature, ErrorStr)) + ExpectedSignature, ErrorStr)) { + // Try to remove the buffer. If it can't be removed, then it was already + // validated by this process. + if (!getModuleCache().tryToDropPCM(NewModule->FileName)) { + const FileEntry *FE = NewModule->File; + FileMgr.invalidateCache(const_cast<FileEntry *>(FE)); + } return OutOfDate; - + } // We're keeping this module. Store it everywhere. Module = Modules[Entry] = NewModule.get(); @@ -284,6 +290,8 @@ for (ModuleIterator victim = First; victim != Last; ++victim) { Modules.erase(victim->File); + const FileEntry *FE = victim->File; + FileMgr.invalidateCache(const_cast<FileEntry *>(FE)); if (modMap) { StringRef ModuleName = victim->ModuleName; if (Module *mod = modMap->findModule(ModuleName)) {
Index: clang/lib/Serialization/ModuleManager.cpp =================================================================== --- clang/lib/Serialization/ModuleManager.cpp +++ clang/lib/Serialization/ModuleManager.cpp @@ -232,9 +232,15 @@ // Read the signature eagerly now so that we can check it. Avoid calling // ReadSignature unless there's something to check though. if (ExpectedSignature && checkSignature(ReadSignature(NewModule->Data), - ExpectedSignature, ErrorStr)) + ExpectedSignature, ErrorStr)) { + // Try to remove the buffer. If it can't be removed, then it was already + // validated by this process. + if (!getModuleCache().tryToDropPCM(NewModule->FileName)) { + const FileEntry *FE = NewModule->File; + FileMgr.invalidateCache(const_cast<FileEntry *>(FE)); + } return OutOfDate; - + } // We're keeping this module. Store it everywhere. Module = Modules[Entry] = NewModule.get(); @@ -284,6 +290,8 @@ for (ModuleIterator victim = First; victim != Last; ++victim) { Modules.erase(victim->File); + const FileEntry *FE = victim->File; + FileMgr.invalidateCache(const_cast<FileEntry *>(FE)); if (modMap) { StringRef ModuleName = victim->ModuleName; if (Module *mod = modMap->findModule(ModuleName)) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits