[Lldb-commits] [lldb] r297139 - Revert "Use LLVM for all stat-related functionality."

Sean Callanan via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 7 10:17:43 PST 2017


Thanks, Pavel.
I think if we do this again we should indirect the new API through the LLDB FileSpec API or at least a global function somewhere in LLDB, so that we can change implementations without having to touch so much source code.

Sean

> On Mar 7, 2017, at 5:19 AM, Pavel Labath via lldb-commits <lldb-commits at lists.llvm.org> wrote:
> 
> Author: labath
> Date: Tue Mar  7 07:19:15 2017
> New Revision: 297139
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=297139&view=rev
> Log:
> Revert "Use LLVM for all stat-related functionality."
> 
> this reverts r297116 because it breaks the unittests and
> TestCompDirSymlink. The ModuleCache unit test is trivially fixable, but
> the CompDirSymlink failure is a symptom of a deeper problem: llvm's stat
> functionality is not a drop-in replacement for lldb's. The former is
> based on stat(2) (which does symlink resolution), while the latter is
> based on lstat(2) (which does not).
> 
> This also reverts subsequent build fixes (r297128, r297120, 297117) and
> r297119 (Remove FileSpec dependency on FileSystem) which builds on top
> of this.
> 
> Modified:
>    lldb/trunk/include/lldb/Host/FileSpec.h
>    lldb/trunk/source/API/SBPlatform.cpp
>    lldb/trunk/source/Commands/CommandCompletions.cpp
>    lldb/trunk/source/Commands/CommandObjectTarget.cpp
>    lldb/trunk/source/Core/Debugger.cpp
>    lldb/trunk/source/Core/FileSpecList.cpp
>    lldb/trunk/source/Core/Module.cpp
>    lldb/trunk/source/Core/ModuleList.cpp
>    lldb/trunk/source/Core/PluginManager.cpp
>    lldb/trunk/source/Host/common/FileSpec.cpp
>    lldb/trunk/source/Host/common/MonitoringProcessLauncher.cpp
>    lldb/trunk/source/Host/common/Symbols.cpp
>    lldb/trunk/source/Host/macosx/Host.mm
>    lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm
>    lldb/trunk/source/Host/macosx/Symbols.cpp
>    lldb/trunk/source/Host/posix/FileSystem.cpp
>    lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
>    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
>    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
>    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
>    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
>    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
>    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
>    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
>    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h
>    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
>    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h
>    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
>    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
>    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
>    lldb/trunk/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp
>    lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
>    lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
>    lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
>    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
>    lldb/trunk/source/Target/ModuleCache.cpp
>    lldb/trunk/source/Target/Platform.cpp
>    lldb/trunk/source/Target/TargetList.cpp
> 
> Modified: lldb/trunk/include/lldb/Host/FileSpec.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/FileSpec.h?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/include/lldb/Host/FileSpec.h (original)
> +++ lldb/trunk/include/lldb/Host/FileSpec.h Tue Mar  7 07:19:15 2017
> @@ -22,7 +22,6 @@
> #include "lldb/lldb-private.h"
> 
> #include "llvm/ADT/Triple.h"
> -#include "llvm/Support/FileSystem.h"
> #include "llvm/Support/FormatVariadic.h"
> 
> namespace lldb_private {
> @@ -47,6 +46,17 @@ namespace lldb_private {
> //----------------------------------------------------------------------
> class FileSpec {
> public:
> +  typedef enum FileType {
> +    eFileTypeInvalid = -1,
> +    eFileTypeUnknown = 0,
> +    eFileTypeDirectory,
> +    eFileTypePipe,
> +    eFileTypeRegular,
> +    eFileTypeSocket,
> +    eFileTypeSymbolicLink,
> +    eFileTypeOther
> +  } FileType;
> +
>   enum PathSyntax {
>     ePathSyntaxPosix,
>     ePathSyntaxWindows,
> @@ -445,6 +455,8 @@ public:
>   //------------------------------------------------------------------
>   ConstString GetFileNameStrippingExtension() const;
> 
> +  FileType GetFileType() const;
> +
>   //------------------------------------------------------------------
>   /// Return the current permissions of the path.
>   ///
> @@ -459,6 +471,20 @@ public:
>   //------------------------------------------------------------------
>   uint32_t GetPermissions() const;
> 
> +  bool IsDirectory() const {
> +    return GetFileType() == FileSpec::eFileTypeDirectory;
> +  }
> +
> +  bool IsPipe() const { return GetFileType() == FileSpec::eFileTypePipe; }
> +
> +  bool IsRegularFile() const {
> +    return GetFileType() == FileSpec::eFileTypeRegular;
> +  }
> +
> +  bool IsSocket() const { return GetFileType() == FileSpec::eFileTypeSocket; }
> +
> +  bool IsSymbolicLink() const;
> +
>   //------------------------------------------------------------------
>   /// Get the memory cost of this object.
>   ///
> @@ -570,7 +596,7 @@ public:
>   };
> 
>   typedef EnumerateDirectoryResult (*EnumerateDirectoryCallbackType)(
> -      void *baton, llvm::sys::fs::file_type file_type, const FileSpec &spec);
> +      void *baton, FileType file_type, const FileSpec &spec);
> 
>   static EnumerateDirectoryResult
>   EnumerateDirectory(llvm::StringRef dir_path, bool find_directories,
> @@ -578,8 +604,8 @@ public:
>                      EnumerateDirectoryCallbackType callback,
>                      void *callback_baton);
> 
> -  typedef std::function<EnumerateDirectoryResult(
> -      llvm::sys::fs::file_type file_type, const FileSpec &spec)>
> +  typedef std::function<EnumerateDirectoryResult(FileType file_type,
> +                                                 const FileSpec &spec)>
>       DirectoryCallback;
> 
>   static EnumerateDirectoryResult
> 
> Modified: lldb/trunk/source/API/SBPlatform.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBPlatform.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/API/SBPlatform.cpp (original)
> +++ lldb/trunk/source/API/SBPlatform.cpp Tue Mar  7 07:19:15 2017
> @@ -19,8 +19,6 @@
> #include "lldb/Target/Target.h"
> #include "lldb/Utility/Error.h"
> 
> -#include "llvm/Support/FileSystem.h"
> -
> #include <functional>
> 
> using namespace lldb;
> @@ -365,7 +363,7 @@ SBError SBPlatform::Put(SBFileSpec &src,
>     if (src.Exists()) {
>       uint32_t permissions = src.ref().GetPermissions();
>       if (permissions == 0) {
> -        if (llvm::sys::fs::is_directory(src.ref().GetPath()))
> +        if (src.ref().GetFileType() == FileSpec::eFileTypeDirectory)
>           permissions = eFilePermissionsDirectoryDefault;
>         else
>           permissions = eFilePermissionsFileDefault;
> 
> Modified: lldb/trunk/source/Commands/CommandCompletions.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Commands/CommandCompletions.cpp (original)
> +++ lldb/trunk/source/Commands/CommandCompletions.cpp Tue Mar  7 07:19:15 2017
> @@ -33,7 +33,6 @@
> #include "lldb/Utility/CleanUp.h"
> 
> #include "llvm/ADT/SmallString.h"
> -#include "llvm/Support/FileSystem.h"
> 
> using namespace lldb_private;
> 
> @@ -110,7 +109,7 @@ typedef struct DiskFilesOrDirectoriesBat
> } DiskFilesOrDirectoriesBaton;
> 
> FileSpec::EnumerateDirectoryResult
> -DiskFilesOrDirectoriesCallback(void *baton, llvm::sys::fs::file_type file_type,
> +DiskFilesOrDirectoriesCallback(void *baton, FileSpec::FileType file_type,
>                                const FileSpec &spec) {
>   const char *name = spec.GetFilename().AsCString();
> 
> @@ -139,10 +138,10 @@ DiskFilesOrDirectoriesCallback(void *bat
>     strcpy(end_ptr, name);
> 
>     bool isa_directory = false;
> -    if (file_type == llvm::sys::fs::file_type::directory_file)
> +    if (file_type == FileSpec::eFileTypeDirectory)
>       isa_directory = true;
> -    else if (file_type == llvm::sys::fs::file_type::symlink_file) {
> -      if (llvm::sys::fs::is_directory(partial_name_copy))
> +    else if (file_type == FileSpec::eFileTypeSymbolicLink) {
> +      if (FileSpec(partial_name_copy, false).IsDirectory())
>         isa_directory = true;
>     }
> 
> 
> Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
> +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Tue Mar  7 07:19:15 2017
> @@ -50,8 +50,6 @@
> #include "lldb/Target/Thread.h"
> #include "lldb/Target/ThreadSpec.h"
> 
> -#include "llvm/Support/FileSystem.h"
> -
> // C Includes
> // C++ Includes
> #include <cerrno>
> @@ -4138,21 +4136,20 @@ protected:
>         module_sp->SetSymbolFileFileSpec(FileSpec());
>       }
> 
> -      namespace fs = llvm::sys::fs;
>       if (module_spec.GetUUID().IsValid()) {
>         StreamString ss_symfile_uuid;
>         module_spec.GetUUID().Dump(&ss_symfile_uuid);
>         result.AppendErrorWithFormat(
>             "symbol file '%s' (%s) does not match any existing module%s\n",
>             symfile_path, ss_symfile_uuid.GetData(),
> -            !fs::is_regular_file(symbol_fspec.GetPath())
> +            (symbol_fspec.GetFileType() != FileSpec::eFileTypeRegular)
>                 ? "\n       please specify the full path to the symbol file"
>                 : "");
>       } else {
>         result.AppendErrorWithFormat(
>             "symbol file '%s' does not match any existing module%s\n",
>             symfile_path,
> -            !fs::is_regular_file(symbol_fspec.GetPath())
> +            (symbol_fspec.GetFileType() != FileSpec::eFileTypeRegular)
>                 ? "\n       please specify the full path to the symbol file"
>                 : "");
>       }
> 
> Modified: lldb/trunk/source/Core/Debugger.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Core/Debugger.cpp (original)
> +++ lldb/trunk/source/Core/Debugger.cpp Tue Mar  7 07:19:15 2017
> @@ -557,7 +557,7 @@ bool Debugger::LoadPlugin(const FileSpec
> }
> 
> static FileSpec::EnumerateDirectoryResult
> -LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
> +LoadPluginCallback(void *baton, FileSpec::FileType file_type,
>                    const FileSpec &file_spec) {
>   Error error;
> 
> @@ -569,13 +569,13 @@ LoadPluginCallback(void *baton, llvm::sy
> 
>   Debugger *debugger = (Debugger *)baton;
> 
> -  namespace fs = llvm::sys::fs;
>   // If we have a regular file, a symbolic link or unknown file type, try
>   // and process the file. We must handle unknown as sometimes the directory
>   // enumeration might be enumerating a file system that doesn't have correct
>   // file type information.
> -  if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file ||
> -      ft == fs::file_type::type_unknown) {
> +  if (file_type == FileSpec::eFileTypeRegular ||
> +      file_type == FileSpec::eFileTypeSymbolicLink ||
> +      file_type == FileSpec::eFileTypeUnknown) {
>     FileSpec plugin_file_spec(file_spec);
>     plugin_file_spec.ResolvePath();
> 
> @@ -588,9 +588,9 @@ LoadPluginCallback(void *baton, llvm::sy
>     debugger->LoadPlugin(plugin_file_spec, plugin_load_error);
> 
>     return FileSpec::eEnumerateDirectoryResultNext;
> -  } else if (ft == fs::file_type::directory_file ||
> -             ft == fs::file_type::symlink_file ||
> -             ft == fs::file_type::type_unknown) {
> +  } else if (file_type == FileSpec::eFileTypeUnknown ||
> +             file_type == FileSpec::eFileTypeDirectory ||
> +             file_type == FileSpec::eFileTypeSymbolicLink) {
>     // Try and recurse into anything that a directory or symbolic link.
>     // We must also do this for unknown as sometimes the directory enumeration
>     // might be enumerating a file system that doesn't have correct file type
> 
> Modified: lldb/trunk/source/Core/FileSpecList.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpecList.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Core/FileSpecList.cpp (original)
> +++ lldb/trunk/source/Core/FileSpecList.cpp Tue Mar  7 07:19:15 2017
> @@ -16,7 +16,6 @@
> // Other libraries and framework includes
> // Project includes
> #include "lldb/Utility/Stream.h"
> -#include "llvm/Support/FileSystem.h"
> 
> using namespace lldb_private;
> using namespace std;
> @@ -151,23 +150,32 @@ size_t FileSpecList::GetFilesMatchingPar
>                                                  FileSpecList &matches) {
> #if 0 // FIXME: Just sketching...
>     matches.Clear();
> -    using namespace llvm::sys::fs;
> -    file_status stats;
> -    if (status(path, stats))
> -      return 0;
> -    if (exists(stats)) {
> -      if (stats.type() == file_type::symlink_file) {
> -        // Shouldn't there be a method that realpath's a file?
> -      }
> -      if (is_regular_file(stats) || (is_directory(stats) && dir_okay)) {
> -        matches.Append(FileSpec(path));
> -        return 1;
> -      } else if (is_directory(stats)) {
> -        // Fill the match list with all the files in the directory:
> -      } else {
> -        return 0;
> -      }
> -    } else {
> +    FileSpec path_spec = FileSpec (path);
> +    if (path_spec.Exists ())
> +    {
> +        FileSpec::FileType type = path_spec.GetFileType();
> +        if (type == FileSpec::eFileTypeSymbolicLink)
> +            // Shouldn't there be a Resolve on a file spec that real-path's it?
> +        {
> +        }
> +
> +        if (type == FileSpec::eFileTypeRegular
> +            || (type == FileSpec::eFileTypeDirectory && dir_okay))
> +        {
> +            matches.Append (path_spec);
> +            return 1;
> +        }
> +        else if (type == FileSpec::eFileTypeDirectory)
> +        {
> +            // Fill the match list with all the files in the directory:
> +        }
> +        else
> +        {
> +            return 0;
> +        }
> +    }
> +    else
> +    {
>         ConstString dir_name = path_spec.GetDirectory();
>         ConstString file_name = GetFilename();
>         if (dir_name == nullptr)
> 
> Modified: lldb/trunk/source/Core/Module.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Core/Module.cpp (original)
> +++ lldb/trunk/source/Core/Module.cpp Tue Mar  7 07:19:15 2017
> @@ -12,7 +12,6 @@
> // C Includes
> // C++ Includes
> // Other libraries and framework includes
> -#include "llvm/Support/FileSystem.h"
> #include "llvm/Support/Signals.h"
> #include "llvm/Support/raw_os_ostream.h"
> 
> @@ -1440,7 +1439,7 @@ void Module::SetSymbolFileFileSpec(const
>         // ("/tmp/a.out.dSYM/Contents/Resources/DWARF/a.out"). So we need to
>         // check this
> 
> -        if (llvm::sys::fs::is_directory(file.GetPath())) {
> +        if (file.IsDirectory()) {
>           std::string new_path(file.GetPath());
>           std::string old_path(obj_file->GetFileSpec().GetPath());
>           if (old_path.find(new_path) == 0) {
> 
> Modified: lldb/trunk/source/Core/ModuleList.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Core/ModuleList.cpp (original)
> +++ lldb/trunk/source/Core/ModuleList.cpp Tue Mar  7 07:19:15 2017
> @@ -26,7 +26,6 @@
> #include "lldb/Symbol/VariableList.h"
> #include "lldb/Utility/Log.h"
> 
> -#include "llvm/Support/FileSystem.h"
> #include "llvm/Support/Threading.h"
> 
> using namespace lldb;
> @@ -767,8 +766,7 @@ Error ModuleList::GetSharedModule(const
>       auto search_path_spec = module_search_paths_ptr->GetFileSpecAtIndex(idx);
>       if (!search_path_spec.ResolvePath())
>         continue;
> -      namespace fs = llvm::sys::fs;
> -      if (!fs::is_directory(search_path_spec.GetPath()))
> +      if (!search_path_spec.Exists() || !search_path_spec.IsDirectory())
>         continue;
>       search_path_spec.AppendPathComponent(
>           module_spec.GetFileSpec().GetFilename().AsCString());
> 
> Modified: lldb/trunk/source/Core/PluginManager.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Core/PluginManager.cpp (original)
> +++ lldb/trunk/source/Core/PluginManager.cpp Tue Mar  7 07:19:15 2017
> @@ -79,18 +79,18 @@ template <typename FPtrTy> static FPtrTy
> }
> 
> static FileSpec::EnumerateDirectoryResult
> -LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
> +LoadPluginCallback(void *baton, FileSpec::FileType file_type,
>                    const FileSpec &file_spec) {
>   //    PluginManager *plugin_manager = (PluginManager *)baton;
>   Error error;
> 
> -  namespace fs = llvm::sys::fs;
>   // If we have a regular file, a symbolic link or unknown file type, try
>   // and process the file. We must handle unknown as sometimes the directory
>   // enumeration might be enumerating a file system that doesn't have correct
>   // file type information.
> -  if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file ||
> -      ft == fs::file_type::type_unknown) {
> +  if (file_type == FileSpec::eFileTypeRegular ||
> +      file_type == FileSpec::eFileTypeSymbolicLink ||
> +      file_type == FileSpec::eFileTypeUnknown) {
>     FileSpec plugin_file_spec(file_spec);
>     plugin_file_spec.ResolvePath();
> 
> @@ -135,8 +135,9 @@ LoadPluginCallback(void *baton, llvm::sy
>     }
>   }
> 
> -  if (ft == fs::file_type::directory_file ||
> -      ft == fs::file_type::symlink_file || ft == fs::file_type::type_unknown) {
> +  if (file_type == FileSpec::eFileTypeUnknown ||
> +      file_type == FileSpec::eFileTypeDirectory ||
> +      file_type == FileSpec::eFileTypeSymbolicLink) {
>     // Try and recurse into anything that a directory or symbolic link.
>     // We must also do this for unknown as sometimes the directory enumeration
>     // might be enumerating a file system that doesn't have correct file type
> 
> Modified: lldb/trunk/source/Host/common/FileSpec.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Host/common/FileSpec.cpp (original)
> +++ lldb/trunk/source/Host/common/FileSpec.cpp Tue Mar  7 07:19:15 2017
> @@ -27,6 +27,7 @@
> 
> #include "lldb/Core/StringList.h"
> #include "lldb/Host/FileSpec.h"
> +#include "lldb/Host/FileSystem.h"
> #include "lldb/Utility/CleanUp.h"
> #include "lldb/Utility/RegularExpression.h"
> #include "lldb/Utility/Stream.h"
> @@ -44,18 +45,10 @@ using namespace lldb_private;
> 
> namespace {
> 
> -static constexpr FileSpec::PathSyntax GetNativeSyntax() {
> -#if defined(LLVM_ON_WIN32)
> -  return FileSpec::ePathSyntaxWindows;
> -#else
> -  return FileSpec::ePathSyntaxPosix;
> -#endif
> -}
> -
> bool PathSyntaxIsPosix(FileSpec::PathSyntax syntax) {
>   return (syntax == FileSpec::ePathSyntaxPosix ||
>           (syntax == FileSpec::ePathSyntaxHostNative &&
> -           GetNativeSyntax() == FileSpec::ePathSyntaxPosix));
> +           FileSystem::GetNativePathSyntax() == FileSpec::ePathSyntaxPosix));
> }
> 
> const char *GetPathSeparators(FileSpec::PathSyntax syntax) {
> @@ -91,6 +84,13 @@ void Denormalize(llvm::SmallVectorImpl<c
>   std::replace(path.begin(), path.end(), '/', '\\');
> }
> 
> +bool GetFileStats(const FileSpec *file_spec, struct stat *stats_ptr) {
> +  char resolved_path[PATH_MAX];
> +  if (file_spec->GetPath(resolved_path, sizeof(resolved_path)))
> +    return FileSystem::Stat(resolved_path, stats_ptr) == 0;
> +  return false;
> +}
> +
> size_t FilenamePos(llvm::StringRef str, FileSpec::PathSyntax syntax) {
>   if (str.size() == 2 && IsPathSeparator(str[0], syntax) && str[0] == str[1])
>     return 0;
> @@ -273,7 +273,7 @@ void FileSpec::Resolve(llvm::SmallVector
>   }
> }
> 
> -FileSpec::FileSpec() : m_syntax(GetNativeSyntax()) {}
> +FileSpec::FileSpec() : m_syntax(FileSystem::GetNativePathSyntax()) {}
> 
> //------------------------------------------------------------------
> // Default constructor that can take an optional full path to a
> @@ -336,7 +336,9 @@ void FileSpec::SetFile(llvm::StringRef p
>   m_filename.Clear();
>   m_directory.Clear();
>   m_is_resolved = false;
> -  m_syntax = (syntax == ePathSyntaxHostNative) ? GetNativeSyntax() : syntax;
> +  m_syntax = (syntax == ePathSyntaxHostNative)
> +                 ? FileSystem::GetNativePathSyntax()
> +                 : syntax;
> 
>   if (pathname.empty())
>     return;
> @@ -613,10 +615,16 @@ void FileSpec::Dump(Stream *s) const {
> //------------------------------------------------------------------
> // Returns true if the file exists.
> //------------------------------------------------------------------
> -bool FileSpec::Exists() const { return llvm::sys::fs::exists(GetPath()); }
> +bool FileSpec::Exists() const {
> +  struct stat file_stats;
> +  return GetFileStats(this, &file_stats);
> +}
> 
> bool FileSpec::Readable() const {
> -  return GetPermissions() & llvm::sys::fs::perms::all_read;
> +  const uint32_t permissions = GetPermissions();
> +  if (permissions & eFilePermissionsEveryoneR)
> +    return true;
> +  return false;
> }
> 
> bool FileSpec::ResolveExecutableLocation() {
> @@ -669,21 +677,67 @@ bool FileSpec::ResolvePath() {
> }
> 
> uint64_t FileSpec::GetByteSize() const {
> -  uint64_t Size = 0;
> -  if (llvm::sys::fs::file_size(GetPath(), Size))
> -    return 0;
> -  return Size;
> +  struct stat file_stats;
> +  if (GetFileStats(this, &file_stats))
> +    return file_stats.st_size;
> +  return 0;
> }
> 
> FileSpec::PathSyntax FileSpec::GetPathSyntax() const { return m_syntax; }
> 
> -uint32_t FileSpec::GetPermissions() const {
> -  namespace fs = llvm::sys::fs;
> -  fs::file_status st;
> -  if (fs::status(GetPath(), st))
> -    return fs::perms::perms_not_known;
> +FileSpec::FileType FileSpec::GetFileType() const {
> +  struct stat file_stats;
> +  if (GetFileStats(this, &file_stats)) {
> +    mode_t file_type = file_stats.st_mode & S_IFMT;
> +    switch (file_type) {
> +    case S_IFDIR:
> +      return eFileTypeDirectory;
> +    case S_IFREG:
> +      return eFileTypeRegular;
> +#ifndef _WIN32
> +    case S_IFIFO:
> +      return eFileTypePipe;
> +    case S_IFSOCK:
> +      return eFileTypeSocket;
> +    case S_IFLNK:
> +      return eFileTypeSymbolicLink;
> +#endif
> +    default:
> +      break;
> +    }
> +    return eFileTypeUnknown;
> +  }
> +  return eFileTypeInvalid;
> +}
> +
> +bool FileSpec::IsSymbolicLink() const {
> +  char resolved_path[PATH_MAX];
> +  if (!GetPath(resolved_path, sizeof(resolved_path)))
> +    return false;
> +
> +#ifdef _WIN32
> +  std::wstring wpath;
> +  if (!llvm::ConvertUTF8toWide(resolved_path, wpath))
> +    return false;
> +  auto attrs = ::GetFileAttributesW(wpath.c_str());
> +  if (attrs == INVALID_FILE_ATTRIBUTES)
> +    return false;
> 
> -  return st.permissions();
> +  return (attrs & FILE_ATTRIBUTE_REPARSE_POINT);
> +#else
> +  struct stat file_stats;
> +  if (::lstat(resolved_path, &file_stats) != 0)
> +    return false;
> +
> +  return (file_stats.st_mode & S_IFMT) == S_IFLNK;
> +#endif
> +}
> +
> +uint32_t FileSpec::GetPermissions() const {
> +  uint32_t file_permissions = 0;
> +  if (*this)
> +    FileSystem::GetFilePermissions(*this, file_permissions);
> +  return file_permissions;
> }
> 
> //------------------------------------------------------------------
> @@ -799,8 +853,7 @@ FileSpec::ForEachItemInDirectory(llvm::S
>     }
> 
>     do {
> -      namespace fs = llvm::sys::fs;
> -      fs::file_type ft = fs::file_type::type_unknown;
> +      FileSpec::FileType file_type = eFileTypeUnknown;
>       if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
>         size_t len = wcslen(ffd.cFileName);
> 
> @@ -810,11 +863,11 @@ FileSpec::ForEachItemInDirectory(llvm::S
>         if (len == 2 && ffd.cFileName[0] == L'.' && ffd.cFileName[1] == L'.')
>           continue;
> 
> -        ft = fs::file_type::directory_file;
> +        file_type = eFileTypeDirectory;
>       } else if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DEVICE) {
> -        ft = fs::file_type::type_unknown;
> +        file_type = eFileTypeOther;
>       } else {
> -        ft = fs::file_type::regular_file;
> +        file_type = eFileTypeRegular;
>       }
> 
>       std::string fileName;
> @@ -826,7 +879,7 @@ FileSpec::ForEachItemInDirectory(llvm::S
>       // Don't resolve the file type or path
>       FileSpec child_path_spec(child_path.data(), false);
> 
> -      EnumerateDirectoryResult result = callback(ft, child_path_spec);
> +      EnumerateDirectoryResult result = callback(file_type, child_path_spec);
> 
>       switch (result) {
>       case eEnumerateDirectoryResultNext:
> @@ -887,38 +940,37 @@ FileSpec::ForEachItemInDirectory(llvm::S
>             continue;
>         }
> 
> -        using namespace llvm::sys::fs;
> -        file_type ft = file_type::type_unknown;
> +        FileSpec::FileType file_type = eFileTypeUnknown;
> 
>         switch (dp->d_type) {
>         default:
>         case DT_UNKNOWN:
> -          ft = file_type::type_unknown;
> +          file_type = eFileTypeUnknown;
>           break;
>         case DT_FIFO:
> -          ft = file_type::fifo_file;
> +          file_type = eFileTypePipe;
>           break;
>         case DT_CHR:
> -          ft = file_type::character_file;
> +          file_type = eFileTypeOther;
>           break;
>         case DT_DIR:
> -          ft = file_type::directory_file;
> +          file_type = eFileTypeDirectory;
>           break;
>         case DT_BLK:
> -          ft = file_type::block_file;
> +          file_type = eFileTypeOther;
>           break;
>         case DT_REG:
> -          ft = file_type::regular_file;
> +          file_type = eFileTypeRegular;
>           break;
>         case DT_LNK:
> -          ft = file_type::symlink_file;
> +          file_type = eFileTypeSymbolicLink;
>           break;
>         case DT_SOCK:
> -          ft = file_type::socket_file;
> +          file_type = eFileTypeSocket;
>           break;
> #if !defined(__OpenBSD__)
>         case DT_WHT:
> -          ft = file_type::type_unknown;
> +          file_type = eFileTypeOther;
>           break;
> #endif
>         }
> @@ -933,7 +985,8 @@ FileSpec::ForEachItemInDirectory(llvm::S
>         // Don't resolve the file type or path
>         FileSpec child_path_spec(child_path, false);
> 
> -        EnumerateDirectoryResult result = callback(ft, child_path_spec);
> +        EnumerateDirectoryResult result =
> +            callback(file_type, child_path_spec);
> 
>         switch (result) {
>         case eEnumerateDirectoryResultNext:
> @@ -987,14 +1040,14 @@ FileSpec::EnumerateDirectory(llvm::Strin
>                              void *callback_baton) {
>   return ForEachItemInDirectory(
>       dir_path,
> -      [&find_directories, &find_files, &find_other, &callback, &callback_baton](
> -          llvm::sys::fs::file_type file_type, const FileSpec &file_spec) {
> +      [&find_directories, &find_files, &find_other, &callback,
> +       &callback_baton](FileType file_type, const FileSpec &file_spec) {
>         switch (file_type) {
> -        case llvm::sys::fs::file_type::directory_file:
> +        case FileType::eFileTypeDirectory:
>           if (find_directories)
>             return callback(callback_baton, file_type, file_spec);
>           break;
> -        case llvm::sys::fs::file_type::regular_file:
> +        case FileType::eFileTypeRegular:
>           if (find_files)
>             return callback(callback_baton, file_type, file_spec);
>           break;
> 
> Modified: lldb/trunk/source/Host/common/MonitoringProcessLauncher.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/MonitoringProcessLauncher.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Host/common/MonitoringProcessLauncher.cpp (original)
> +++ lldb/trunk/source/Host/common/MonitoringProcessLauncher.cpp Tue Mar  7 07:19:15 2017
> @@ -17,8 +17,6 @@
> #include "lldb/Utility/Error.h"
> #include "lldb/Utility/Log.h"
> 
> -#include "llvm/Support/FileSystem.h"
> -
> using namespace lldb;
> using namespace lldb_private;
> 
> @@ -40,8 +38,8 @@ MonitoringProcessLauncher::LaunchProcess
> 
>   FileSpec exe_spec(resolved_info.GetExecutableFile());
> 
> -  llvm::sys::fs::file_status stats;
> -  if (status(exe_spec.GetPath(), stats) || !is_regular_file(stats)) {
> +  FileSpec::FileType file_type = exe_spec.GetFileType();
> +  if (file_type != FileSpec::eFileTypeRegular) {
>     ModuleSpec module_spec(exe_spec, arch_spec);
>     lldb::ModuleSP exe_module_sp;
>     error =
> @@ -54,7 +52,7 @@ MonitoringProcessLauncher::LaunchProcess
>       exe_spec = exe_module_sp->GetFileSpec();
>   }
> 
> -  if (exists(stats)) {
> +  if (exe_spec.Exists()) {
>     exe_spec.GetPath(exe_path, sizeof(exe_path));
>   } else {
>     resolved_info.GetExecutableFile().GetPath(exe_path, sizeof(exe_path));
> 
> Modified: lldb/trunk/source/Host/common/Symbols.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Symbols.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Host/common/Symbols.cpp (original)
> +++ lldb/trunk/source/Host/common/Symbols.cpp Tue Mar  7 07:19:15 2017
> @@ -229,7 +229,7 @@ FileSpec Symbols::LocateExecutableSymbol
>     for (size_t idx = 0; idx < num_directories; ++idx) {
>       FileSpec dirspec = debug_file_search_paths.GetFileSpecAtIndex(idx);
>       dirspec.ResolvePath();
> -      if (!llvm::sys::fs::is_directory(dirspec.GetPath()))
> +      if (!dirspec.Exists() || !dirspec.IsDirectory())
>         continue;
> 
>       std::vector<std::string> files;
> 
> Modified: lldb/trunk/source/Host/macosx/Host.mm
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Host/macosx/Host.mm (original)
> +++ lldb/trunk/source/Host/macosx/Host.mm Tue Mar  7 07:19:15 2017
> @@ -75,8 +75,6 @@
> #include "lldb/Utility/NameMatches.h"
> #include "lldb/Utility/StreamString.h"
> 
> -#include "llvm/Support/FileSystem.h"
> -
> #include "cfcpp/CFCBundle.h"
> #include "cfcpp/CFCMutableArray.h"
> #include "cfcpp/CFCMutableDictionary.h"
> @@ -103,7 +101,7 @@ using namespace lldb_private;
> bool Host::GetBundleDirectory(const FileSpec &file,
>                               FileSpec &bundle_directory) {
> #if defined(__APPLE__)
> -  if (llvm::sys::fs::is_directory(file.GetPath())) {
> +  if (file.GetFileType() == FileSpec::eFileTypeDirectory) {
>     char path[PATH_MAX];
>     if (file.GetPath(path, sizeof(path))) {
>       CFCBundle bundle(path);
> @@ -120,7 +118,7 @@ bool Host::GetBundleDirectory(const File
> 
> bool Host::ResolveExecutableInBundle(FileSpec &file) {
> #if defined(__APPLE__)
> -  if (llvm::sys::fs::is_directory(file.GetPath())) {
> +  if (file.GetFileType() == FileSpec::eFileTypeDirectory) {
>     char path[PATH_MAX];
>     if (file.GetPath(path, sizeof(path))) {
>       CFCBundle bundle(path);
> @@ -1186,8 +1184,8 @@ Error Host::LaunchProcess(ProcessLaunchI
>   ModuleSpec exe_module_spec(launch_info.GetExecutableFile(),
>                              launch_info.GetArchitecture());
> 
> -  if (!llvm::sys::fs::is_regular_file(
> -          exe_module_spec.GetFileSpec().GetPath())) {
> +  FileSpec::FileType file_type = exe_module_spec.GetFileSpec().GetFileType();
> +  if (file_type != FileSpec::eFileTypeRegular) {
>     lldb::ModuleSP exe_module_sp;
>     error = host_platform_sp->ResolveExecutable(exe_module_spec, exe_module_sp,
>                                                 NULL);
> 
> Modified: lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm (original)
> +++ lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm Tue Mar  7 07:19:15 2017
> @@ -18,7 +18,6 @@
> #include "lldb/Utility/SafeMachO.h"
> 
> #include "llvm/ADT/SmallString.h"
> -#include "llvm/Support/FileSystem.h"
> #include "llvm/Support/raw_ostream.h"
> 
> // C++ Includes
> @@ -153,7 +152,7 @@ bool HostInfoMacOSX::ComputeSupportExeDi
>     // the lldb driver.
>     raw_path.append("/../bin");
>     FileSpec support_dir_spec(raw_path, true);
> -    if (!llvm::sys::fs::is_directory(support_dir_spec.GetPath())) {
> +    if (!support_dir_spec.Exists() || !support_dir_spec.IsDirectory()) {
>       Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
>       if (log)
>         log->Printf("HostInfoMacOSX::%s(): failed to find support directory",
> 
> Modified: lldb/trunk/source/Host/macosx/Symbols.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Symbols.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Host/macosx/Symbols.cpp (original)
> +++ lldb/trunk/source/Host/macosx/Symbols.cpp Tue Mar  7 07:19:15 2017
> @@ -38,8 +38,6 @@
> #include "lldb/Utility/UUID.h"
> #include "mach/machine.h"
> 
> -#include "llvm/Support/FileSystem.h"
> -
> using namespace lldb;
> using namespace lldb_private;
> using namespace llvm::MachO;
> @@ -103,7 +101,7 @@ int LocateMacOSXFilesUsingDebugSymbols(c
>             }
>             FileSpec dsym_filespec(path, path[0] == '~');
> 
> -            if (llvm::sys::fs::is_directory(dsym_filespec.GetPath())) {
> +            if (dsym_filespec.GetFileType() == FileSpec::eFileTypeDirectory) {
>               dsym_filespec =
>                   Symbols::FindSymbolFileInBundle(dsym_filespec, uuid, arch);
>               ++items_found;
> @@ -166,10 +164,8 @@ int LocateMacOSXFilesUsingDebugSymbols(c
>                 FileSpec file_spec(path, true);
>                 ModuleSpecList module_specs;
>                 ModuleSpec matched_module_spec;
> -                using namespace llvm::sys::fs;
> -                switch (get_file_type(file_spec.GetPath())) {
> -
> -                case file_type::directory_file: // Bundle directory?
> +                switch (file_spec.GetFileType()) {
> +                case FileSpec::eFileTypeDirectory: // Bundle directory?
>                 {
>                   CFCBundle bundle(path);
>                   CFCReleaser<CFURLRef> bundle_exe_url(
> @@ -197,17 +193,15 @@ int LocateMacOSXFilesUsingDebugSymbols(c
>                   }
>                 } break;
> 
> -                case file_type::fifo_file:      // Forget pipes
> -                case file_type::socket_file:    // We can't process socket files
> -                case file_type::file_not_found: // File doesn't exist...
> -                case file_type::status_error:
> +                case FileSpec::eFileTypePipe:   // Forget pipes
> +                case FileSpec::eFileTypeSocket: // We can't process socket files
> +                case FileSpec::eFileTypeInvalid: // File doesn't exist...
>                   break;
> 
> -                case file_type::type_unknown:
> -                case file_type::regular_file:
> -                case file_type::symlink_file:
> -                case file_type::block_file:
> -                case file_type::character_file:
> +                case FileSpec::eFileTypeUnknown:
> +                case FileSpec::eFileTypeRegular:
> +                case FileSpec::eFileTypeSymbolicLink:
> +                case FileSpec::eFileTypeOther:
>                   if (ObjectFile::GetModuleSpecifications(file_spec, 0, 0,
>                                                           module_specs) &&
>                       module_specs.FindMatchingModuleSpec(module_spec,
> 
> Modified: lldb/trunk/source/Host/posix/FileSystem.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/FileSystem.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Host/posix/FileSystem.cpp (original)
> +++ lldb/trunk/source/Host/posix/FileSystem.cpp Tue Mar  7 07:19:15 2017
> @@ -29,8 +29,6 @@
> #include "lldb/Utility/Error.h"
> #include "lldb/Utility/StreamString.h"
> 
> -#include "llvm/Support/FileSystem.h"
> -
> using namespace lldb;
> using namespace lldb_private;
> 
> @@ -63,7 +61,7 @@ Error FileSystem::MakeDirectory(const Fi
>         return error;
>       } break;
>       case EEXIST: {
> -        if (llvm::sys::fs::is_directory(file_spec.GetPath()))
> +        if (file_spec.IsDirectory())
>           return Error(); // It is a directory and it already exists
>       } break;
>       }
> @@ -85,9 +83,9 @@ Error FileSystem::DeleteDirectory(const
>       FileSpec::ForEachItemInDirectory(
>           file_spec.GetCString(),
>           [&error, &sub_directories](
> -              llvm::sys::fs::file_type ft,
> +              FileSpec::FileType file_type,
>               const FileSpec &spec) -> FileSpec::EnumerateDirectoryResult {
> -            if (ft == llvm::sys::fs::file_type::directory_file) {
> +            if (file_type == FileSpec::eFileTypeDirectory) {
>               // Save all directorires and process them after iterating through
>               // this directory
>               sub_directories.push_back(spec);
> 
> Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp (original)
> +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp Tue Mar  7 07:19:15 2017
> @@ -20,7 +20,6 @@
> #include "clang/Parse/Parser.h"
> #include "clang/Sema/Lookup.h"
> #include "clang/Serialization/ASTReader.h"
> -#include "llvm/Support/FileSystem.h"
> #include "llvm/Support/Path.h"
> #include "llvm/Support/Threading.h"
> 
> @@ -607,7 +606,7 @@ ClangModulesDeclVendor::Create(Target &t
>   {
>     FileSpec clang_resource_dir = GetResourceDir();
> 
> -    if (llvm::sys::fs::is_directory(clang_resource_dir.GetPath())) {
> +    if (clang_resource_dir.IsDirectory()) {
>       compiler_invocation_arguments.push_back("-resource-dir");
>       compiler_invocation_arguments.push_back(clang_resource_dir.GetPath());
>     }
> 
> Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp (original)
> +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp Tue Mar  7 07:19:15 2017
> @@ -28,8 +28,6 @@
> #include "lldb/Utility/Log.h"
> #include "lldb/Utility/StreamString.h"
> 
> -#include "llvm/Support/FileSystem.h"
> -
> using namespace lldb;
> using namespace lldb_private;
> 
> @@ -248,9 +246,9 @@ Error PlatformAppleTVSimulator::ResolveE
> }
> 
> static FileSpec::EnumerateDirectoryResult
> -EnumerateDirectoryCallback(void *baton, llvm::sys::fs::file_type ft,
> +EnumerateDirectoryCallback(void *baton, FileSpec::FileType file_type,
>                            const FileSpec &file_spec) {
> -  if (ft == llvm::sys::fs::file_type::directory_file) {
> +  if (file_type == FileSpec::eFileTypeDirectory) {
>     const char *filename = file_spec.GetFilename().GetCString();
>     if (filename &&
>         strncmp(filename, "AppleTVSimulator", strlen("AppleTVSimulator")) ==
> 
> Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp (original)
> +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp Tue Mar  7 07:19:15 2017
> @@ -248,9 +248,9 @@ Error PlatformAppleWatchSimulator::Resol
> }
> 
> static FileSpec::EnumerateDirectoryResult
> -EnumerateDirectoryCallback(void *baton, llvm::sys::fs::file_type ft,
> +EnumerateDirectoryCallback(void *baton, FileSpec::FileType file_type,
>                            const FileSpec &file_spec) {
> -  if (ft == llvm::sys::fs::file_type::directory_file) {
> +  if (file_type == FileSpec::eFileTypeDirectory) {
>     const char *filename = file_spec.GetFilename().GetCString();
>     if (filename &&
>         strncmp(filename, "AppleWatchSimulator",
> 
> Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
> +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Tue Mar  7 07:19:15 2017
> @@ -41,7 +41,6 @@
> #include "lldb/Utility/Error.h"
> #include "lldb/Utility/Log.h"
> #include "llvm/ADT/STLExtras.h"
> -#include "llvm/Support/FileSystem.h"
> #include "llvm/Support/Threading.h"
> 
> #if defined(__APPLE__)
> @@ -202,15 +201,8 @@ Error PlatformDarwin::ResolveSymbolFile(
>                                         FileSpec &sym_file) {
>   Error error;
>   sym_file = sym_spec.GetSymbolFileSpec();
> -
> -  llvm::sys::fs::file_status st;
> -  if (status(sym_file.GetPath(), st)) {
> -    error.SetErrorString("Could not stat file!");
> -    return error;
> -  }
> -
> -  if (exists(st)) {
> -    if (is_directory(st)) {
> +  if (sym_file.Exists()) {
> +    if (sym_file.GetFileType() == FileSpec::eFileTypeDirectory) {
>       sym_file = Symbols::FindSymbolFileInBundle(
>           sym_file, sym_spec.GetUUIDPtr(), sym_spec.GetArchitecturePtr());
>     }
> @@ -1202,7 +1194,7 @@ const char *PlatformDarwin::GetDeveloper
>           developer_dir_path[i] = '\0';
> 
>           FileSpec devel_dir(developer_dir_path, false);
> -          if (llvm::sys::fs::is_directory(devel_dir.GetPath())) {
> +          if (devel_dir.Exists() && devel_dir.IsDirectory()) {
>             developer_dir_path_valid = true;
>           }
>         }
> @@ -1447,8 +1439,9 @@ bool PlatformDarwin::SDKSupportsModules(
>   return false;
> }
> 
> -FileSpec::EnumerateDirectoryResult PlatformDarwin::DirectoryEnumerator(
> -    void *baton, llvm::sys::fs::file_type file_type, const FileSpec &spec) {
> +FileSpec::EnumerateDirectoryResult
> +PlatformDarwin::DirectoryEnumerator(void *baton, FileSpec::FileType file_type,
> +                                    const FileSpec &spec) {
>   SDKEnumeratorInfo *enumerator_info = static_cast<SDKEnumeratorInfo *>(baton);
> 
>   if (SDKSupportsModules(enumerator_info->sdk_type, spec)) {
> @@ -1463,9 +1456,8 @@ FileSpec PlatformDarwin::FindSDKInXcodeF
>                                                   const FileSpec &sdks_spec) {
>   // Look inside Xcode for the required installed iOS SDK version
> 
> -  if (!llvm::sys::fs::is_directory(sdks_spec.GetPath())) {
> +  if (!sdks_spec.IsDirectory())
>     return FileSpec();
> -  }
> 
>   const bool find_directories = true;
>   const bool find_files = false;
> @@ -1479,7 +1471,7 @@ FileSpec PlatformDarwin::FindSDKInXcodeF
>                                find_files, find_other, DirectoryEnumerator,
>                                &enumerator_info);
> 
> -  if (llvm::sys::fs::is_directory(enumerator_info.found_path.GetPath()))
> +  if (enumerator_info.found_path.IsDirectory())
>     return enumerator_info.found_path;
>   else
>     return FileSpec();
> @@ -1638,7 +1630,7 @@ void PlatformDarwin::AddClangModuleCompi
>     sysroot_spec = GetSDKDirectoryForModules(sdk_type);
>   }
> 
> -  if (llvm::sys::fs::is_directory(sysroot_spec.GetPath())) {
> +  if (sysroot_spec.IsDirectory()) {
>     options.push_back("-isysroot");
>     options.push_back(sysroot_spec.GetPath());
>   }
> 
> Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h (original)
> +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h Tue Mar  7 07:19:15 2017
> @@ -18,7 +18,6 @@
> #include "Plugins/Platform/POSIX/PlatformPOSIX.h"
> #include "lldb/Host/FileSpec.h"
> #include "llvm/ADT/StringRef.h"
> -#include "llvm/Support/FileSystem.h"
> 
> #include <string>
> #include <tuple>
> @@ -113,7 +112,7 @@ protected:
>   };
> 
>   static lldb_private::FileSpec::EnumerateDirectoryResult
> -  DirectoryEnumerator(void *baton, llvm::sys::fs::file_type file_type,
> +  DirectoryEnumerator(void *baton, lldb_private::FileSpec::FileType file_type,
>                       const lldb_private::FileSpec &spec);
> 
>   static lldb_private::FileSpec
> 
> Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp (original)
> +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp Tue Mar  7 07:19:15 2017
> @@ -36,8 +36,6 @@
> #include "lldb/Utility/Log.h"
> #include "lldb/Utility/StreamString.h"
> 
> -#include "llvm/Support/FileSystem.h"
> -
> #include <CoreFoundation/CoreFoundation.h>
> 
> #include "Host/macosx/cfcpp/CFCBundle.h"
> @@ -383,7 +381,7 @@ void PlatformDarwinKernel::CollectKextAn
> 
>   // Add simple directory /Applications/Xcode.app/Contents/Developer/../Symbols
>   FileSpec possible_dir(developer_dir + "/../Symbols", true);
> -  if (llvm::sys::fs::is_directory(possible_dir.GetPath()))
> +  if (possible_dir.Exists() && possible_dir.IsDirectory())
>     m_search_directories.push_back(possible_dir);
> 
>   // Add simple directory of the current working directory
> @@ -398,7 +396,7 @@ void PlatformDarwinKernel::GetUserSpecif
>   for (uint32_t i = 0; i < user_dirs_count; i++) {
>     FileSpec dir = user_dirs.GetFileSpecAtIndex(i);
>     dir.ResolvePath();
> -    if (llvm::sys::fs::is_directory(dir.GetPath())) {
> +    if (dir.Exists() && dir.IsDirectory()) {
>       m_search_directories.push_back(dir);
>     }
>   }
> @@ -414,7 +412,7 @@ void PlatformDarwinKernel::AddRootSubdir
>       nullptr};
>   for (int i = 0; subdirs[i] != nullptr; i++) {
>     FileSpec testdir(dir + subdirs[i], true);
> -    if (llvm::sys::fs::is_directory(testdir.GetPath()))
> +    if (testdir.Exists() && testdir.IsDirectory())
>       thisp->m_search_directories.push_back(testdir);
>   }
> 
> @@ -437,12 +435,12 @@ void PlatformDarwinKernel::AddSDKSubdirs
> // Helper function to find *.sdk and *.kdk directories in a given directory.
> FileSpec::EnumerateDirectoryResult
> PlatformDarwinKernel::FindKDKandSDKDirectoriesInDirectory(
> -    void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec) {
> +    void *baton, FileSpec::FileType file_type, const FileSpec &file_spec) {
>   static ConstString g_sdk_suffix = ConstString("sdk");
>   static ConstString g_kdk_suffix = ConstString("kdk");
> 
>   PlatformDarwinKernel *thisp = (PlatformDarwinKernel *)baton;
> -  if (ft == llvm::sys::fs::file_type::directory_file &&
> +  if (file_type == FileSpec::eFileTypeDirectory &&
>       (file_spec.GetFileNameExtension() == g_sdk_suffix ||
>        file_spec.GetFileNameExtension() == g_kdk_suffix)) {
>     AddRootSubdirsToSearchPaths(thisp, file_spec.GetPath());
> @@ -488,19 +486,20 @@ void PlatformDarwinKernel::SearchForKext
> 
> FileSpec::EnumerateDirectoryResult
> PlatformDarwinKernel::GetKernelsAndKextsInDirectoryWithRecursion(
> -    void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec) {
> -  return GetKernelsAndKextsInDirectoryHelper(baton, ft, file_spec, true);
> +    void *baton, FileSpec::FileType file_type, const FileSpec &file_spec) {
> +  return GetKernelsAndKextsInDirectoryHelper(baton, file_type, file_spec, true);
> }
> 
> FileSpec::EnumerateDirectoryResult
> PlatformDarwinKernel::GetKernelsAndKextsInDirectoryNoRecursion(
> -    void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec) {
> -  return GetKernelsAndKextsInDirectoryHelper(baton, ft, file_spec, false);
> +    void *baton, FileSpec::FileType file_type, const FileSpec &file_spec) {
> +  return GetKernelsAndKextsInDirectoryHelper(baton, file_type, file_spec,
> +                                             false);
> }
> 
> FileSpec::EnumerateDirectoryResult
> PlatformDarwinKernel::GetKernelsAndKextsInDirectoryHelper(
> -    void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec,
> +    void *baton, FileSpec::FileType file_type, const FileSpec &file_spec,
>     bool recurse) {
>   static ConstString g_kext_suffix = ConstString("kext");
>   static ConstString g_dsym_suffix = ConstString("dSYM");
> @@ -513,8 +512,8 @@ PlatformDarwinKernel::GetKernelsAndKexts
>                 file_spec.GetPath().c_str());
> 
>   PlatformDarwinKernel *thisp = (PlatformDarwinKernel *)baton;
> -  if (ft == llvm::sys::fs::file_type::regular_file ||
> -      ft == llvm::sys::fs::file_type::symlink_file) {
> +  if (file_type == FileSpec::eFileTypeRegular ||
> +      file_type == FileSpec::eFileTypeSymbolicLink) {
>     ConstString filename = file_spec.GetFilename();
>     if ((strncmp(filename.GetCString(), "kernel", 6) == 0 ||
>          strncmp(filename.GetCString(), "mach", 4) == 0) &&
> @@ -525,17 +524,17 @@ PlatformDarwinKernel::GetKernelsAndKexts
>         thisp->m_kernel_binaries_without_dsyms.push_back(file_spec);
>       return FileSpec::eEnumerateDirectoryResultNext;
>     }
> -  } else if (ft == llvm::sys::fs::file_type::directory_file &&
> +  } else if (file_type == FileSpec::eFileTypeDirectory &&
>              file_spec_extension == g_kext_suffix) {
>     AddKextToMap(thisp, file_spec);
>     // Look to see if there is a PlugIns subdir with more kexts
>     FileSpec contents_plugins(file_spec.GetPath() + "/Contents/PlugIns", false);
>     std::string search_here_too;
> -    if (llvm::sys::fs::is_directory(contents_plugins.GetPath())) {
> +    if (contents_plugins.Exists() && contents_plugins.IsDirectory()) {
>       search_here_too = contents_plugins.GetPath();
>     } else {
>       FileSpec plugins(file_spec.GetPath() + "/PlugIns", false);
> -      if (llvm::sys::fs::is_directory(plugins.GetPath())) {
> +      if (plugins.Exists() && plugins.IsDirectory()) {
>         search_here_too = plugins.GetPath();
>       }
>     }
> @@ -592,7 +591,7 @@ bool PlatformDarwinKernel::KextHasdSYMSi
>   std::string filename = dsym_fspec.GetFilename().AsCString();
>   filename += ".dSYM";
>   dsym_fspec.GetFilename() = ConstString(filename);
> -  if (llvm::sys::fs::is_directory(dsym_fspec.GetPath())) {
> +  if (dsym_fspec.Exists() && dsym_fspec.IsDirectory()) {
>     return true;
>   }
>   // Should probably get the CFBundleExecutable here or call
> @@ -606,7 +605,7 @@ bool PlatformDarwinKernel::KextHasdSYMSi
>   deep_bundle_str += executable_name.AsCString();
>   deep_bundle_str += ".dSYM";
>   dsym_fspec.SetFile(deep_bundle_str, true);
> -  if (llvm::sys::fs::is_directory(dsym_fspec.GetPath())) {
> +  if (dsym_fspec.Exists() && dsym_fspec.IsDirectory()) {
>     return true;
>   }
> 
> @@ -616,7 +615,7 @@ bool PlatformDarwinKernel::KextHasdSYMSi
>   shallow_bundle_str += executable_name.AsCString();
>   shallow_bundle_str += ".dSYM";
>   dsym_fspec.SetFile(shallow_bundle_str, true);
> -  if (llvm::sys::fs::is_directory(dsym_fspec.GetPath())) {
> +  if (dsym_fspec.Exists() && dsym_fspec.IsDirectory()) {
>     return true;
>   }
>   return false;
> @@ -630,7 +629,7 @@ bool PlatformDarwinKernel::KernelHasdSYM
>   std::string filename = kernel_binary.GetFilename().AsCString();
>   filename += ".dSYM";
>   kernel_dsym.GetFilename() = ConstString(filename);
> -  if (llvm::sys::fs::is_directory(kernel_dsym.GetPath())) {
> +  if (kernel_dsym.Exists() && kernel_dsym.IsDirectory()) {
>     return true;
>   }
>   return false;
> 
> Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h (original)
> +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h Tue Mar  7 07:19:15 2017
> @@ -20,8 +20,6 @@
> // Other libraries and framework includes
> #include "lldb/Host/FileSpec.h"
> 
> -#include "llvm/Support/FileSystem.h"
> -
> // Project includes
> #include "PlatformDarwin.h"
> 
> @@ -107,25 +105,26 @@ protected:
>   void AddSDKSubdirsToSearchPaths(const std::string &dir);
> 
>   static lldb_private::FileSpec::EnumerateDirectoryResult
> -  FindKDKandSDKDirectoriesInDirectory(void *baton, llvm::sys::fs::file_type ft,
> -                                      const lldb_private::FileSpec &file_spec);
> +  FindKDKandSDKDirectoriesInDirectory(
> +      void *baton, lldb_private::FileSpec::FileType file_type,
> +      const lldb_private::FileSpec &file_spec);
> 
>   void SearchForKextsAndKernelsRecursively();
> 
>   static lldb_private::FileSpec::EnumerateDirectoryResult
>   GetKernelsAndKextsInDirectoryWithRecursion(
> -      void *baton, llvm::sys::fs::file_type ft,
> +      void *baton, lldb_private::FileSpec::FileType file_type,
>       const lldb_private::FileSpec &file_spec);
> 
>   static lldb_private::FileSpec::EnumerateDirectoryResult
>   GetKernelsAndKextsInDirectoryNoRecursion(
> -      void *baton, llvm::sys::fs::file_type ft,
> +      void *baton, lldb_private::FileSpec::FileType file_type,
>       const lldb_private::FileSpec &file_spec);
> 
>   static lldb_private::FileSpec::EnumerateDirectoryResult
> -  GetKernelsAndKextsInDirectoryHelper(void *baton, llvm::sys::fs::file_type ft,
> -                                      const lldb_private::FileSpec &file_spec,
> -                                      bool recurse);
> +  GetKernelsAndKextsInDirectoryHelper(
> +      void *baton, lldb_private::FileSpec::FileType file_type,
> +      const lldb_private::FileSpec &file_spec, bool recurse);
> 
>   static void AddKextToMap(PlatformDarwinKernel *thisp,
>                            const lldb_private::FileSpec &file_spec);
> 
> Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp (original)
> +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp Tue Mar  7 07:19:15 2017
> @@ -250,7 +250,7 @@ Error PlatformRemoteAppleTV::ResolveExec
> 
> FileSpec::EnumerateDirectoryResult
> PlatformRemoteAppleTV::GetContainedFilesIntoVectorOfStringsCallback(
> -    void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec) {
> +    void *baton, FileSpec::FileType file_type, const FileSpec &file_spec) {
>   ((PlatformRemoteAppleTV::SDKDirectoryInfoCollection *)baton)
>       ->push_back(PlatformRemoteAppleTV::SDKDirectoryInfo(file_spec));
>   return FileSpec::eEnumerateDirectoryResultNext;
> 
> Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h (original)
> +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h Tue Mar  7 07:19:15 2017
> @@ -18,8 +18,6 @@
> // Project includes
> #include "lldb/Host/FileSpec.h"
> 
> -#include "llvm/Support/FileSystem.h"
> -
> #include "PlatformDarwin.h"
> 
> class PlatformRemoteAppleTV : public PlatformDarwin {
> @@ -118,7 +116,7 @@ protected:
> 
>   static lldb_private::FileSpec::EnumerateDirectoryResult
>   GetContainedFilesIntoVectorOfStringsCallback(
> -      void *baton, llvm::sys::fs::file_type ft,
> +      void *baton, lldb_private::FileSpec::FileType file_type,
>       const lldb_private::FileSpec &file_spec);
> 
>   uint32_t FindFileInAllSDKs(const char *platform_file_path,
> 
> Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp (original)
> +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp Tue Mar  7 07:19:15 2017
> @@ -260,7 +260,7 @@ Error PlatformRemoteAppleWatch::ResolveE
> 
> FileSpec::EnumerateDirectoryResult
> PlatformRemoteAppleWatch::GetContainedFilesIntoVectorOfStringsCallback(
> -    void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec) {
> +    void *baton, FileSpec::FileType file_type, const FileSpec &file_spec) {
>   ((PlatformRemoteAppleWatch::SDKDirectoryInfoCollection *)baton)
>       ->push_back(PlatformRemoteAppleWatch::SDKDirectoryInfo(file_spec));
>   return FileSpec::eEnumerateDirectoryResultNext;
> 
> Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h (original)
> +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h Tue Mar  7 07:19:15 2017
> @@ -21,8 +21,6 @@
> 
> #include "PlatformDarwin.h"
> 
> -#include "llvm/Support/FileSystem.h"
> -
> class PlatformRemoteAppleWatch : public PlatformDarwin {
> public:
>   PlatformRemoteAppleWatch();
> @@ -120,7 +118,7 @@ protected:
> 
>   static lldb_private::FileSpec::EnumerateDirectoryResult
>   GetContainedFilesIntoVectorOfStringsCallback(
> -      void *baton, llvm::sys::fs::file_type ft,
> +      void *baton, lldb_private::FileSpec::FileType file_type,
>       const lldb_private::FileSpec &file_spec);
> 
>   uint32_t FindFileInAllSDKs(const char *platform_file_path,
> 
> Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp (original)
> +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp Tue Mar  7 07:19:15 2017
> @@ -255,7 +255,7 @@ Error PlatformRemoteiOS::ResolveExecutab
> 
> FileSpec::EnumerateDirectoryResult
> PlatformRemoteiOS::GetContainedFilesIntoVectorOfStringsCallback(
> -    void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec) {
> +    void *baton, FileSpec::FileType file_type, const FileSpec &file_spec) {
>   ((PlatformRemoteiOS::SDKDirectoryInfoCollection *)baton)
>       ->push_back(PlatformRemoteiOS::SDKDirectoryInfo(file_spec));
>   return FileSpec::eEnumerateDirectoryResultNext;
> 
> Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h (original)
> +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h Tue Mar  7 07:19:15 2017
> @@ -19,8 +19,6 @@
> #include "PlatformDarwin.h"
> #include "lldb/Host/FileSpec.h"
> 
> -#include "llvm/Support/FileSystem.h"
> -
> class PlatformRemoteiOS : public PlatformDarwin {
> public:
>   PlatformRemoteiOS();
> @@ -116,7 +114,7 @@ protected:
> 
>   static lldb_private::FileSpec::EnumerateDirectoryResult
>   GetContainedFilesIntoVectorOfStringsCallback(
> -      void *baton, llvm::sys::fs::file_type ft,
> +      void *baton, lldb_private::FileSpec::FileType file_type,
>       const lldb_private::FileSpec &file_spec);
> 
>   uint32_t FindFileInAllSDKs(const char *platform_file_path,
> 
> Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp (original)
> +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp Tue Mar  7 07:19:15 2017
> @@ -29,8 +29,6 @@
> #include "lldb/Utility/Log.h"
> #include "lldb/Utility/StreamString.h"
> 
> -#include "llvm/Support/FileSystem.h"
> -
> using namespace lldb;
> using namespace lldb_private;
> 
> @@ -254,9 +252,9 @@ Error PlatformiOSSimulator::ResolveExecu
> }
> 
> static FileSpec::EnumerateDirectoryResult
> -EnumerateDirectoryCallback(void *baton, llvm::sys::fs::file_type ft,
> +EnumerateDirectoryCallback(void *baton, FileSpec::FileType file_type,
>                            const FileSpec &file_spec) {
> -  if (ft == llvm::sys::fs::file_type::directory_file) {
> +  if (file_type == FileSpec::eFileTypeDirectory) {
>     const char *filename = file_spec.GetFilename().GetCString();
>     if (filename &&
>         strncmp(filename, "iPhoneSimulator", strlen("iPhoneSimulator")) == 0) {
> 
> Modified: lldb/trunk/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp (original)
> +++ lldb/trunk/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp Tue Mar  7 07:19:15 2017
> @@ -31,8 +31,6 @@
> 
> #include "MachException.h"
> 
> -#include "llvm/Support/FileSystem.h"
> -
> using namespace lldb;
> using namespace lldb_private;
> using namespace lldb_private::process_darwin;
> @@ -65,7 +63,7 @@ Error NativeProcessProtocol::Launch(
>   FileSpec working_dir(launch_info.GetWorkingDirectory());
>   if (working_dir &&
>       (!working_dir.ResolvePath() ||
> -       !llvm::sys::fs::is_directory(working_dir.GetPath())) {
> +       working_dir.GetFileType() != FileSpec::eFileTypeDirectory)) {
>     error.SetErrorStringWithFormat("No such file or directory: %s",
>                                    working_dir.GetCString());
>     return error;
> 
> Modified: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp (original)
> +++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp Tue Mar  7 07:19:15 2017
> @@ -46,7 +46,6 @@
> 
> #include "lldb/Host/posix/Fcntl.h"
> 
> -#include "llvm/Support/FileSystem.h"
> #include "llvm/Support/Threading.h"
> 
> using namespace lldb;
> @@ -362,9 +361,9 @@ Error ProcessFreeBSD::DoLaunch(Module *m
>   assert(m_monitor == NULL);
> 
>   FileSpec working_dir = launch_info.GetWorkingDirectory();
> -  namespace fs = llvm::sys::fs;
> -  if (working_dir && (!working_dir.ResolvePath() ||
> -                      !fs::is_directory(working_dir.GetPath()))) {
> +  if (working_dir &&
> +      (!working_dir.ResolvePath() ||
> +       working_dir.GetFileType() != FileSpec::eFileTypeDirectory)) {
>     error.SetErrorStringWithFormat("No such file or directory: %s",
>                                    working_dir.GetCString());
>     return error;
> 
> Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original)
> +++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Tue Mar  7 07:19:15 2017
> @@ -49,7 +49,6 @@
> #include "ProcFileReader.h"
> #include "Procfs.h"
> 
> -#include "llvm/Support/FileSystem.h"
> #include "llvm/Support/Threading.h"
> 
> #include <linux/unistd.h>
> @@ -225,8 +224,9 @@ Error NativeProcessProtocol::Launch(
> 
>   // Verify the working directory is valid if one was specified.
>   FileSpec working_dir{launch_info.GetWorkingDirectory()};
> -  if (working_dir && (!working_dir.ResolvePath() ||
> -                      !llvm::sys::fs::is_directory(working_dir.GetPath()))) {
> +  if (working_dir &&
> +      (!working_dir.ResolvePath() ||
> +       working_dir.GetFileType() != FileSpec::eFileTypeDirectory)) {
>     error.SetErrorStringWithFormat("No such file or directory: %s",
>                                    working_dir.GetCString());
>     return error;
> 
> Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (original)
> +++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Tue Mar  7 07:19:15 2017
> @@ -51,7 +51,6 @@
> 
> #include "llvm/ADT/STLExtras.h"
> #include "llvm/ADT/StringRef.h"
> -#include "llvm/Support/FileSystem.h"
> 
> using namespace lldb;
> using namespace lldb_private;
> @@ -2576,13 +2575,9 @@ bool ScriptInterpreterPython::LoadScript
>                              Locker::NoSTDIN,
>                    Locker::FreeAcquiredLock |
>                        (init_session ? Locker::TearDownSession : 0));
> -    namespace fs = llvm::sys::fs;
> -    fs::file_status st;
> -    std::error_code ec = status(target_file.GetPath(), st);
> -
> -    if (ec || st.type() == fs::file_type::status_error ||
> -        st.type() == fs::file_type::type_unknown ||
> -        st.type() == fs::file_type::file_not_found) {
> +
> +    if (target_file.GetFileType() == FileSpec::eFileTypeInvalid ||
> +        target_file.GetFileType() == FileSpec::eFileTypeUnknown) {
>       // if not a valid file of any sort, check if it might be a filename still
>       // dot can't be used but / and \ can, and if either is found, reject
>       if (strchr(pathname, '\\') || strchr(pathname, '/')) {
> @@ -2591,8 +2586,9 @@ bool ScriptInterpreterPython::LoadScript
>       }
>       basename = pathname; // not a filename, probably a package of some sort,
>                            // let it go through
> -    } else if (is_directory(st) || fs::is_regular_file(st) ||
> -               st.type() == fs::file_type::symlink_file) {
> +    } else if (target_file.GetFileType() == FileSpec::eFileTypeDirectory ||
> +               target_file.GetFileType() == FileSpec::eFileTypeRegular ||
> +               target_file.GetFileType() == FileSpec::eFileTypeSymbolicLink) {
>       std::string directory = target_file.GetDirectory().GetCString();
>       replace_all(directory, "\\", "\\\\");
>       replace_all(directory, "'", "\\'");
> 
> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Mar  7 07:19:15 2017
> @@ -72,8 +72,6 @@
> #include "SymbolFileDWARFDebugMap.h"
> #include "SymbolFileDWARFDwo.h"
> 
> -#include "llvm/Support/FileSystem.h"
> -
> #include <map>
> 
> #include <ctype.h>
> @@ -193,9 +191,7 @@ static const char *resolveCompDir(const
>   if (!is_symlink)
>     return local_path;
> 
> -  namespace fs = llvm::sys::fs;
> -  if (fs::get_file_type(local_path_spec.GetPath()) !=
> -      fs::file_type::symlink_file)
> +  if (!local_path_spec.IsSymbolicLink())
>     return local_path;
> 
>   FileSpec resolved_local_path_spec;
> 
> Modified: lldb/trunk/source/Target/ModuleCache.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ModuleCache.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Target/ModuleCache.cpp (original)
> +++ lldb/trunk/source/Target/ModuleCache.cpp Tue Mar  7 07:19:15 2017
> @@ -59,19 +59,15 @@ public:
>   void Delete();
> };
> 
> -static FileSpec JoinPath(const FileSpec &path1, const char *path2) {
> +FileSpec JoinPath(const FileSpec &path1, const char *path2) {
>   FileSpec result_spec(path1);
>   result_spec.AppendPathComponent(path2);
>   return result_spec;
> }
> 
> -static Error MakeDirectory(const FileSpec &dir_path) {
> -  llvm::sys::fs::file_status st;
> -  if (status(dir_path.GetPath(), st))
> -    return Error("Could not stat path");
> -
> -  if (exists(st)) {
> -    if (!is_directory(st))
> +Error MakeDirectory(const FileSpec &dir_path) {
> +  if (dir_path.Exists()) {
> +    if (!dir_path.IsDirectory())
>       return Error("Invalid existing path");
> 
>     return Error();
> 
> Modified: lldb/trunk/source/Target/Platform.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Target/Platform.cpp (original)
> +++ lldb/trunk/source/Target/Platform.cpp Tue Mar  7 07:19:15 2017
> @@ -42,8 +42,6 @@
> #include "lldb/Utility/Error.h"
> #include "lldb/Utility/Log.h"
> 
> -#include "llvm/Support/FileSystem.h"
> -
> // Define these constants from POSIX mman.h rather than include the file
> // so that they will be correct even when compiled on Linux.
> #define MAP_PRIVATE 2
> @@ -543,18 +541,17 @@ struct RecurseCopyBaton {
> };
> 
> static FileSpec::EnumerateDirectoryResult
> -RecurseCopy_Callback(void *baton, llvm::sys::fs::file_type ft,
> +RecurseCopy_Callback(void *baton, FileSpec::FileType file_type,
>                      const FileSpec &src) {
>   RecurseCopyBaton *rc_baton = (RecurseCopyBaton *)baton;
> -  namespace fs = llvm::sys::fs;
> -  switch (ft) {
> -  case fs::file_type::fifo_file:
> -  case fs::file_type::socket_file:
> +  switch (file_type) {
> +  case FileSpec::eFileTypePipe:
> +  case FileSpec::eFileTypeSocket:
>     // we have no way to copy pipes and sockets - ignore them and continue
>     return FileSpec::eEnumerateDirectoryResultNext;
>     break;
> 
> -  case fs::file_type::directory_file: {
> +  case FileSpec::eFileTypeDirectory: {
>     // make the new directory and get in there
>     FileSpec dst_dir = rc_baton->dst;
>     if (!dst_dir.GetFilename())
> @@ -584,7 +581,7 @@ RecurseCopy_Callback(void *baton, llvm::
>     return FileSpec::eEnumerateDirectoryResultNext;
>   } break;
> 
> -  case fs::file_type::symlink_file: {
> +  case FileSpec::eFileTypeSymbolicLink: {
>     // copy the file and keep going
>     FileSpec dst_file = rc_baton->dst;
>     if (!dst_file.GetFilename())
> @@ -606,7 +603,7 @@ RecurseCopy_Callback(void *baton, llvm::
>     return FileSpec::eEnumerateDirectoryResultNext;
>   } break;
> 
> -  case fs::file_type::regular_file: {
> +  case FileSpec::eFileTypeRegular: {
>     // copy the file and keep going
>     FileSpec dst_file = rc_baton->dst;
>     if (!dst_file.GetFilename())
> @@ -619,13 +616,15 @@ RecurseCopy_Callback(void *baton, llvm::
>     return FileSpec::eEnumerateDirectoryResultNext;
>   } break;
> 
> -  default:
> +  case FileSpec::eFileTypeInvalid:
> +  case FileSpec::eFileTypeOther:
> +  case FileSpec::eFileTypeUnknown:
>     rc_baton->error.SetErrorStringWithFormat(
>         "invalid file detected during copy: %s", src.GetPath().c_str());
>     return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out
>     break;
>   }
> -  llvm_unreachable("Unhandled file_type!");
> +  llvm_unreachable("Unhandled FileSpec::FileType!");
> }
> 
> Error Platform::Install(const FileSpec &src, const FileSpec &dst) {
> @@ -693,9 +692,8 @@ Error Platform::Install(const FileSpec &
>   if (GetSupportsRSync()) {
>     error = PutFile(src, dst);
>   } else {
> -    namespace fs = llvm::sys::fs;
> -    switch (fs::get_file_type(src.GetPath())) {
> -    case fs::file_type::directory_file: {
> +    switch (src.GetFileType()) {
> +    case FileSpec::eFileTypeDirectory: {
>       if (GetFileExists(fixed_dst))
>         Unlink(fixed_dst);
>       uint32_t permissions = src.GetPermissions();
> @@ -715,13 +713,13 @@ Error Platform::Install(const FileSpec &
>       }
>     } break;
> 
> -    case fs::file_type::regular_file:
> +    case FileSpec::eFileTypeRegular:
>       if (GetFileExists(fixed_dst))
>         Unlink(fixed_dst);
>       error = PutFile(src, fixed_dst);
>       break;
> 
> -    case fs::file_type::symlink_file: {
> +    case FileSpec::eFileTypeSymbolicLink: {
>       if (GetFileExists(fixed_dst))
>         Unlink(fixed_dst);
>       FileSpec src_resolved;
> @@ -729,13 +727,15 @@ Error Platform::Install(const FileSpec &
>       if (error.Success())
>         error = CreateSymlink(dst, src_resolved);
>     } break;
> -    case fs::file_type::fifo_file:
> +    case FileSpec::eFileTypePipe:
>       error.SetErrorString("platform install doesn't handle pipes");
>       break;
> -    case fs::file_type::socket_file:
> +    case FileSpec::eFileTypeSocket:
>       error.SetErrorString("platform install doesn't handle sockets");
>       break;
> -    default:
> +    case FileSpec::eFileTypeInvalid:
> +    case FileSpec::eFileTypeUnknown:
> +    case FileSpec::eFileTypeOther:
>       error.SetErrorString(
>           "platform install doesn't handle non file or directory items");
>       break;
> @@ -1236,8 +1236,7 @@ Error Platform::PutFile(const FileSpec &
> 
>   uint32_t source_open_options =
>       File::eOpenOptionRead | File::eOpenOptionCloseOnExec;
> -  namespace fs = llvm::sys::fs;
> -  if (fs::get_file_type(source.GetPath()) == fs::file_type::symlink_file)
> +  if (source.GetFileType() == FileSpec::eFileTypeSymbolicLink)
>     source_open_options |= File::eOpenOptionDontFollowSymlinks;
> 
>   File source_file(source, source_open_options, lldb::eFilePermissionsUserRW);
> 
> Modified: lldb/trunk/source/Target/TargetList.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=297139&r1=297138&r2=297139&view=diff
> ==============================================================================
> --- lldb/trunk/source/Target/TargetList.cpp (original)
> +++ lldb/trunk/source/Target/TargetList.cpp Tue Mar  7 07:19:15 2017
> @@ -362,7 +362,7 @@ Error TargetList::CreateTargetInternal(D
>   char resolved_bundle_exe_path[PATH_MAX];
>   resolved_bundle_exe_path[0] = '\0';
>   if (file) {
> -    if (llvm::sys::fs::is_directory(file.GetPath()))
> +    if (file.GetFileType() == FileSpec::eFileTypeDirectory)
>       user_exe_path_is_bundle = true;
> 
>     if (file.IsRelative() && !user_exe_path.empty()) {
> 
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits



More information about the lldb-commits mailing list