[Lldb-commits] [PATCH] D115104: [lldb] Fix guessing of windows path style

Jaroslav Sevcik via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sat Dec 4 12:47:14 PST 2021


jarin created this revision.
jarin added a reviewer: labath.
jarin requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Currently, only paths with length>3 are guessed as Windows paths. This prevents root paths (such as C:\) to be recognized as Windows paths. This patch makes sure we also recognize "<letter>:\" as Windows paths.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115104

Files:
  lldb/source/Utility/FileSpec.cpp
  lldb/unittests/Utility/FileSpecTest.cpp


Index: lldb/unittests/Utility/FileSpecTest.cpp
===================================================================
--- lldb/unittests/Utility/FileSpecTest.cpp
+++ lldb/unittests/Utility/FileSpecTest.cpp
@@ -198,8 +198,10 @@
             FileSpec::GuessPathStyle(R"(C:\foo.txt)"));
   EXPECT_EQ(FileSpec::Style::windows,
             FileSpec::GuessPathStyle(R"(\\net\foo.txt)"));
+  EXPECT_EQ(FileSpec::Style::windows, FileSpec::GuessPathStyle(R"(Z:\)"));
   EXPECT_EQ(llvm::None, FileSpec::GuessPathStyle("foo.txt"));
   EXPECT_EQ(llvm::None, FileSpec::GuessPathStyle("foo/bar.txt"));
+  EXPECT_EQ(llvm::None, FileSpec::GuessPathStyle("Z:"));
 }
 
 TEST(FileSpecTest, GetPath) {
Index: lldb/source/Utility/FileSpec.cpp
===================================================================
--- lldb/source/Utility/FileSpec.cpp
+++ lldb/source/Utility/FileSpec.cpp
@@ -310,7 +310,7 @@
     return Style::posix;
   if (absolute_path.startswith(R"(\\)"))
     return Style::windows;
-  if (absolute_path.size() > 3 && llvm::isAlpha(absolute_path[0]) &&
+  if (absolute_path.size() >= 3 && llvm::isAlpha(absolute_path[0]) &&
       absolute_path.substr(1, 2) == R"(:\)")
     return Style::windows;
   return llvm::None;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115104.391868.patch
Type: text/x-patch
Size: 1215 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20211204/d5d0efb0/attachment.bin>


More information about the lldb-commits mailing list