aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2025-05-14 14:31:23 -0700
committerGitHub <noreply@github.com>2025-05-14 14:31:23 -0700
commit960afcc90e8fb75b725ed331f4bc60eb2398d6e5 (patch)
tree9415bb216da3f252bc15f7c43218b695f0238f04 /clang/lib/Frontend
parenta608b4914209f4238fe83a6b5fa8fd7219f11115 (diff)
downloadllvm-960afcc90e8fb75b725ed331f4bc60eb2398d6e5.zip
llvm-960afcc90e8fb75b725ed331f4bc60eb2398d6e5.tar.gz
llvm-960afcc90e8fb75b725ed331f4bc60eb2398d6e5.tar.bz2
[clang][modules] Timestamp-less validation API (#138983)
Timestamps are an implementation detail of the cross-process module cache implementation. This PR hides it from the `ModuleCache` API, which simplifies the in-process implementation.
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp10
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp4
2 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 5a79fe0..eb8483d 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -829,9 +829,10 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
AST->SourceMgr = new SourceManager(AST->getDiagnostics(),
AST->getFileManager(),
UserFilesAreVolatile);
- AST->ModCache = createCrossProcessModuleCache();
AST->HSOpts = std::make_unique<HeaderSearchOptions>(HSOpts);
AST->HSOpts->ModuleFormat = std::string(PCHContainerRdr.getFormats().front());
+ AST->ModCache =
+ createCrossProcessModuleCache(AST->HSOpts->BuildSessionTimestamp);
AST->HeaderInfo.reset(new HeaderSearch(AST->getHeaderSearchOpts(),
AST->getSourceManager(),
AST->getDiagnostics(),
@@ -1548,7 +1549,8 @@ ASTUnit::create(std::shared_ptr<CompilerInvocation> CI,
AST->UserFilesAreVolatile = UserFilesAreVolatile;
AST->SourceMgr = new SourceManager(AST->getDiagnostics(), *AST->FileMgr,
UserFilesAreVolatile);
- AST->ModCache = createCrossProcessModuleCache();
+ AST->ModCache = createCrossProcessModuleCache(
+ AST->Invocation->getHeaderSearchOpts().BuildSessionTimestamp);
return AST;
}
@@ -1834,7 +1836,6 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromCommandLine(
AST->FileMgr = new FileManager(AST->FileSystemOpts, VFS);
AST->StorePreamblesInMemory = StorePreamblesInMemory;
AST->PreambleStoragePath = PreambleStoragePath;
- AST->ModCache = createCrossProcessModuleCache();
AST->OnlyLocalDecls = OnlyLocalDecls;
AST->CaptureDiagnostics = CaptureDiagnostics;
AST->TUKind = TUKind;
@@ -1843,6 +1844,8 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromCommandLine(
= IncludeBriefCommentsInCodeCompletion;
AST->UserFilesAreVolatile = UserFilesAreVolatile;
AST->Invocation = CI;
+ AST->ModCache = createCrossProcessModuleCache(
+ AST->Invocation->getHeaderSearchOpts().BuildSessionTimestamp);
AST->SkipFunctionBodies = SkipFunctionBodies;
if (ForSerialization)
AST->WriterData.reset(new ASTWriterData(*AST->ModCache));
@@ -2378,7 +2381,6 @@ bool ASTUnit::serialize(raw_ostream &OS) {
SmallString<128> Buffer;
llvm::BitstreamWriter Stream(Buffer);
- IntrusiveRefCntPtr<ModuleCache> ModCache = createCrossProcessModuleCache();
ASTWriter Writer(Stream, Buffer, *ModCache, {});
return serializeUnit(Writer, Buffer, getSema(), OS);
}
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 503d364..b3a23e6 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -72,7 +72,9 @@ CompilerInstance::CompilerInstance(
ModuleCache *ModCache)
: ModuleLoader(/*BuildingModule=*/ModCache),
Invocation(std::move(Invocation)),
- ModCache(ModCache ? ModCache : createCrossProcessModuleCache()),
+ ModCache(ModCache ? ModCache
+ : createCrossProcessModuleCache(
+ getHeaderSearchOpts().BuildSessionTimestamp)),
ThePCHContainerOperations(std::move(PCHContainerOps)) {
assert(this->Invocation && "Invocation must not be null");
}