Loading clang/include/clang/Frontend/PrecompiledPreamble.h +0 −8 Original line number Diff line number Diff line Loading @@ -134,14 +134,6 @@ private: // A main method used to construct TempPCHFile. static llvm::ErrorOr<TempPCHFile> CreateNewPreamblePCHFile(); /// Call llvm::sys::fs::createTemporaryFile to create a new temporary file. static llvm::ErrorOr<TempPCHFile> createInSystemTempDir(const Twine &Prefix, StringRef Suffix); /// Create a new instance of TemporaryFile for file at \p Path. Use with /// extreme caution, there's an assertion checking that there's only a /// single instance of TempPCHFile alive for each path. static llvm::ErrorOr<TempPCHFile> createFromCustomPath(const Twine &Path); private: TempPCHFile(std::string FilePath); Loading clang/lib/Frontend/PrecompiledPreamble.cpp +3 −14 Original line number Diff line number Diff line Loading @@ -535,21 +535,15 @@ PrecompiledPreamble::TempPCHFile::CreateNewPreamblePCHFile() { // FIXME: This is a hack so that we can override the preamble file during // crash-recovery testing, which is the only case where the preamble files // are not necessarily cleaned up. const char *TmpFile = ::getenv("CINDEXTEST_PREAMBLE_FILE"); if (TmpFile) return TempPCHFile::createFromCustomPath(TmpFile); return TempPCHFile::createInSystemTempDir("preamble", "pch"); } if (const char *TmpFile = ::getenv("CINDEXTEST_PREAMBLE_FILE")) return TempPCHFile(TmpFile); llvm::ErrorOr<PrecompiledPreamble::TempPCHFile> PrecompiledPreamble::TempPCHFile::createInSystemTempDir(const Twine &Prefix, StringRef Suffix) { llvm::SmallString<64> File; // Using a version of createTemporaryFile with a file descriptor guarantees // that we would never get a race condition in a multi-threaded setting // (i.e., multiple threads getting the same temporary path). int FD; auto EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, FD, File); auto EC = llvm::sys::fs::createTemporaryFile("preamble", "pch", FD, File); if (EC) return EC; // We only needed to make sure the file exists, close the file right away. Loading @@ -557,11 +551,6 @@ PrecompiledPreamble::TempPCHFile::createInSystemTempDir(const Twine &Prefix, return TempPCHFile(std::move(File).str()); } llvm::ErrorOr<PrecompiledPreamble::TempPCHFile> PrecompiledPreamble::TempPCHFile::createFromCustomPath(const Twine &Path) { return TempPCHFile(Path.str()); } PrecompiledPreamble::TempPCHFile::TempPCHFile(std::string FilePath) : FilePath(std::move(FilePath)) { TemporaryFiles::getInstance().addFile(*this->FilePath); Loading Loading
clang/include/clang/Frontend/PrecompiledPreamble.h +0 −8 Original line number Diff line number Diff line Loading @@ -134,14 +134,6 @@ private: // A main method used to construct TempPCHFile. static llvm::ErrorOr<TempPCHFile> CreateNewPreamblePCHFile(); /// Call llvm::sys::fs::createTemporaryFile to create a new temporary file. static llvm::ErrorOr<TempPCHFile> createInSystemTempDir(const Twine &Prefix, StringRef Suffix); /// Create a new instance of TemporaryFile for file at \p Path. Use with /// extreme caution, there's an assertion checking that there's only a /// single instance of TempPCHFile alive for each path. static llvm::ErrorOr<TempPCHFile> createFromCustomPath(const Twine &Path); private: TempPCHFile(std::string FilePath); Loading
clang/lib/Frontend/PrecompiledPreamble.cpp +3 −14 Original line number Diff line number Diff line Loading @@ -535,21 +535,15 @@ PrecompiledPreamble::TempPCHFile::CreateNewPreamblePCHFile() { // FIXME: This is a hack so that we can override the preamble file during // crash-recovery testing, which is the only case where the preamble files // are not necessarily cleaned up. const char *TmpFile = ::getenv("CINDEXTEST_PREAMBLE_FILE"); if (TmpFile) return TempPCHFile::createFromCustomPath(TmpFile); return TempPCHFile::createInSystemTempDir("preamble", "pch"); } if (const char *TmpFile = ::getenv("CINDEXTEST_PREAMBLE_FILE")) return TempPCHFile(TmpFile); llvm::ErrorOr<PrecompiledPreamble::TempPCHFile> PrecompiledPreamble::TempPCHFile::createInSystemTempDir(const Twine &Prefix, StringRef Suffix) { llvm::SmallString<64> File; // Using a version of createTemporaryFile with a file descriptor guarantees // that we would never get a race condition in a multi-threaded setting // (i.e., multiple threads getting the same temporary path). int FD; auto EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, FD, File); auto EC = llvm::sys::fs::createTemporaryFile("preamble", "pch", FD, File); if (EC) return EC; // We only needed to make sure the file exists, close the file right away. Loading @@ -557,11 +551,6 @@ PrecompiledPreamble::TempPCHFile::createInSystemTempDir(const Twine &Prefix, return TempPCHFile(std::move(File).str()); } llvm::ErrorOr<PrecompiledPreamble::TempPCHFile> PrecompiledPreamble::TempPCHFile::createFromCustomPath(const Twine &Path) { return TempPCHFile(Path.str()); } PrecompiledPreamble::TempPCHFile::TempPCHFile(std::string FilePath) : FilePath(std::move(FilePath)) { TemporaryFiles::getInstance().addFile(*this->FilePath); Loading