Skip to content

Commit 1a37796

Browse files
committed
fix parse windows driver and wsl path
1 parent 1e5c1a3 commit 1a37796

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

clang-tools-extra/clangd/PathMapping.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ llvm::Expected<std::string> parsePath(llvm::StringRef Path) {
150150
if (path::is_absolute(Path, path::Style::posix)) {
151151
return std::string(Path);
152152
}
153-
if (path::is_absolute(Path, path::Style::windows)) {
154-
std::string Converted = path::convert_to_slash(Path, path::Style::windows);
155-
if (Converted.front() != '/')
156-
Converted = "/" + Converted;
157-
return Converted;
153+
llvm::StringRef Root = path::root_name(Path, path::Style::windows);
154+
if (!Root.empty()) {
155+
std::string Converted = "/";
156+
return Converted.append(Root)
157+
.append(path::convert_to_slash(Path.substr(Root.size()), path::Style::windows));
158158
}
159159
return error("Path not absolute: {0}", Path);
160160
}

0 commit comments

Comments
 (0)