Add a -t="dir" option to the driver. This can be used to specify the directory to be used as TempDir if somebody doesn't want to use the standard /tmp.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75121 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CompilerDriver/Main.cpp b/lib/CompilerDriver/Main.cpp
index 7d1a3d8..57d2937 100644
--- a/lib/CompilerDriver/Main.cpp
+++ b/lib/CompilerDriver/Main.cpp
@@ -31,6 +31,15 @@
   sys::Path getTempDir() {
     sys::Path tempDir;
 
+    if (! TempDirname.empty() {
+      tempDir = TempDirname;
+      if (!tempDir.exists()) {
+        std::string ErrMsg;
+        if (tempDir.createDirectoryOnDisk(true, &ErrMsg))
+          throw std::runtime_error(ErrMsg);
+      }
+    }
+
     // GCC 4.5-style -save-temps handling.
     if (SaveTemps == SaveTempsEnum::Unset) {
       tempDir = sys::Path::GetTemporaryDirectory();