]> granicus.if.org Git - clang/commitdiff
Use the new PathV2 instead of implementing the logic in clang.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 25 Jun 2013 00:55:28 +0000 (00:55 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 25 Jun 2013 00:55:28 +0000 (00:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184803 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Driver.cpp

index 43b66ba9ee1e59fb5dd4ac3bfd53e9c79d2af314..d524dc3855370fa74de58eb0f90c98f2b846e595 100644 (file)
@@ -1615,29 +1615,15 @@ std::string Driver::GetProgramPath(const char *Name,
 
 std::string Driver::GetTemporaryPath(StringRef Prefix, const char *Suffix)
   const {
-  // 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;
+  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();
     return "";
   }
 
-  // FIXME: Grumble, makeUnique sometimes leaves the file around!?  PR3837.
-  P.eraseFromDisk(false, 0);
-
-  if (Suffix)
-    P.appendSuffix(Suffix);
-  return P.str();
+  return Path.str();
 }
 
 /// \brief Compute target triple from args.