Kale created this revision.
Herald added a project: All.
Kale requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

DepFS already provides necessary caching, so explicitly stop reusing the 
FileMgr for possibly cache conflict.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125859

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===================================================================
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -7,6 +7,7 @@
 
//===----------------------------------------------------------------------===//
 
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
+#include "clang/Basic/FileManager.h"
 #include "clang/CodeGen/ObjectFilePCHContainerOperations.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
@@ -197,10 +198,14 @@
       for (const auto &F : ScanInstance.getHeaderSearchOpts().VFSOverlayFiles)
         DepFS->disableMinimization(F);
 
-      // Support for virtual file system overlays on top of the caching
-      // filesystem.
-      FileMgr->setVirtualFileSystem(createVFSFromCompilerInvocation(
-          ScanInstance.getInvocation(), ScanInstance.getDiagnostics(), DepFS));
+      // DepFS already provides caching, so we don't need to reuse FileManager.
+      // The provided FileManger is abandoned for possibly invalid caches 
caused
+      // by the change of VFS.
+      auto VFS = createVFSFromCompilerInvocation(
+          ScanInstance.getInvocation(), ScanInstance.getDiagnostics(), DepFS);
+      FileMgr = new FileManager(FileMgr->getFileSystemOpts(), VFS);
+      ScanInstance.setFileManager(FileMgr);
+      ScanInstance.createSourceManager(*FileMgr);
 
       // Pass the skip mappings which should speed up excluded conditional 
block
       // skipping in the preprocessor.


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===================================================================
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
+#include "clang/Basic/FileManager.h"
 #include "clang/CodeGen/ObjectFilePCHContainerOperations.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
@@ -197,10 +198,14 @@
       for (const auto &F : ScanInstance.getHeaderSearchOpts().VFSOverlayFiles)
         DepFS->disableMinimization(F);
 
-      // Support for virtual file system overlays on top of the caching
-      // filesystem.
-      FileMgr->setVirtualFileSystem(createVFSFromCompilerInvocation(
-          ScanInstance.getInvocation(), ScanInstance.getDiagnostics(), DepFS));
+      // DepFS already provides caching, so we don't need to reuse FileManager.
+      // The provided FileManger is abandoned for possibly invalid caches caused
+      // by the change of VFS.
+      auto VFS = createVFSFromCompilerInvocation(
+          ScanInstance.getInvocation(), ScanInstance.getDiagnostics(), DepFS);
+      FileMgr = new FileManager(FileMgr->getFileSystemOpts(), VFS);
+      ScanInstance.setFileManager(FileMgr);
+      ScanInstance.createSourceManager(*FileMgr);
 
       // Pass the skip mappings which should speed up excluded conditional block
       // skipping in the preprocessor.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to