diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-06-25 02:35:32 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-06-25 02:35:32 +0000 |
commit | e7f89915b483e7aea3c794f6913203c6e0f7f7b6 (patch) | |
tree | 0c5a24a51a623b722b98a4d65c99a22c091036c4 /clang/lib/Driver/Driver.cpp | |
parent | 3bab90a40012d22b473777fa4b39f3a9c212e043 (diff) | |
download | bcm5719-llvm-e7f89915b483e7aea3c794f6913203c6e0f7f7b6.tar.gz bcm5719-llvm-e7f89915b483e7aea3c794f6913203c6e0f7f7b6.zip |
Revert "Use the new PathV2 instead of implementing the logic in clang."
This reverts commit 184803 while I debug the failures on the bots.
llvm-svn: 184818
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r-- | clang/lib/Driver/Driver.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 135af0404b1..546333b137d 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -30,6 +30,7 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" +#include "llvm/Support/PathV1.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Program.h" #include "llvm/Support/raw_ostream.h" @@ -1614,15 +1615,29 @@ std::string Driver::GetProgramPath(const char *Name, std::string Driver::GetTemporaryPath(StringRef Prefix, const char *Suffix) const { - SmallString<128> Path; - llvm::error_code EC = - llvm::sys::fs::unique_file(Prefix + "-%%%%%%." + Suffix, Path); - if (EC) { - Diag(clang::diag::err_unable_to_make_temp) << EC.message(); + // FIXME: This is lame; sys::Path should provide this function (in particular, + // it should know how to find the temporary files dir). + std::string Error; + const char *TmpDir = ::getenv("TMPDIR"); + if (!TmpDir) + TmpDir = ::getenv("TEMP"); + if (!TmpDir) + TmpDir = ::getenv("TMP"); + if (!TmpDir) + TmpDir = "/tmp"; + llvm::sys::Path P(TmpDir); + P.appendComponent(Prefix); + if (P.makeUnique(false, &Error)) { + Diag(clang::diag::err_unable_to_make_temp) << Error; return ""; } - return Path.str(); + // FIXME: Grumble, makeUnique sometimes leaves the file around!? PR3837. + P.eraseFromDisk(false, 0); + + if (Suffix) + P.appendSuffix(Suffix); + return P.str(); } /// \brief Compute target triple from args. |