[llvm] [clang] [clang][DependencyScanner] Remove unused -ivfsoverlay files (PR #73734)

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 29 13:31:42 PST 2024


================
@@ -141,6 +141,22 @@ std::vector<bool> HeaderSearch::computeUserEntryUsage() const {
   return UserEntryUsage;
 }
 
+std::vector<bool> HeaderSearch::computeVFSUsageAndClear() const {
+  std::vector<bool> VFSUsage;
+  llvm::vfs::FileSystem &RootFS = FileMgr.getVirtualFileSystem();
+  // TODO: This only works if the `RedirectingFileSystem`s were all created by
+  //       `createVFSFromOverlayFiles`.
+  RootFS.visit([&](llvm::vfs::FileSystem &FS) {
+    if (auto *RFS = dyn_cast<llvm::vfs::RedirectingFileSystem>(&FS)) {
+      VFSUsage.push_back(RFS->hasBeenUsed());
+      RFS->clearHasBeenUsed();
+    }
+  });
+  // VFS visit order is the opposite of VFSOverlayFiles order.
+  std::reverse(VFSUsage.begin(), VFSUsage.end());
+  return VFSUsage;
----------------
jansvoboda11 wrote:

Might be worth asserting that size of `VFSUsage` is the same as the size of `HeaderSearchOptions::VFSOverlayFiles`.

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


More information about the cfe-commits mailing list