diff --git a/lldb/source/Utility/FileSpec.cpp b/lldb/source/Utility/FileSpec.cpp --- a/lldb/source/Utility/FileSpec.cpp +++ b/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; diff --git a/lldb/unittests/Utility/FileSpecTest.cpp b/lldb/unittests/Utility/FileSpecTest.cpp --- a/lldb/unittests/Utility/FileSpecTest.cpp +++ b/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) {