Skip to content

Conversation

@hamishknight
Copy link

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

@hamishknight hamishknight requested a review from bnbarham June 26, 2023 17:52
Copy link

@bnbarham bnbarham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tracking this down @hamishknight!

@bnbarham bnbarham requested review from akyrtzi and benlangmuir June 26, 2023 18:11
Copy link

@benlangmuir benlangmuir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes should go upstream to llvm.org

@hamishknight
Copy link
Author

These changes should go upstream to llvm.org

Yup, that's the plan, we're cherry-picking downstream first as we want to get this into 5.9 fairly soon

@bnbarham
Copy link

@swift-ci please test Windows platform

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
@hamishknight
Copy link
Author

@swift-ci please test

@hamishknight hamishknight changed the title [ASTUnit] Fix working directory handling [clang] Fix ASTUnit working directory handling Jun 27, 2023
@hamishknight
Copy link
Author

@swift-ci please test macOS

@hamishknight hamishknight merged commit 2b330ec into swiftlang:stable/20221013 Jun 28, 2023
@hamishknight hamishknight deleted the time-and-place branch June 28, 2023 14:46
@hamishknight
Copy link
Author

Upstream patch: https://reviews.llvm.org/D154134

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants