Resubmit r298334 after fixing OSX build errors.

Hopefully this works, I can't test since I don't have Mac
hardware, however.

llvm-svn: 298340
diff --git a/lldb/source/Target/ModuleCache.cpp b/lldb/source/Target/ModuleCache.cpp
index b35e2d7..a4aa26a 100644
--- a/lldb/source/Target/ModuleCache.cpp
+++ b/lldb/source/Target/ModuleCache.cpp
@@ -13,7 +13,6 @@
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Host/File.h"
-#include "lldb/Host/FileSystem.h"
 #include "lldb/Host/LockFile.h"
 #include "lldb/Utility/Log.h"
 #include "llvm/Support/FileSystem.h"
@@ -101,11 +100,12 @@
                   module_uuid.GetAsString().c_str(), error.AsCString());
   }
 
-  auto link_count = FileSystem::GetHardlinkCount(sysroot_module_path_spec);
-  if (link_count == -1)
+  namespace fs = llvm::sys::fs;
+  fs::file_status st;
+  if (status(sysroot_module_path_spec.GetPath(), st))
     return;
 
-  if (link_count > 2) // module is referred by other hosts.
+  if (st.getLinkCount() > 2) // module is referred by other hosts.
     return;
 
   const auto module_spec_dir = GetModuleDirectory(root_dir_spec, module_uuid);
@@ -119,11 +119,10 @@
   DeleteExistingModule(root_dir_spec, sysroot_module_path_spec);
 
   // Remove sysroot link.
-  FileSystem::Unlink(sysroot_module_path_spec);
+  llvm::sys::fs::remove(sysroot_module_path_spec.GetPath());
 
   FileSpec symfile_spec = GetSymbolFileSpec(sysroot_module_path_spec);
-  if (symfile_spec.Exists()) // delete module's symbol file if exists.
-    FileSystem::Unlink(symfile_spec);
+  llvm::sys::fs::remove(symfile_spec.GetPath());
 }
 
 Error CreateHostSysRootModuleLink(const FileSpec &root_dir_spec,
@@ -146,7 +145,8 @@
   if (error.Fail())
     return error;
 
-  return FileSystem::Hardlink(sysroot_module_path_spec, local_module_spec);
+  return llvm::sys::fs::create_hard_link(local_module_spec.GetPath(),
+                                         sysroot_module_path_spec.GetPath());
 }
 
 } // namespace
@@ -179,7 +179,7 @@
     return;
 
   m_file.Close();
-  FileSystem::Unlink(m_file_spec);
+  llvm::sys::fs::remove(m_file_spec.GetPath());
 }
 
 /////////////////////////////////////////////////////////////////////////