[clang] Make PCH's respect any VFS specified. (PR #106577)

Chris B via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 3 17:30:30 PDT 2024


================
@@ -4772,6 +4772,23 @@ bool ASTWriter::PreparePathForOutput(SmallVectorImpl<char> &Path) {
     Changed = true;
   }
 
+  // If we are generating a normal PCH (EG. not a C++ module).
+  if (!WritingModule) {
+    // Use the vfs overlay if it exists to translate paths.
+    auto &FileSys =
+        Context->getSourceManager().getFileManager().getVirtualFileSystem();
+
+    if (auto *RFS = dyn_cast<llvm::vfs::RedirectingFileSystem>(&FileSys)) {
----------------
llvm-beanz wrote:

If instead of calling `cleanPathForOutput` above we call `getRealPath` on the vfs, does that solve this problem? I'm just a little wary about needing to look into the vfs implementation because in theory the abstraction shouldn't require us to look through it.

(cc @benlangmuir & @vsapsai who I believe have done work in this area)

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


More information about the cfe-commits mailing list