[PATCH] D149173: [llvm][vfs] Avoid silent fallback to process-wide working directory

Ben Langmuir via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 2 09:38:58 PDT 2023

benlangmuir added a comment.

> But I think it would be nicer to fail earlier (in the constructor), or propagate the error out of adjustPath(). What do you think?

Returning an error from `adjustPath` makes sense to me if we don't have a usable WD, but the constructor is not so obvious.  I could see a few options

- Pass a `std::error_code` out parameter, but still construct the filesystem so you can ignore the error if desired -- we certainly don't care about the error in clang-scan-deps since we are going to set our own WD later.
- Remove the `getcwd` call and require passing in an initial WD string.  This doesn't really match how we use the filesystem in scan-deps, because we have a per-TU working directory not per-TU filesystem, so I think this could be awkward, or we end up doing something silly like passing "/"
- Don't set any initial working directory in the constructor and reject any calls using relative paths until one is provided via `setCurrentWorkingDirectory`.

  rG LLVM Github Monorepo



More information about the llvm-commits mailing list