[clang] [clang] Introduce `ModuleCache::write()` (PR #188877)
Qiongsi Wu via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 30 16:49:29 PDT 2026
================
@@ -101,6 +101,39 @@ void clang::maybePruneImpl(StringRef Path, time_t PruneInterval,
}
}
+std::error_code clang::writeImpl(StringRef Path, llvm::MemoryBufferRef Buffer) {
+ StringRef Extension = llvm::sys::path::extension(Path);
+ SmallString<128> ModelPath = StringRef(Path).drop_back(Extension.size());
+ ModelPath += "-%%%%%%%%";
+ ModelPath += Extension;
+ ModelPath += ".tmp";
+
+ std::error_code EC;
+ int FD;
+ SmallString<128> TmpPath;
+ if ((EC = llvm::sys::fs::createUniqueFile(ModelPath, FD, TmpPath))) {
----------------
qiongsiwu wrote:
What is the reason that we want to create unique files here? Is it that we are trying to be consistent with what we do in `OnDiskOutputFile::tryToCreateTemporary` (or in general how we write files to disk)? Would it be a good idea to pull out the common utility part and share some code? It might not be that straightforward and I don't think this is a blocker.
https://github.com/llvm/llvm-project/pull/188877
More information about the cfe-commits
mailing list