diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-06-26 04:02:37 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-06-26 04:02:37 +0000 |
commit | bc4aa5547e57b363eda5995a79a33dced3302277 (patch) | |
tree | 6c31157b2992937cb8fec31e52d075c702937740 /clang/lib/Frontend/ASTUnit.cpp | |
parent | bc7d949b32060fab45484dd8ebec6affc09887c1 (diff) | |
download | bcm5719-llvm-bc4aa5547e57b363eda5995a79a33dced3302277.tar.gz bcm5719-llvm-bc4aa5547e57b363eda5995a79a33dced3302277.zip |
Use llvm::sys::fs::unique_file.
llvm-svn: 184908
Diffstat (limited to 'clang/lib/Frontend/ASTUnit.cpp')
-rw-r--r-- | clang/lib/Frontend/ASTUnit.cpp | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index e5a8d17c203..2633e3c11e9 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -172,7 +172,7 @@ void OnDiskData::CleanTemporaryFiles() { void OnDiskData::CleanPreambleFile() { if (!PreambleFile.empty()) { - llvm::sys::Path(PreambleFile).eraseFromDisk(); + llvm::sys::fs::remove(PreambleFile); PreambleFile.clear(); } } @@ -1237,36 +1237,17 @@ error: /// \brief Simple function to retrieve a path for a preamble precompiled header. static std::string GetPreamblePCHPath() { - // FIXME: This is lame; sys::Path should provide this function (in particular, - // it should know how to find the temporary files dir). - // FIXME: This is really lame. I copied this code from the Driver! // 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. + // are not necessarily cleaned up. const char *TmpFile = ::getenv("CINDEXTEST_PREAMBLE_FILE"); if (TmpFile) return TmpFile; - - std::string Error; - const char *TmpDir = ::getenv("TMPDIR"); - if (!TmpDir) - TmpDir = ::getenv("TEMP"); - if (!TmpDir) - TmpDir = ::getenv("TMP"); -#ifdef LLVM_ON_WIN32 - if (!TmpDir) - TmpDir = ::getenv("USERPROFILE"); -#endif - if (!TmpDir) - TmpDir = "/tmp"; - llvm::sys::Path P(TmpDir); - P.createDirectoryOnDisk(true); - P.appendComponent("preamble"); - P.appendSuffix("pch"); - if (P.makeUnique(/*reuse_current=*/false, /*ErrMsg*/0)) - return std::string(); - - return P.str(); + + SmallString<128> Path; + llvm::sys::fs::unique_file("preamble-%%%%%%.pch", Path); + + return Path.str(); } /// \brief Compute the preamble for the main file, providing the source buffer |