This is an archive of the discontinued LLVM Phabricator instance.

Support: Add RedirectingFileSystem::create from simple list of redirections
ClosedPublic

Authored by dexonsmith on Nov 11 2020, 8:05 PM.

Details

Summary

Add an overload of RedirectingFileSystem::create that builds a
redirecting filesystem off of a simple vector of string pairs. This is
intended to be used to support clang::arcmt::FileRemapper and
clang::PreprocessorOptions::RemappedFiles.

Diff Detail

Event Timeline

dexonsmith created this revision.Nov 11 2020, 8:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 11 2020, 8:05 PM
dexonsmith requested review of this revision.Nov 11 2020, 8:05 PM
This revision is now accepted and ready to land.Dec 8 2020, 4:34 AM
JDevlieghere added inline comments.Dec 8 2020, 1:55 PM
llvm/include/llvm/Support/VirtualFileSystem.h
735
  • Do you need to know that this is a RedirectingFileSystem or can it be a FileSystem?
  • Is there a reason this should be a unique_ptr instead of an IntrusiveRefCntPtr (which is more prevalent across the VFS, although I'm not sure why)
dexonsmith added inline comments.Dec 8 2020, 2:26 PM
llvm/include/llvm/Support/VirtualFileSystem.h
735

For my use case it doesn't matter what kind of FileSystem is returned; I figure this could be convenient for a future client. I would tend toward keeping it this type to match the other overload of RedirectingFileSystem::create, but happy to change it if you disagree.

Regarding unique_ptr, I chose that as a sounder alternative to the raw pointer above; leaves options open to clients if they do want unique ownership, which seems nice to support since it's trivial. My use case will ultimately assign it to an IntrusiveRefCntPtr so if you disagree I can change it.

dexonsmith added inline comments.Dec 8 2020, 3:03 PM
llvm/include/llvm/Support/VirtualFileSystem.h
735

It does seem nicer to be consistent, so I just sent out https://reviews.llvm.org/D92888, which allows constructing an IntrusiveRefCntPtr from a moved unique_ptr, and https://reviews.llvm.org/D92890, which update existing APIs to use unique_ptr.

JDevlieghere accepted this revision.Dec 8 2020, 4:04 PM

LGTM with the other patches. Thanks!