[Lldb-commits] [lldb] r332247 - FileSpec: Remove PathSyntax enum and use llvm version instead

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Mon May 14 07:52:47 PDT 2018


Author: labath
Date: Mon May 14 07:52:47 2018
New Revision: 332247

URL: http://llvm.org/viewvc/llvm-project?rev=332247&view=rev
Log:
FileSpec: Remove PathSyntax enum and use llvm version instead

Summary:
The llvm version of the enum has the same enumerators, with stlightly
different names, so this is mostly just a search&replace exercise. One
concrete benefit of this is that we can remove the function for
converting between the two enums.

To avoid typing llvm::sys::path::Style::windows everywhere I import the
enum into the FileSpec class, so it can be referenced as
FileSpec::Style::windows.

Reviewers: zturner, clayborg

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D46753

Modified:
    lldb/trunk/include/lldb/Utility/FileSpec.h
    lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
    lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
    lldb/trunk/source/Utility/FileSpec.cpp
    lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
    lldb/trunk/unittests/Target/ModuleCacheTest.cpp
    lldb/trunk/unittests/Utility/FileSpecTest.cpp

Modified: lldb/trunk/include/lldb/Utility/FileSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/FileSpec.h?rev=332247&r1=332246&r2=332247&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/FileSpec.h (original)
+++ lldb/trunk/include/lldb/Utility/FileSpec.h Mon May 14 07:52:47 2018
@@ -22,6 +22,7 @@
 #include "llvm/ADT/StringRef.h" // for StringRef
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/Path.h"
 
 #include <stddef.h> // for size_t
 #include <stdint.h> // for uint32_t, uint64_t
@@ -60,11 +61,7 @@ namespace lldb_private {
 //----------------------------------------------------------------------
 class FileSpec {
 public:
-  enum PathSyntax : unsigned char {
-    ePathSyntaxPosix,
-    ePathSyntaxWindows,
-    ePathSyntaxHostNative
-  };
+  using Style = llvm::sys::path::Style;
 
   FileSpec();
 
@@ -86,7 +83,7 @@ public:
   /// @see FileSpec::SetFile (const char *path, bool resolve)
   //------------------------------------------------------------------
   explicit FileSpec(llvm::StringRef path, bool resolve_path,
-                    PathSyntax syntax = ePathSyntaxHostNative);
+                    Style style = Style::native);
 
   explicit FileSpec(llvm::StringRef path, bool resolve_path,
                     const llvm::Triple &Triple);
@@ -261,7 +258,7 @@ public:
   ///     \b true if the file path is case sensitive (POSIX), false
   ///		if case insensitive (Windows).
   //------------------------------------------------------------------
-  bool IsCaseSensitive() const { return m_syntax != ePathSyntaxWindows; }
+  bool IsCaseSensitive() const { return m_style != Style::windows; }
 
   //------------------------------------------------------------------
   /// Dump this object to a Stream.
@@ -316,7 +313,7 @@ public:
 
   uint64_t GetByteSize() const;
 
-  PathSyntax GetPathSyntax() const;
+  Style GetPathStyle() const;
 
   //------------------------------------------------------------------
   /// Directory string get accessor.
@@ -494,7 +491,7 @@ public:
   ///     the static FileSpec::Resolve.
   //------------------------------------------------------------------
   void SetFile(llvm::StringRef path, bool resolve_path,
-               PathSyntax syntax = ePathSyntaxHostNative);
+               Style style = Style::native);
 
   void SetFile(llvm::StringRef path, bool resolve_path,
                const llvm::Triple &Triple);
@@ -567,8 +564,7 @@ protected:
   ConstString m_directory;            ///< The uniqued directory path
   ConstString m_filename;             ///< The uniqued filename path
   mutable bool m_is_resolved = false; ///< True if this path has been resolved.
-  PathSyntax
-      m_syntax; ///< The syntax that this path uses (e.g. Windows / Posix)
+  Style m_style; ///< The syntax that this path uses (e.g. Windows / Posix)
 };
 
 //----------------------------------------------------------------------

Modified: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp?rev=332247&r1=332246&r2=332247&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp Mon May 14 07:52:47 2018
@@ -193,8 +193,7 @@ Status PlatformAndroid::GetFile(const Fi
   if (IsHost() || !m_remote_platform_sp)
     return PlatformLinux::GetFile(source, destination);
 
-  FileSpec source_spec(source.GetPath(false), false,
-                       FileSpec::ePathSyntaxPosix);
+  FileSpec source_spec(source.GetPath(false), false, FileSpec::Style::posix);
   if (source_spec.IsRelative())
     source_spec = GetRemoteWorkingDirectory().CopyByAppendingPathComponent(
         source_spec.GetCString(false));
@@ -239,7 +238,7 @@ Status PlatformAndroid::PutFile(const Fi
     return PlatformLinux::PutFile(source, destination, uid, gid);
 
   FileSpec destination_spec(destination.GetPath(false), false,
-                            FileSpec::ePathSyntaxPosix);
+                            FileSpec::Style::posix);
   if (destination_spec.IsRelative())
     destination_spec = GetRemoteWorkingDirectory().CopyByAppendingPathComponent(
         destination_spec.GetCString(false));

Modified: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp?rev=332247&r1=332246&r2=332247&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp Mon May 14 07:52:47 2018
@@ -343,7 +343,7 @@ bool SymbolFilePDB::ParseCompileUnitSupp
     return false;
 
   while (auto file = files->getNext()) {
-    FileSpec spec(file->getFileName(), false, FileSpec::ePathSyntaxWindows);
+    FileSpec spec(file->getFileName(), false, FileSpec::Style::windows);
     support_files.AppendIfUnique(spec);
   }
   return true;
@@ -630,7 +630,7 @@ uint32_t SymbolFilePDB::ResolveSymbolCon
         std::string source_file = compiland->getSourceFileFullPath();
         if (source_file.empty())
           continue;
-        FileSpec this_spec(source_file, false, FileSpec::ePathSyntaxWindows);
+        FileSpec this_spec(source_file, false, FileSpec::Style::windows);
         bool need_full_match = !file_spec.GetDirectory().IsEmpty();
         if (FileSpec::Compare(file_spec, this_spec, need_full_match) != 0)
           continue;

Modified: lldb/trunk/source/Utility/FileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/FileSpec.cpp?rev=332247&r1=332246&r2=332247&view=diff
==============================================================================
--- lldb/trunk/source/Utility/FileSpec.cpp (original)
+++ lldb/trunk/source/Utility/FileSpec.cpp Mon May 14 07:52:47 2018
@@ -19,7 +19,6 @@
 #include "llvm/ADT/Twine.h"          // for Twine
 #include "llvm/Support/ErrorOr.h"    // for ErrorOr
 #include "llvm/Support/FileSystem.h"
-#include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/raw_ostream.h" // for raw_ostream, fs
 
@@ -36,48 +35,34 @@ using namespace lldb_private;
 
 namespace {
 
-static constexpr FileSpec::PathSyntax GetNativeSyntax() {
+static constexpr FileSpec::Style GetNativeStyle() {
 #if defined(_WIN32)
-  return FileSpec::ePathSyntaxWindows;
+  return FileSpec::Style::windows;
 #else
-  return FileSpec::ePathSyntaxPosix;
+  return FileSpec::Style::posix;
 #endif
 }
 
-bool PathSyntaxIsPosix(FileSpec::PathSyntax syntax) {
-  return (syntax == FileSpec::ePathSyntaxPosix ||
-          (syntax == FileSpec::ePathSyntaxHostNative &&
-           GetNativeSyntax() == FileSpec::ePathSyntaxPosix));
+bool PathStyleIsPosix(FileSpec::Style style) {
+  return (style == FileSpec::Style::posix ||
+          (style == FileSpec::Style::native &&
+           GetNativeStyle() == FileSpec::Style::posix));
 }
 
-const char *GetPathSeparators(FileSpec::PathSyntax syntax) {
-  return PathSyntaxIsPosix(syntax) ? "/" : "\\/";
+const char *GetPathSeparators(FileSpec::Style style) {
+  return PathStyleIsPosix(style) ? "/" : "\\/";
 }
 
-char GetPreferredPathSeparator(FileSpec::PathSyntax syntax) {
-  return GetPathSeparators(syntax)[0];
+char GetPreferredPathSeparator(FileSpec::Style style) {
+  return GetPathSeparators(style)[0];
 }
 
-bool IsPathSeparator(char value, FileSpec::PathSyntax syntax) {
-  return value == '/' || (!PathSyntaxIsPosix(syntax) && value == '\\');
+bool IsPathSeparator(char value, FileSpec::Style style) {
+  return value == '/' || (!PathStyleIsPosix(style) && value == '\\');
 }
 
-inline llvm::sys::path::Style
-LLVMPathSyntax(FileSpec::PathSyntax lldb_syntax) {
-  switch (lldb_syntax) {
-    case FileSpec::ePathSyntaxPosix:
-      return llvm::sys::path::Style::posix;
-    case FileSpec::ePathSyntaxWindows:
-      return llvm::sys::path::Style::windows;
-    case FileSpec::ePathSyntaxHostNative:
-      return llvm::sys::path::Style::native;
-  };
-  return llvm::sys::path::Style::native;
-}
-
-void Denormalize(llvm::SmallVectorImpl<char> &path,
-                 FileSpec::PathSyntax syntax) {
-  if (PathSyntaxIsPosix(syntax))
+void Denormalize(llvm::SmallVectorImpl<char> &path, FileSpec::Style style) {
+  if (PathStyleIsPosix(style))
     return;
 
   std::replace(path.begin(), path.end(), '/', '\\');
@@ -102,27 +87,27 @@ void FileSpec::Resolve(llvm::SmallVector
   }
 }
 
-FileSpec::FileSpec() : m_syntax(GetNativeSyntax()) {}
+FileSpec::FileSpec() : m_style(GetNativeStyle()) {}
 
 //------------------------------------------------------------------
 // Default constructor that can take an optional full path to a file on disk.
 //------------------------------------------------------------------
-FileSpec::FileSpec(llvm::StringRef path, bool resolve_path, PathSyntax syntax)
-    : m_syntax(syntax) {
-  SetFile(path, resolve_path, syntax);
+FileSpec::FileSpec(llvm::StringRef path, bool resolve_path, Style style)
+    : m_style(style) {
+  SetFile(path, resolve_path, style);
 }
 
 FileSpec::FileSpec(llvm::StringRef path, bool resolve_path,
                    const llvm::Triple &Triple)
     : FileSpec{path, resolve_path,
-               Triple.isOSWindows() ? ePathSyntaxWindows : ePathSyntaxPosix} {}
+               Triple.isOSWindows() ? Style::windows : Style::posix} {}
 
 //------------------------------------------------------------------
 // Copy constructor
 //------------------------------------------------------------------
 FileSpec::FileSpec(const FileSpec &rhs)
     : m_directory(rhs.m_directory), m_filename(rhs.m_filename),
-      m_is_resolved(rhs.m_is_resolved), m_syntax(rhs.m_syntax) {}
+      m_is_resolved(rhs.m_is_resolved), m_style(rhs.m_style) {}
 
 //------------------------------------------------------------------
 // Copy constructor
@@ -239,7 +224,7 @@ const FileSpec &FileSpec::operator=(cons
     m_directory = rhs.m_directory;
     m_filename = rhs.m_filename;
     m_is_resolved = rhs.m_is_resolved;
-    m_syntax = rhs.m_syntax;
+    m_style = rhs.m_style;
   }
   return *this;
 }
@@ -249,12 +234,11 @@ const FileSpec &FileSpec::operator=(cons
 // up into a directory and filename and stored as uniqued string values for
 // quick comparison and efficient memory usage.
 //------------------------------------------------------------------
-void FileSpec::SetFile(llvm::StringRef pathname, bool resolve,
-                       PathSyntax syntax) {
+void FileSpec::SetFile(llvm::StringRef pathname, bool resolve, Style style) {
   m_filename.Clear();
   m_directory.Clear();
   m_is_resolved = false;
-  m_syntax = (syntax == ePathSyntaxHostNative) ? GetNativeSyntax() : syntax;
+  m_style = (style == Style::native) ? GetNativeStyle() : style;
 
   if (pathname.empty())
     return;
@@ -268,15 +252,14 @@ void FileSpec::SetFile(llvm::StringRef p
 
   // Normalize the path by removing ".", ".." and other redundant components.
   if (needsNormalization(resolved))
-    llvm::sys::path::remove_dots(resolved, true, LLVMPathSyntax(m_syntax));
+    llvm::sys::path::remove_dots(resolved, true, m_style);
 
   // Normalize back slashes to forward slashes
-  if (m_syntax == FileSpec::ePathSyntaxWindows)
+  if (m_style == Style::windows)
     std::replace(resolved.begin(), resolved.end(), '\\', '/');
 
-  auto style = LLVMPathSyntax(syntax);
-  m_filename.SetString(llvm::sys::path::filename(resolved, style));
-  llvm::StringRef dir = llvm::sys::path::parent_path(resolved, style);
+  m_filename.SetString(llvm::sys::path::filename(resolved, m_style));
+  llvm::StringRef dir = llvm::sys::path::parent_path(resolved, m_style);
   if (!dir.empty())
     m_directory.SetString(dir);
 }
@@ -284,7 +267,7 @@ void FileSpec::SetFile(llvm::StringRef p
 void FileSpec::SetFile(llvm::StringRef path, bool resolve,
                        const llvm::Triple &Triple) {
   return SetFile(path, resolve,
-                 Triple.isOSWindows() ? ePathSyntaxWindows : ePathSyntaxPosix);
+                 Triple.isOSWindows() ? Style::windows : Style::posix);
 }
 
 //----------------------------------------------------------------------
@@ -451,7 +434,7 @@ void FileSpec::Dump(Stream *s) const {
   if (s) {
     std::string path{GetPath(true)};
     s->PutCString(path);
-    char path_separator = GetPreferredPathSeparator(m_syntax);
+    char path_separator = GetPreferredPathSeparator(m_style);
     if (!m_filename && !path.empty() && path.back() != path_separator)
       s->PutChar(path_separator);
   }
@@ -518,7 +501,7 @@ uint64_t FileSpec::GetByteSize() const {
   return Size;
 }
 
-FileSpec::PathSyntax FileSpec::GetPathSyntax() const { return m_syntax; }
+FileSpec::Style FileSpec::GetPathStyle() const { return m_style; }
 
 uint32_t FileSpec::GetPermissions() const {
   namespace fs = llvm::sys::fs;
@@ -586,7 +569,7 @@ void FileSpec::GetPath(llvm::SmallVector
   path.append(m_filename.GetStringRef().begin(),
               m_filename.GetStringRef().end());
   if (denormalize && !path.empty())
-    Denormalize(path, m_syntax);
+    Denormalize(path, m_style);
 }
 
 ConstString FileSpec::GetFileNameExtension() const {
@@ -716,7 +699,7 @@ ConstString FileSpec::GetLastPathCompone
 }
 
 static std::string
-join_path_components(FileSpec::PathSyntax syntax,
+join_path_components(FileSpec::Style style,
                      const std::vector<llvm::StringRef> components) {
   std::string result;
   for (size_t i = 0; i < components.size(); ++i) {
@@ -724,8 +707,8 @@ join_path_components(FileSpec::PathSynta
       continue;
     result += components[i];
     if (i != components.size() - 1 &&
-        !IsPathSeparator(components[i].back(), syntax))
-      result += GetPreferredPathSeparator(syntax);
+        !IsPathSeparator(components[i].back(), style))
+      result += GetPreferredPathSeparator(style);
   }
 
   return result;
@@ -742,9 +725,9 @@ void FileSpec::PrependPathComponent(llvm
   }
 
   std::string result =
-      join_path_components(m_syntax, {component, m_directory.GetStringRef(),
-                                      m_filename.GetStringRef()});
-  SetFile(result, resolve, m_syntax);
+      join_path_components(m_style, {component, m_directory.GetStringRef(),
+                                     m_filename.GetStringRef()});
+  SetFile(result, resolve, m_style);
 }
 
 void FileSpec::PrependPathComponent(const FileSpec &new_path) {
@@ -756,13 +739,13 @@ void FileSpec::AppendPathComponent(llvm:
     return;
 
   component = component.drop_while(
-      [this](char c) { return IsPathSeparator(c, m_syntax); });
+      [this](char c) { return IsPathSeparator(c, m_style); });
 
   std::string result =
-      join_path_components(m_syntax, {m_directory.GetStringRef(),
-                                      m_filename.GetStringRef(), component});
+      join_path_components(m_style, {m_directory.GetStringRef(),
+                                     m_filename.GetStringRef(), component});
 
-  SetFile(result, false, m_syntax);
+  SetFile(result, false, m_style);
 }
 
 void FileSpec::AppendPathComponent(const FileSpec &new_path) {
@@ -827,7 +810,7 @@ bool FileSpec::IsRelative() const {
   llvm::StringRef directory(dir ? dir : "");
 
   if (directory.size() > 0) {
-    if (PathSyntaxIsPosix(m_syntax)) {
+    if (PathStyleIsPosix(m_style)) {
       // If the path doesn't start with '/' or '~', return true
       switch (directory[0]) {
       case '/':
@@ -878,9 +861,9 @@ void llvm::format_provider<FileSpec>::fo
     // preferred form.  In order to handle this, we need to cut off the
     // filename, then denormalize, then write the entire denorm'ed directory.
     llvm::SmallString<64> denormalized_dir = dir;
-    Denormalize(denormalized_dir, F.GetPathSyntax());
+    Denormalize(denormalized_dir, F.GetPathStyle());
     Stream << denormalized_dir;
-    Stream << GetPreferredPathSeparator(F.GetPathSyntax());
+    Stream << GetPreferredPathSeparator(F.GetPathStyle());
   }
 
   if (Style.equals_lower("D")) {

Modified: lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp?rev=332247&r1=332246&r2=332247&view=diff
==============================================================================
--- lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp (original)
+++ lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp Mon May 14 07:52:47 2018
@@ -169,14 +169,14 @@ TEST_F(GDBRemoteCommunicationClientTest,
   llvm::Triple triple("i386-pc-linux");
 
   FileSpec file_specs[] = {
-      FileSpec("/foo/bar.so", false, FileSpec::ePathSyntaxPosix),
-      FileSpec("/foo/baz.so", false, FileSpec::ePathSyntaxPosix),
+      FileSpec("/foo/bar.so", false, FileSpec::Style::posix),
+      FileSpec("/foo/baz.so", false, FileSpec::Style::posix),
 
       // This is a bit dodgy but we currently depend on GetModulesInfo not
       // performing denormalization. It can go away once the users
       // (DynamicLoaderPOSIXDYLD, at least) correctly set the path syntax for
       // the FileSpecs they create.
-      FileSpec("/foo/baw.so", false, FileSpec::ePathSyntaxWindows),
+      FileSpec("/foo/baw.so", false, FileSpec::Style::windows),
   };
   std::future<llvm::Optional<std::vector<ModuleSpec>>> async_result =
       std::async(std::launch::async,
@@ -202,7 +202,7 @@ TEST_F(GDBRemoteCommunicationClientTest,
 TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfo_UUID20) {
   llvm::Triple triple("i386-pc-linux");
 
-  FileSpec file_spec("/foo/bar.so", false, FileSpec::ePathSyntaxPosix);
+  FileSpec file_spec("/foo/bar.so", false, FileSpec::Style::posix);
   std::future<llvm::Optional<std::vector<ModuleSpec>>> async_result =
       std::async(std::launch::async,
                  [&] { return client.GetModulesInfo(file_spec, triple); });
@@ -225,7 +225,7 @@ TEST_F(GDBRemoteCommunicationClientTest,
 
 TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfoInvalidResponse) {
   llvm::Triple triple("i386-pc-linux");
-  FileSpec file_spec("/foo/bar.so", false, FileSpec::ePathSyntaxPosix);
+  FileSpec file_spec("/foo/bar.so", false, FileSpec::Style::posix);
 
   const char *invalid_responses[] = {
       // no UUID

Modified: lldb/trunk/unittests/Target/ModuleCacheTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Target/ModuleCacheTest.cpp?rev=332247&r1=332246&r2=332247&view=diff
==============================================================================
--- lldb/trunk/unittests/Target/ModuleCacheTest.cpp (original)
+++ lldb/trunk/unittests/Target/ModuleCacheTest.cpp Mon May 14 07:52:47 2018
@@ -44,7 +44,7 @@ static const uint32_t uuid_bytes = 20;
 static const size_t module_size = 5602;
 
 static FileSpec GetDummyRemotePath() {
-  FileSpec fs("/", false, FileSpec::ePathSyntaxPosix);
+  FileSpec fs("/", false, FileSpec::Style::posix);
   fs.AppendPathComponent(dummy_remote_dir);
   fs.AppendPathComponent(module_name);
   return fs;

Modified: lldb/trunk/unittests/Utility/FileSpecTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/FileSpecTest.cpp?rev=332247&r1=332246&r2=332247&view=diff
==============================================================================
--- lldb/trunk/unittests/Utility/FileSpecTest.cpp (original)
+++ lldb/trunk/unittests/Utility/FileSpecTest.cpp Mon May 14 07:52:47 2018
@@ -14,83 +14,82 @@
 using namespace lldb_private;
 
 TEST(FileSpecTest, FileAndDirectoryComponents) {
-  FileSpec fs_posix("/foo/bar", false, FileSpec::ePathSyntaxPosix);
+  FileSpec fs_posix("/foo/bar", false, FileSpec::Style::posix);
   EXPECT_STREQ("/foo/bar", fs_posix.GetCString());
   EXPECT_STREQ("/foo", fs_posix.GetDirectory().GetCString());
   EXPECT_STREQ("bar", fs_posix.GetFilename().GetCString());
 
-  FileSpec fs_windows("F:\\bar", false, FileSpec::ePathSyntaxWindows);
+  FileSpec fs_windows("F:\\bar", false, FileSpec::Style::windows);
   EXPECT_STREQ("F:\\bar", fs_windows.GetCString());
   // EXPECT_STREQ("F:\\", fs_windows.GetDirectory().GetCString()); // It returns
   // "F:/"
   EXPECT_STREQ("bar", fs_windows.GetFilename().GetCString());
 
-  FileSpec fs_posix_root("/", false, FileSpec::ePathSyntaxPosix);
+  FileSpec fs_posix_root("/", false, FileSpec::Style::posix);
   EXPECT_STREQ("/", fs_posix_root.GetCString());
   EXPECT_EQ(nullptr, fs_posix_root.GetDirectory().GetCString());
   EXPECT_STREQ("/", fs_posix_root.GetFilename().GetCString());
 
-  FileSpec fs_windows_drive("F:", false, FileSpec::ePathSyntaxWindows);
+  FileSpec fs_windows_drive("F:", false, FileSpec::Style::windows);
   EXPECT_STREQ("F:", fs_windows_drive.GetCString());
   EXPECT_EQ(nullptr, fs_windows_drive.GetDirectory().GetCString());
   EXPECT_STREQ("F:", fs_windows_drive.GetFilename().GetCString());
 
-  FileSpec fs_windows_root("F:\\", false, FileSpec::ePathSyntaxWindows);
+  FileSpec fs_windows_root("F:\\", false, FileSpec::Style::windows);
   EXPECT_STREQ("F:\\", fs_windows_root.GetCString());
   EXPECT_STREQ("F:", fs_windows_root.GetDirectory().GetCString());
   // EXPECT_STREQ("\\", fs_windows_root.GetFilename().GetCString()); // It
   // returns "/"
 
-  FileSpec fs_posix_long("/foo/bar/baz", false, FileSpec::ePathSyntaxPosix);
+  FileSpec fs_posix_long("/foo/bar/baz", false, FileSpec::Style::posix);
   EXPECT_STREQ("/foo/bar/baz", fs_posix_long.GetCString());
   EXPECT_STREQ("/foo/bar", fs_posix_long.GetDirectory().GetCString());
   EXPECT_STREQ("baz", fs_posix_long.GetFilename().GetCString());
 
-  FileSpec fs_windows_long("F:\\bar\\baz", false, FileSpec::ePathSyntaxWindows);
+  FileSpec fs_windows_long("F:\\bar\\baz", false, FileSpec::Style::windows);
   EXPECT_STREQ("F:\\bar\\baz", fs_windows_long.GetCString());
   // EXPECT_STREQ("F:\\bar", fs_windows_long.GetDirectory().GetCString()); // It
   // returns "F:/bar"
   EXPECT_STREQ("baz", fs_windows_long.GetFilename().GetCString());
 
-  FileSpec fs_posix_trailing_slash("/foo/bar/", false,
-                                   FileSpec::ePathSyntaxPosix);
+  FileSpec fs_posix_trailing_slash("/foo/bar/", false, FileSpec::Style::posix);
   EXPECT_STREQ("/foo/bar", fs_posix_trailing_slash.GetCString());
   EXPECT_STREQ("/foo", fs_posix_trailing_slash.GetDirectory().GetCString());
   EXPECT_STREQ("bar", fs_posix_trailing_slash.GetFilename().GetCString());
 
   FileSpec fs_windows_trailing_slash("F:\\bar\\", false,
-                                     FileSpec::ePathSyntaxWindows);
+                                     FileSpec::Style::windows);
   EXPECT_STREQ("F:\\bar", fs_windows_trailing_slash.GetCString());
   EXPECT_STREQ("bar", fs_windows_trailing_slash.GetFilename().GetCString());
 }
 
 TEST(FileSpecTest, AppendPathComponent) {
-  FileSpec fs_posix("/foo", false, FileSpec::ePathSyntaxPosix);
+  FileSpec fs_posix("/foo", false, FileSpec::Style::posix);
   fs_posix.AppendPathComponent("bar");
   EXPECT_STREQ("/foo/bar", fs_posix.GetCString());
   EXPECT_STREQ("/foo", fs_posix.GetDirectory().GetCString());
   EXPECT_STREQ("bar", fs_posix.GetFilename().GetCString());
 
-  FileSpec fs_posix_2("/foo", false, FileSpec::ePathSyntaxPosix);
+  FileSpec fs_posix_2("/foo", false, FileSpec::Style::posix);
   fs_posix_2.AppendPathComponent("//bar/baz");
   EXPECT_STREQ("/foo/bar/baz", fs_posix_2.GetCString());
   EXPECT_STREQ("/foo/bar", fs_posix_2.GetDirectory().GetCString());
   EXPECT_STREQ("baz", fs_posix_2.GetFilename().GetCString());
 
-  FileSpec fs_windows("F:\\bar", false, FileSpec::ePathSyntaxWindows);
+  FileSpec fs_windows("F:\\bar", false, FileSpec::Style::windows);
   fs_windows.AppendPathComponent("baz");
   EXPECT_STREQ("F:\\bar\\baz", fs_windows.GetCString());
   // EXPECT_STREQ("F:\\bar", fs_windows.GetDirectory().GetCString()); // It
   // returns "F:/bar"
   EXPECT_STREQ("baz", fs_windows.GetFilename().GetCString());
 
-  FileSpec fs_posix_root("/", false, FileSpec::ePathSyntaxPosix);
+  FileSpec fs_posix_root("/", false, FileSpec::Style::posix);
   fs_posix_root.AppendPathComponent("bar");
   EXPECT_STREQ("/bar", fs_posix_root.GetCString());
   EXPECT_STREQ("/", fs_posix_root.GetDirectory().GetCString());
   EXPECT_STREQ("bar", fs_posix_root.GetFilename().GetCString());
 
-  FileSpec fs_windows_root("F:\\", false, FileSpec::ePathSyntaxWindows);
+  FileSpec fs_windows_root("F:\\", false, FileSpec::Style::windows);
   fs_windows_root.AppendPathComponent("bar");
   EXPECT_STREQ("F:\\bar", fs_windows_root.GetCString());
   // EXPECT_STREQ("F:\\", fs_windows_root.GetDirectory().GetCString()); // It
@@ -99,7 +98,7 @@ TEST(FileSpecTest, AppendPathComponent)
 }
 
 TEST(FileSpecTest, CopyByAppendingPathComponent) {
-  FileSpec fs = FileSpec("/foo", false, FileSpec::ePathSyntaxPosix)
+  FileSpec fs = FileSpec("/foo", false, FileSpec::Style::posix)
                     .CopyByAppendingPathComponent("bar");
   EXPECT_STREQ("/foo/bar", fs.GetCString());
   EXPECT_STREQ("/foo", fs.GetDirectory().GetCString());
@@ -107,30 +106,30 @@ TEST(FileSpecTest, CopyByAppendingPathCo
 }
 
 TEST(FileSpecTest, PrependPathComponent) {
-  FileSpec fs_posix("foo", false, FileSpec::ePathSyntaxPosix);
+  FileSpec fs_posix("foo", false, FileSpec::Style::posix);
   fs_posix.PrependPathComponent("/bar");
   EXPECT_STREQ("/bar/foo", fs_posix.GetCString());
 
-  FileSpec fs_posix_2("foo/bar", false, FileSpec::ePathSyntaxPosix);
+  FileSpec fs_posix_2("foo/bar", false, FileSpec::Style::posix);
   fs_posix_2.PrependPathComponent("/baz");
   EXPECT_STREQ("/baz/foo/bar", fs_posix_2.GetCString());
 
-  FileSpec fs_windows("baz", false, FileSpec::ePathSyntaxWindows);
+  FileSpec fs_windows("baz", false, FileSpec::Style::windows);
   fs_windows.PrependPathComponent("F:\\bar");
   EXPECT_STREQ("F:\\bar\\baz", fs_windows.GetCString());
 
-  FileSpec fs_posix_root("bar", false, FileSpec::ePathSyntaxPosix);
+  FileSpec fs_posix_root("bar", false, FileSpec::Style::posix);
   fs_posix_root.PrependPathComponent("/");
   EXPECT_STREQ("/bar", fs_posix_root.GetCString());
 
-  FileSpec fs_windows_root("bar", false, FileSpec::ePathSyntaxWindows);
+  FileSpec fs_windows_root("bar", false, FileSpec::Style::windows);
   fs_windows_root.PrependPathComponent("F:\\");
   EXPECT_STREQ("F:\\bar", fs_windows_root.GetCString());
 }
 
 TEST(FileSpecTest, EqualSeparator) {
-  FileSpec backward("C:\\foo\\bar", false, FileSpec::ePathSyntaxWindows);
-  FileSpec forward("C:/foo/bar", false, FileSpec::ePathSyntaxWindows);
+  FileSpec backward("C:\\foo\\bar", false, FileSpec::Style::windows);
+  FileSpec forward("C:/foo/bar", false, FileSpec::Style::windows);
   EXPECT_EQ(forward, backward);
 }
 
@@ -146,8 +145,8 @@ TEST(FileSpecTest, EqualDotsWindows) {
   };
 
   for (const auto &test : tests) {
-    FileSpec one(test.first, false, FileSpec::ePathSyntaxWindows);
-    FileSpec two(test.second, false, FileSpec::ePathSyntaxWindows);
+    FileSpec one(test.first, false, FileSpec::Style::windows);
+    FileSpec two(test.second, false, FileSpec::Style::windows);
     EXPECT_EQ(one, two);
   }
 }
@@ -162,8 +161,8 @@ TEST(FileSpecTest, EqualDotsPosix) {
   };
 
   for (const auto &test : tests) {
-    FileSpec one(test.first, false, FileSpec::ePathSyntaxPosix);
-    FileSpec two(test.second, false, FileSpec::ePathSyntaxPosix);
+    FileSpec one(test.first, false, FileSpec::Style::posix);
+    FileSpec two(test.second, false, FileSpec::Style::posix);
     EXPECT_EQ(one, two);
   }
 }
@@ -176,8 +175,8 @@ TEST(FileSpecTest, EqualDotsPosixRoot) {
   };
 
   for (const auto &test : tests) {
-    FileSpec one(test.first, false, FileSpec::ePathSyntaxPosix);
-    FileSpec two(test.second, false, FileSpec::ePathSyntaxPosix);
+    FileSpec one(test.first, false, FileSpec::Style::posix);
+    FileSpec two(test.second, false, FileSpec::Style::posix);
     EXPECT_EQ(one, two);
   }
 }
@@ -213,8 +212,7 @@ TEST(FileSpecTest, GetNormalizedPath) {
   for (auto test : posix_tests) {
     SCOPED_TRACE(llvm::Twine("test.first = ") + test.first);
     EXPECT_EQ(test.second,
-              FileSpec(test.first, false, FileSpec::ePathSyntaxPosix)
-                  .GetPath());
+              FileSpec(test.first, false, FileSpec::Style::posix).GetPath());
   }
 
   std::pair<const char *, const char *> windows_tests[] = {
@@ -246,14 +244,13 @@ TEST(FileSpecTest, GetNormalizedPath) {
   };
   for (auto test : windows_tests) {
     EXPECT_EQ(test.second,
-              FileSpec(test.first, false, FileSpec::ePathSyntaxWindows)
-                  .GetPath())
+              FileSpec(test.first, false, FileSpec::Style::windows).GetPath())
         << "Original path: " << test.first;
   }
 }
 
 TEST(FileSpecTest, FormatFileSpec) {
-  auto win = FileSpec::ePathSyntaxWindows;
+  auto win = FileSpec::Style::windows;
 
   FileSpec F;
   EXPECT_EQ("(empty)", llvm::formatv("{0}", F).str());




More information about the lldb-commits mailing list