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

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
288–290

Return errc::success?

lib/Basic/VirtualFileSystem.cpp
92

What's the proposed fix? :)

263–268

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)

388

Do we want to make this const?

390

This probably wants to be const.

412

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

427

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

497–501

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.

752

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

unittests/Tooling/RewriterTestContext.h
42–45

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
288–290

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

lib/Basic/VirtualFileSystem.cpp
92

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

263–268

Good catch!

427

Gone it is.

497–501

FIXME added.

752

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

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.