If defined, use TMPDIR environment variable as location for temporary files.
llvm-svn: 69609
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 67e92c2..5a2c8f6 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1110,7 +1110,12 @@
// 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;
- llvm::sys::Path P("/tmp/cc");
+ llvm::sys::Path P;
+ if (const char *TmpDir = ::getenv("TMPDIR"))
+ P = TmpDir;
+ else
+ P = "/tmp";
+ P.appendComponent("cc");
if (P.makeUnique(false, &Error)) {
Diag(clang::diag::err_drv_unable_to_make_temp) << Error;
return "";