[PATCH] D56545: [VFS] Allow multiple RealFileSystem instances with independent CWDs.
Pavel Labath via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 10 07:13:56 PST 2019
labath added a subscriber: JDevlieghere.
labath added a comment.
The patch makes sense to me.
I wonder if instead of lambda-wrapping everything we couldn't use a pattern like this:
Twine fixPath(const Twin &Orig, SmallVectorImpl<char> &Storage) {
if (path_needs_fixing()) {
fix_path(Orig, Storage);
return Storage;
}
return Orig;
}
T whatever(const Twine &Path) {
SmallString<N> Storage;
// This is safe because the returned twine is either a copy of the input twine or a unary twine backed by the provided storage
Twine Fixed = fixPath(Path, Storage);
return do_stuff(Fixed);
}
This usage of `Twine` isn't very nice, but neither is lambda-wrapping everything, so it's kind of a pick-your-poison situation. Anyway, just throwing the idea out there...
================
Comment at: lib/Support/VirtualFileSystem.cpp:241
public:
+ RealFileSystem(bool LinkCWDToProcess) {
+ if (!LinkCWDToProcess) {
----------------
explicit
================
Comment at: lib/Support/VirtualFileSystem.cpp:265
+ template <typename Func, typename R = decltype(std::declval<Func>()(Twine()))>
+ R WithFixedPath(const Twine& Path, const Func &F) const {
+ if (!WD)
----------------
It looks like it should be possible to use the trailing return type syntax to simplify this (`auto WithFixedPath(Path, F) -> decltype(F(Path))`
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56545/new/
https://reviews.llvm.org/D56545
More information about the llvm-commits
mailing list