Skip to content

Commit f72ae5c

Browse files
author
Jaroslav Sevcik
committed
[lldb] Fix windows path guessing for root paths
Fix recognizing "<letter>:\" as a windows path. Differential Revision: https://reviews.llvm.org/D115104
1 parent 63eb7ff commit f72ae5c

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lldb/source/Utility/FileSpec.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ llvm::Optional<FileSpec::Style> FileSpec::GuessPathStyle(llvm::StringRef absolut
310310
return Style::posix;
311311
if (absolute_path.startswith(R"(\\)"))
312312
return Style::windows;
313-
if (absolute_path.size() > 3 && llvm::isAlpha(absolute_path[0]) &&
313+
if (absolute_path.size() >= 3 && llvm::isAlpha(absolute_path[0]) &&
314314
absolute_path.substr(1, 2) == R"(:\)")
315315
return Style::windows;
316316
return llvm::None;

lldb/unittests/Utility/FileSpecTest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,10 @@ TEST(FileSpecTest, GuessPathStyle) {
198198
FileSpec::GuessPathStyle(R"(C:\foo.txt)"));
199199
EXPECT_EQ(FileSpec::Style::windows,
200200
FileSpec::GuessPathStyle(R"(\\net\foo.txt)"));
201+
EXPECT_EQ(FileSpec::Style::windows, FileSpec::GuessPathStyle(R"(Z:\)"));
201202
EXPECT_EQ(llvm::None, FileSpec::GuessPathStyle("foo.txt"));
202203
EXPECT_EQ(llvm::None, FileSpec::GuessPathStyle("foo/bar.txt"));
204+
EXPECT_EQ(llvm::None, FileSpec::GuessPathStyle("Z:"));
203205
}
204206

205207
TEST(FileSpecTest, GetPath) {

0 commit comments

Comments
 (0)