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;
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;
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits