This is an archive of the discontinued LLVM Phabricator instance.

[VFS] Add an in-memory file system implementation.
ClosedPublic

Authored by bkramer on Oct 5 2015, 3:17 AM.

Details

Summary

This is a simple file system tree of memory buffers that can be filled by a
client. In conjunction with an OverlayFS it can be used to make virtual
files accessible right next to physical files. This can be used as a
replacement for the virtual file handling in FileManager and which I intend
to remove eventually.

[VFS] Add working directories to every virtual file system.

For RealFileSystem this is getcwd()/chdir(), the synthetic file systems can
make up one for themselves. OverlayFileSystem now synchronizes the working
directories when a new FS is added to the overlay or the overlay working
directory is set. This allows purely artificial file systems that have zero
ties to the underlying disks.

Diff Detail

Repository
rL LLVM

Event Timeline

bkramer updated this revision to Diff 36495.Oct 5 2015, 3:17 AM
bkramer retitled this revision from to [VFS] Add an in-memory file system implementation..
bkramer updated this object.
bkramer added a reviewer: klimek.
bkramer added a subscriber: cfe-commits.
klimek added inline comments.Oct 5 2015, 4:24 AM
include/clang/Basic/VirtualFileSystem.h
286–288 ↗(On Diff #36495)

Return errc::success?

lib/Basic/VirtualFileSystem.cpp
80 ↗(On Diff #36495)

What's the proposed fix? :)

312–316 ↗(On Diff #36495)

If I read this correctly, it gets and sets the pwd from FS for the first one? That seems superfluous.
(perhaps change the constructor to not use pushOverlay)

437 ↗(On Diff #36495)

Do we want to make this const?

439 ↗(On Diff #36495)

This probably wants to be const.

461 ↗(On Diff #36495)

I think parent is a misleading name here (parent implies a hierarchy, but this is a simple adapter). Perhaps "Node".

476 ↗(On Diff #36495)

Is this used in the File interface? It seems - strange... is this really a "mv" implementation?

546–550 ↗(On Diff #36495)

I think we'll want to get some of these into the interface. But that's fine in a follow-up patch. Add a FIXME though.

800 ↗(On Diff #36495)

Doesn't the YAML FS work on the same pwd as the current process?

unittests/Tooling/RewriterTestContext.h
42–45 ↗(On Diff #36495)

Perhaps add a FIXME: To make these tests truly in-memory, we need to overlay the builtin headers.

bkramer updated this revision to Diff 36509.Oct 5 2015, 6:25 AM

Rebased and addressed review comments.

bkramer marked 10 inline comments as done.Oct 5 2015, 6:28 AM
bkramer added inline comments.
include/clang/Basic/VirtualFileSystem.h
286–288 ↗(On Diff #36495)

There is no errc::success, the preferred way is to just use error_code(). Fixed the comment.

lib/Basic/VirtualFileSystem.cpp
80 ↗(On Diff #36495)

Moving it to LLVM. That's done now :)

312–316 ↗(On Diff #36495)

Good catch!

476 ↗(On Diff #36495)

Gone it is.

546–550 ↗(On Diff #36495)

FIXME added.

800 ↗(On Diff #36495)

Changed the methods to forward to the inner FS of the yaml overlay.

klimek accepted this revision.Oct 5 2015, 6:51 AM
klimek edited edge metadata.

lg

lib/Basic/VirtualFileSystem.cpp
1263–1265 ↗(On Diff #36509)

Optional: I'd put this into an anonymous namespace. But I'm also fine with waiting how others think about this :)

This revision is now accepted and ready to land.Oct 5 2015, 6:51 AM
This revision was automatically updated to reflect the committed changes.