aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/VirtualFileSystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support/VirtualFileSystem.cpp')
-rw-r--r--llvm/lib/Support/VirtualFileSystem.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp
index bec4e8d..7b752b5 100644
--- a/llvm/lib/Support/VirtualFileSystem.cpp
+++ b/llvm/lib/Support/VirtualFileSystem.cpp
@@ -1649,10 +1649,19 @@ private:
sys::path::Style::windows_backslash)) {
path_style = sys::path::Style::windows_backslash;
} else {
- assert(NameValueNode && "Name presence should be checked earlier");
- error(NameValueNode,
+ // Relative VFS root entries are made absolute to the current working
+ // directory, then we can determine the path style from that.
+ auto EC = sys::fs::make_absolute(Name);
+ if (EC) {
+ assert(NameValueNode && "Name presence should be checked earlier");
+ error(
+ NameValueNode,
"entry with relative path at the root level is not discoverable");
- return nullptr;
+ return nullptr;
+ }
+ path_style = sys::path::is_absolute(Name, sys::path::Style::posix)
+ ? sys::path::Style::posix
+ : sys::path::Style::windows_backslash;
}
}