[PATCH] D128257: invalidateCache in addModule and removeModules
Tapasweni Pathak via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 21 04:02:02 PDT 2022
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 <vvasilev at cern.ch>
Submitted-by: Tapasweni Pathak <tapaswenipathak at 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)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128257.438629.patch
Type: text/x-patch
Size: 1368 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220621/c6bfe943/attachment.bin>
More information about the cfe-commits
mailing list