[FileSystem] Move path resolution logic out of FileSpec

This patch removes the logic for resolving paths out of FileSpec and
updates call sites to rely on the FileSystem class instead.

Differential revision: https://reviews.llvm.org/D53915

llvm-svn: 345890
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index dfff7ec..60b56b0 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -353,7 +353,7 @@
         std::string file;
         extractor.GetHexByteString(file);
         match_info.GetProcessInfo().GetExecutableFile().SetFile(
-            file, false, FileSpec::Style::native);
+            file, FileSpec::Style::native);
       } else if (key.equals("name_match")) {
         NameMatch name_match = llvm::StringSwitch<NameMatch>(value)
                                    .Case("equals", NameMatch::Equals)
@@ -520,7 +520,8 @@
       if (packet.GetChar() == ',') {
         mode_t mode = packet.GetHexMaxU32(false, 0600);
         Status error;
-        const FileSpec path_spec{path, true};
+        FileSpec path_spec(path);
+        FileSystem::Instance().Resolve(path_spec);
         int fd = ::open(path_spec.GetCString(), flags, mode);
         const int save_errno = fd == -1 ? errno : 0;
         StreamString response;
@@ -660,7 +661,9 @@
   packet.GetHexByteString(path);
   if (!path.empty()) {
     Status error;
-    const uint32_t mode = File::GetPermissions(FileSpec{path, true}, error);
+    FileSpec file_spec(path);
+    FileSystem::Instance().Resolve(file_spec);
+    const uint32_t mode = File::GetPermissions(file_spec, error);
     StreamString response;
     response.Printf("F%u", mode);
     if (mode == 0 || error.Fail())
@@ -698,7 +701,11 @@
   packet.GetHexByteStringTerminatedBy(dst, ',');
   packet.GetChar(); // Skip ',' char
   packet.GetHexByteString(src);
-  Status error = FileSystem::Instance().Symlink(FileSpec{src, true}, FileSpec{dst, false});
+
+  FileSpec src_spec(src);
+  FileSystem::Instance().Resolve(src_spec);
+  Status error = FileSystem::Instance().Symlink(src_spec, FileSpec(dst));
+
   StreamString response;
   response.Printf("F%u,%u", error.GetError(), error.GetError());
   return SendPacketNoLock(response.GetString());
@@ -731,9 +738,11 @@
         packet.GetHexByteString(working_dir);
       int status, signo;
       std::string output;
-      Status err = Host::RunShellCommand(
-          path.c_str(), FileSpec{working_dir, true}, &status, &signo, &output,
-          std::chrono::seconds(10));
+      FileSpec working_spec(working_dir);
+      FileSystem::Instance().Resolve(working_spec);
+      Status err =
+          Host::RunShellCommand(path.c_str(), working_spec, &status, &signo,
+                                &output, std::chrono::seconds(10));
       StreamGDBRemote response;
       if (err.Fail()) {
         response.PutCString("F,");
@@ -884,7 +893,7 @@
   packet.GetHexByteString(path);
   const bool read = true;
   const bool write = false;
-  if (file_action.Open(STDIN_FILENO, FileSpec{path, false}, read, write)) {
+  if (file_action.Open(STDIN_FILENO, FileSpec(path), read, write)) {
     m_process_launch_info.AppendFileAction(file_action);
     return SendOKResponse();
   }
@@ -900,7 +909,7 @@
   packet.GetHexByteString(path);
   const bool read = false;
   const bool write = true;
-  if (file_action.Open(STDOUT_FILENO, FileSpec{path, false}, read, write)) {
+  if (file_action.Open(STDOUT_FILENO, FileSpec(path), read, write)) {
     m_process_launch_info.AppendFileAction(file_action);
     return SendOKResponse();
   }
@@ -916,7 +925,7 @@
   packet.GetHexByteString(path);
   const bool read = false;
   const bool write = true;
-  if (file_action.Open(STDERR_FILENO, FileSpec{path, false}, read, write)) {
+  if (file_action.Open(STDERR_FILENO, FileSpec(path), read, write)) {
     m_process_launch_info.AppendFileAction(file_action);
     return SendOKResponse();
   }
@@ -1024,7 +1033,7 @@
               if (success) {
                 if (arg_idx == 0)
                   m_process_launch_info.GetExecutableFile().SetFile(
-                      arg, false, FileSpec::Style::native);
+                      arg, FileSpec::Style::native);
                 m_process_launch_info.GetArguments().AppendArgument(arg);
                 if (log)
                   log->Printf("LLGSPacketHandler::%s added arg %d: \"%s\"",
@@ -1263,7 +1272,9 @@
 #ifdef __ANDROID__
   return HostInfoAndroid::ResolveLibraryPath(module_path, arch);
 #else
-  return FileSpec(module_path, true);
+  FileSpec file_spec(module_path);
+  FileSystem::Instance().Resolve(file_spec);
+  return file_spec;
 #endif
 }
 
@@ -1272,7 +1283,9 @@
                                                   llvm::StringRef triple) {
   ArchSpec arch(triple);
 
-  const FileSpec req_module_path_spec(module_path, true);
+  FileSpec req_module_path_spec(module_path);
+  FileSystem::Instance().Resolve(req_module_path_spec);
+
   const FileSpec module_path_spec =
       FindModuleFile(req_module_path_spec.GetPath(), arch);
   const ModuleSpec module_spec(module_path_spec, arch);