This is an archive of the discontinued LLVM Phabricator instance.

[VFS] Fix inconsistencies between relative paths and fallthrough in the RedirectingFileSystem
ClosedPublic

Authored by JDevlieghere on Jan 21 2021, 5:18 PM.

Details

Summary

This patch addresses inconsistencies in the way fallthrough is handled in the RedirectingFileSystem. Rather than trying to change the working directory of the external filesystem, the RedirectingFileSystem will canonicalize every path before handing it down. This guarantees that relative paths are resolved relative to the RedirectingFileSystem's working directory. This allows us to have a strictly virtual working directory, and still fallthrough for absolute paths, but not for relative paths that would get resolved incorrectly at the lower layer (for example, in case of the RealFileSystem, because the strictly virtual path does not exist).

Diff Detail

Event Timeline

JDevlieghere created this revision.Jan 21 2021, 5:18 PM
JDevlieghere requested review of this revision.Jan 21 2021, 5:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 21 2021, 5:18 PM
dexonsmith requested changes to this revision.Jan 21 2021, 6:07 PM

This seems like a good simplification.

llvm/lib/Support/VirtualFileSystem.cpp
1085–1088

I think you need to call makeCanonical here.

1748

Typo s/StirngRef/StringRef/

1754

Is there a reason you had to manually inline canonicalize() here? It'd be nice to reuse the logic, since it's not entirely obvious.

This revision now requires changes to proceed.Jan 21 2021, 6:07 PM
JDevlieghere marked 3 inline comments as done.
  • Implement makeCanonical using canonicalize
  • Add missing call to makeCanonical is isLocal
JDevlieghere added inline comments.Jan 21 2021, 7:47 PM
llvm/lib/Support/VirtualFileSystem.cpp
1754

I was trying to avoid the copy into the SmallString, but that didn't work out because you need a buffer to copy from (otherwise you're copying from yourself). We could add an overload to remove_leading_dotslash that performs the operation in-place, but that would be for a separate patch.

This revision is now accepted and ready to land.Jan 22 2021, 1:00 PM