[clang] [clang][deps] Fix dependency scanning with -working-directory (PR #84525)

Ben Langmuir via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 11 10:06:02 PDT 2024


benlangmuir wrote:

> I can see a situation where we ask FileManager about the same relative path before and after setting the parsed FileSystemOptions. The second call would blindly return the cached result, effectively ignoring -working-directory for that file.

The driver calls `VFS->setCurrentWorkingDirectory` using the value of `-working-directory`. So in general relative paths will be resolved consistently with `-working-directory` if they're seen before configuring the `FileManager`.  Now, a fair question is why are we changing both the VFS working directory *and* making paths absolute in the FileManager for `-working-directory`, which seems redundant, but I'm not looking to change that behaviour -- this PR should make scanning behave more consistently with compilation.

To be clear this situation with mismatched relative paths would **currently** be broken, because the way we were setting `FSOpts.WorkingDir` was not using the value of `-working-directory` before this change.

https://github.com/llvm/llvm-project/pull/84525


More information about the cfe-commits mailing list