[Lldb-commits] [lldb] a2c9cf4 - [lldb] Use is_style_posix() for path style checks

Martin Storsjö via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 5 12:51:12 PDT 2021


Author: Martin Storsjö
Date: 2021-11-05T21:50:45+02:00
New Revision: a2c9cf4c76974086a206c86a172085162a57de9b

URL: https://github.com/llvm/llvm-project/commit/a2c9cf4c76974086a206c86a172085162a57de9b
DIFF: https://github.com/llvm/llvm-project/commit/a2c9cf4c76974086a206c86a172085162a57de9b.diff

LOG: [lldb] Use is_style_posix() for path style checks

Since a8b54834a186f5570b49b614e31b961a9cf1cbfe, there are two
distinct Windows path styles, `windows_backslash` (with the old
`windows` being an alias for it) and `windows_slash`.
4e4883e1f394f7c47ff3adee48039aa8374bb8d0 added helpers for
inspecting path styles.

The newly added windows_slash path style doesn't end up used in
LLDB yet anyway, as LLDB is quite decoupled from most of
llvm::sys::path and uses its own FileSpec class. To take it in
use, it could be hooked up in `FileSpec::Style::GetNativeStyle`
(in lldb/source/Utility/FileSpec.cpp) just like in the `real_style`
function in llvm/lib/Support/Path.cpp in
df0ba47c36f6bd0865e3286853b76d37e037c2d7.

It is not currently clear whether there's a real need for using
the Windows path style with forward slashes in LLDB (if there's any
other applications interacting with it, expecting that style), and
what other changes in LLDB are needed for that to work, but this
at least makes some of the checks more ready for the new style,
simplifying code a bit.

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

Added: 
    

Modified: 
    lldb/include/lldb/Utility/FileSpec.h
    lldb/source/Utility/FileSpec.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Utility/FileSpec.h b/lldb/include/lldb/Utility/FileSpec.h
index 0f4e6505e4337..305cd04f95c01 100644
--- a/lldb/include/lldb/Utility/FileSpec.h
+++ b/lldb/include/lldb/Utility/FileSpec.h
@@ -202,7 +202,7 @@ class FileSpec {
   /// \return
   ///     \b true if the file path is case sensitive (POSIX), false
   ///		if case insensitive (Windows).
-  bool IsCaseSensitive() const { return m_style != Style::windows; }
+  bool IsCaseSensitive() const { return is_style_posix(m_style); }
 
   /// Dump this object to a Stream.
   ///

diff  --git a/lldb/source/Utility/FileSpec.cpp b/lldb/source/Utility/FileSpec.cpp
index bea3c6d6268b3..601edb86c1b0c 100644
--- a/lldb/source/Utility/FileSpec.cpp
+++ b/lldb/source/Utility/FileSpec.cpp
@@ -43,9 +43,7 @@ static constexpr FileSpec::Style GetNativeStyle() {
 }
 
 bool PathStyleIsPosix(FileSpec::Style style) {
-  return (style == FileSpec::Style::posix ||
-          (style == FileSpec::Style::native &&
-           GetNativeStyle() == FileSpec::Style::posix));
+  return llvm::sys::path::is_style_posix(style);
 }
 
 const char *GetPathSeparators(FileSpec::Style style) {


        


More information about the lldb-commits mailing list