================
@@ -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
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to