[Lldb-commits] [PATCH] D113255: [lldb] Use is_style_posix() for path style checks

Martin Storsjö via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 5 03:04:53 PDT 2021


mstorsjo created this revision.
mstorsjo added reviewers: labath, dexonsmith.
mstorsjo requested review of this revision.
Herald added a project: LLDB.

Since a8b54834a186f5570b49b614e31b961a9cf1cbfe <https://reviews.llvm.org/rGa8b54834a186f5570b49b614e31b961a9cf1cbfe>, there are two
distinct Windows path styles, `windows_backslash` (with the old
`windows` being an alias for it) and `windows_slash`.
4e4883e1f394f7c47ff3adee48039aa8374bb8d0 <https://reviews.llvm.org/rG4e4883e1f394f7c47ff3adee48039aa8374bb8d0> 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 <https://reviews.llvm.org/rGdf0ba47c36f6bd0865e3286853b76d37e037c2d7>.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113255

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


Index: lldb/source/Utility/FileSpec.cpp
===================================================================
--- lldb/source/Utility/FileSpec.cpp
+++ lldb/source/Utility/FileSpec.cpp
@@ -43,9 +43,7 @@
 }
 
 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) {
Index: lldb/include/lldb/Utility/FileSpec.h
===================================================================
--- lldb/include/lldb/Utility/FileSpec.h
+++ lldb/include/lldb/Utility/FileSpec.h
@@ -202,7 +202,7 @@
   /// \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.
   ///


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113255.385005.patch
Type: text/x-patch
Size: 1037 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20211105/c7f7d8e6/attachment-0001.bin>


More information about the lldb-commits mailing list