[Lldb-commits] [PATCH] D122389: [lldb] Fix interpreting absolute Windows paths with forward slashes
Martin Storsjö via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Mar 24 05:41:26 PDT 2022
mstorsjo created this revision.
mstorsjo added a reviewer: labath.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: LLDB.
In practice, Windows paths can use either backslashes or forward slashes.
This fixes an issue reported downstream at
https://github.com/mstorsjo/llvm-mingw/issues/266.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D122389
Files:
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
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
@@ -196,9 +196,12 @@
EXPECT_EQ(FileSpec::Style::posix, FileSpec::GuessPathStyle("//net/bar.txt"));
EXPECT_EQ(FileSpec::Style::windows,
FileSpec::GuessPathStyle(R"(C:\foo.txt)"));
+ EXPECT_EQ(FileSpec::Style::windows,
+ 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(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:"));
Index: lldb/source/Utility/FileSpec.cpp
===================================================================
--- lldb/source/Utility/FileSpec.cpp
+++ lldb/source/Utility/FileSpec.cpp
@@ -311,7 +311,8 @@
if (absolute_path.startswith(R"(\\)"))
return Style::windows;
if (absolute_path.size() >= 3 && llvm::isAlpha(absolute_path[0]) &&
- absolute_path.substr(1, 2) == R"(:\)")
+ (absolute_path.substr(1, 2) == R"(:\)" ||
+ absolute_path.substr(1, 2) == R"(:/)"))
return Style::windows;
return llvm::None;
}
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -772,7 +772,8 @@
// check whether we have a windows path, and so the first character is a
// drive-letter not a hostname.
- if (host.size() == 1 && llvm::isAlpha(host[0]) && path.startswith("\\"))
+ if (host.size() == 1 && llvm::isAlpha(host[0]) &&
+ (path.startswith("\\") || path.startswith("/")))
return path_from_dwarf;
return path;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122389.417895.patch
Type: text/x-patch
Size: 2076 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220324/92201e55/attachment.bin>
More information about the lldb-commits
mailing list