aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInstance.cpp
diff options
context:
space:
mode:
authorQiongsi Wu <qiongsiwu@gmail.com>2025-08-06 15:39:37 -0700
committerGitHub <noreply@github.com>2025-08-06 15:39:37 -0700
commit09dbdf651470bb4c9e5b81986a47f7c495285fbe (patch)
treeb4cfd19c9195ccf3e167a0df56f53f223bf6fbff /clang/lib/Frontend/CompilerInstance.cpp
parentb296ea9c14af60f9b4faa26a39ecc52c1762c794 (diff)
downloadllvm-09dbdf651470bb4c9e5b81986a47f7c495285fbe.zip
llvm-09dbdf651470bb4c9e5b81986a47f7c495285fbe.tar.gz
llvm-09dbdf651470bb4c9e5b81986a47f7c495285fbe.tar.bz2
[clang][Dependency Scanning] Move Module Timestamp Update After Compilation Finishes (#151774)
When two threads are accessing the same `pcm`, it is possible that the reading thread sees the timestamp update, while the file on disk is not updated. This PR moves timestamp update from `writeAST` to `compileModuleAndReadASTImpl`, so we only update the timestamp after the file has been committed to disk. rdar://152097193
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index d64290f..9f99edad 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -1485,6 +1485,14 @@ static bool compileModuleAndReadASTImpl(CompilerInstance &ImportingInstance,
return false;
}
+ // The module is built successfully, we can update its timestamp now.
+ if (ImportingInstance.getPreprocessor()
+ .getHeaderSearchInfo()
+ .getHeaderSearchOpts()
+ .ModulesValidateOncePerBuildSession) {
+ ImportingInstance.getModuleCache().updateModuleTimestamp(ModuleFileName);
+ }
+
return readASTAfterCompileModule(ImportingInstance, ImportLoc, ModuleNameLoc,
Module, ModuleFileName,
/*OutOfDate=*/nullptr, /*Missing=*/nullptr);