Support/Path: Deprecate PathV1::exists and replace all uses with PathV2::fs::exists.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123151 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp
index 3e0ee8d..4689208 100644
--- a/lib/Support/Path.cpp
+++ b/lib/Support/Path.cpp
@@ -13,6 +13,7 @@
 
 #include "llvm/Support/Path.h"
 #include "llvm/Config/config.h"
+#include "llvm/Support/FileSystem.h"
 #include <cassert>
 #include <cstring>
 #include <ostream>
diff --git a/lib/Support/Unix/Path.inc b/lib/Support/Unix/Path.inc
index 886ba6b..b39e465 100644
--- a/lib/Support/Unix/Path.inc
+++ b/lib/Support/Unix/Path.inc
@@ -811,7 +811,8 @@
 
 bool
 Path::makeUnique(bool reuse_current, std::string* ErrMsg) {
-  if (reuse_current && !exists())
+  bool Exists;
+  if (reuse_current && (fs::exists(path, Exists) || !Exists))
     return false; // File doesn't exist already, just use it!
 
   // Append an XXXXXX pattern to the end of the file for use with mkstemp,
diff --git a/lib/Support/Unix/Program.inc b/lib/Support/Unix/Program.inc
index 17c3ba1..1104bc7 100644
--- a/lib/Support/Unix/Program.inc
+++ b/lib/Support/Unix/Program.inc
@@ -17,6 +17,7 @@
 //===----------------------------------------------------------------------===//
 
 #include <llvm/Config/config.h>
+#include "llvm/Support/FileSystem.h"
 #include "Unix.h"
 #if HAVE_SYS_STAT_H
 #include <sys/stat.h>
@@ -355,7 +356,8 @@
     // Following the POSIX convention for command-line tools (which posix_spawn
     // itself apparently does not), check to see if the failure was due to some
     // reason other than the file not existing, and return 126 in this case.
-    if (result == 127 && path.exists())
+    bool Exists;
+    if (result == 127 && !llvm::sys::fs::exists(path.str(), Exists) && Exists)
       result = 126;
 #endif
     if (result == 127) {
diff --git a/lib/Support/Windows/Path.inc b/lib/Support/Windows/Path.inc
index cc68b9f..9100739 100644
--- a/lib/Support/Windows/Path.inc
+++ b/lib/Support/Windows/Path.inc
@@ -694,7 +694,8 @@
 
   if (fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
     // If it doesn't exist, we're done.
-    if (!exists())
+    bool Exists;
+    if (fs::exists(path, Exists) || !Exists)
       return false;
 
     char *pathname = reinterpret_cast<char *>(_alloca(path.length()+3));
@@ -868,7 +869,8 @@
 
 bool
 Path::makeUnique(bool reuse_current, std::string* ErrMsg) {
-  if (reuse_current && !exists())
+  bool Exists;
+  if (reuse_current && (fs::exists(path, Exists) || !Exists))
     return false; // File doesn't exist already, just use it!
 
   // Reserve space for -XXXXXX at the end.
@@ -885,7 +887,7 @@
     if (++FCounter > 999999)
       FCounter = 0;
     path = FNBuffer;
-  } while (exists());
+  } while (!fs::exists(path, Exists) && Exists);
   return false;
 }