File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
clang/lib/Tooling/DependencyScanning Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -750,9 +750,25 @@ bool DependencyScanningWorker::computeDependencies(
750750 auto InMemoryFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
751751 InMemoryFS->setCurrentWorkingDirectory (WorkingDirectory);
752752 SmallString<128 > FakeInputPath;
753- // TODO: We should retry the creation if the path already exists.
754- llvm::sys::fs::createUniquePath (ModuleName + " -%%%%%%%%.input" , FakeInputPath,
755- /* MakeAbsolute=*/ false );
753+
754+ unsigned RetryCount = 5 ; // retries to create
755+ bool UniquePathCreated = false ;
756+
757+ for (unsigned i = 0 ; i < RetryCount; ++i) {
758+ if (llvm::sys::fs::createUniquePath (ModuleName + " -%%%%%%%%.input" , FakeInputPath,
759+ /* MakeAbsolute=*/ false )) {
760+ if (!llvm::sys::fs::exists (FakeInputPath)) {
761+ UniquePathCreated = true ;
762+ break ; // Successfully created a unique path
763+ }
764+ }
765+ }
766+ if (!UniquePathCreated) {
767+ llvm::errs () << " Error: Failed to create a unique input path after "
768+ << RetryCount << " retries.\n " ;
769+ return false ; // Handle failure appropriately
770+ }
771+
756772 InMemoryFS->addFile (FakeInputPath, 0 , llvm::MemoryBuffer::getMemBuffer (" " ));
757773 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> InMemoryOverlay = InMemoryFS;
758774
You can’t perform that action at this time.
0 commit comments