[PATCH] D154134: [clang] Fix ASTUnit working directory handling

Hamish Knight via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 29 12:14:22 PDT 2023


hamishknight created this revision.
hamishknight added reviewers: bnbarham, benlangmuir.
hamishknight added a project: clang.
Herald added a project: All.
hamishknight requested review of this revision.
Herald added a subscriber: cfe-commits.

Fix a couple of issues with the handling of the current working directory in ASTUnit:

- Use `createPhysicalFileSystem` instead of `getRealFileSystem` to avoid affecting the process' current working directory, and set it at the top of `ASTUnit::LoadFromCommandLine` such that the driver used for argument parsing and the ASTUnit share the same VFS. This ensures that '-working-directory' correctly sets the VFS working directory in addition to the FileManager working directory.
- Ensure we preserve the FileSystemOptions set on the FileManager when re-creating it (as `ASTUnit::Reparse` will clear the currently set FileManager).

rdar://110697657


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154134

Files:
  clang/lib/Frontend/ASTUnit.cpp
  clang/unittests/Frontend/ASTUnitTest.cpp
  clang/unittests/Frontend/CMakeLists.txt
  clang/unittests/Frontend/ReparseWorkingDirTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154134.535948.patch
Type: text/x-patch
Size: 8336 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230629/02ac28a5/attachment.bin>


More information about the cfe-commits mailing list