[all-commits] [llvm/llvm-project] 986725: [clang][deps] Don't share in-memory VFS across scans

Jan Svoboda via All-commits all-commits at lists.llvm.org
Wed Oct 12 18:40:50 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 98672596626862e4b21319da7c01737bf7e20ae4
      https://github.com/llvm/llvm-project/commit/98672596626862e4b21319da7c01737bf7e20ae4
  Author: Jan Svoboda <jan_svoboda at apple.com>
  Date:   2022-10-12 (Wed, 12 Oct 2022)

  Changed paths:
    M clang/include/clang/Basic/FileManager.h
    M clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
    M clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp

  Log Message:
  -----------
  [clang][deps] Don't share in-memory VFS across scans

The dependency scanning worker may create an in-memory VFS and inject that into its `FileManager`. (Implemented in D109485.) This VFS currently persists between scans, which is not correct: in-memory files created in one scan could affect subsequent scans. This patch changes things so that the in-memory VFS is local to `DependencyScanningWorker::computeDependencies()`.

To test this, one would first scan for dependencies of a named module and then run second scan (on the same worker) for something unrelated, which would pick up the in-memory file created in the first scan. This set up is impossible to achieve with `clang-scan-deps`. We could set this up in `ToolingTests`, but the scanner needs to access the physical filesystem to store `.pcm` files. AFAIK we don't have a good way to propagate something like `%t` into unit tests to make that feasible. (This could be achieved with something like the virtualized `OutputManager`.)

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D135414


  Commit: 888daa9e83bceb6cb8fda02f5f3719391f717154
      https://github.com/llvm/llvm-project/commit/888daa9e83bceb6cb8fda02f5f3719391f717154
  Author: Jan Svoboda <jan_svoboda at apple.com>
  Date:   2022-10-12 (Wed, 12 Oct 2022)

  Changed paths:
    M clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
    M clang/test/ClangScanDeps/vfsoverlay.cpp

  Log Message:
  -----------
  [clang][deps] Respect VFS overlays in canonical preprocessing mode

The `-ivfsoverlay` flag was only being respected when the scanner was instructed to minimize the inputs. This patch respects that flag even in canonical preprocessing mode.

Depends on D135414.

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D135416


Compare: https://github.com/llvm/llvm-project/compare/4f158995b9cd...888daa9e83bc


More information about the All-commits mailing list