diff options
author | Richard Howell <rhow@fb.com> | 2022-01-19 10:12:32 -0800 |
---|---|---|
committer | Ellis Hoag <ellis.sparky.hoag@gmail.com> | 2022-01-19 10:13:06 -0800 |
commit | 4f61749e16f63b0c9ebd9bdd1f8bf4f570a31692 (patch) | |
tree | 164d33e7e105a53d2b797dcf1315aa88d98fce42 /llvm/lib/Support/VirtualFileSystem.cpp | |
parent | 88d81770f1101c8306bd1717755ef4eea0724deb (diff) | |
download | llvm-4f61749e16f63b0c9ebd9bdd1f8bf4f570a31692.zip llvm-4f61749e16f63b0c9ebd9bdd1f8bf4f570a31692.tar.gz llvm-4f61749e16f63b0c9ebd9bdd1f8bf4f570a31692.tar.bz2 |
[clang] support relative roots to vfs overlays
This diff adds support for relative roots to VFS overlays. The directory root
will be made absolute from the current working directory and will be used to
determine the path style to use. This supports the use of VFS overlays with
remote build systems that might use a different working directory for each
compilation.
Reviewed By: benlangmuir
Differential Revision: https://reviews.llvm.org/D116174
Diffstat (limited to 'llvm/lib/Support/VirtualFileSystem.cpp')
-rw-r--r-- | llvm/lib/Support/VirtualFileSystem.cpp | 15 |
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; } } |