From 6aa64750e81b5cae9c03a0a3ed46033cda125718 Mon Sep 17 00:00:00 2001 From: Naveen Seth Hanig Date: Sat, 13 Dec 2025 18:07:49 +0100 Subject: [PATCH] [clang][DependencyScanning] Unify initVFS helpers to return OverlayFileSystem (NFC) This patch is part of a series of splitting the work from #169964 into smaller changes (see comment linked below). The PR extends the regular and by-name dependency scanning APIs to allow the VFS to be initialized via the initVFS helpers before invoking the scanning APIs, with the resulting overlay filesystem passed into the worker. To make the API consistent, this patch updates both helpers to return an OverlayFileSystem. https://github.com/llvm/llvm-project/pull/169964#pullrequestreview-3545879529 --- .../clang/DependencyScanning/DependencyScannerImpl.h | 3 ++- clang/lib/DependencyScanning/DependencyScannerImpl.cpp | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/clang/include/clang/DependencyScanning/DependencyScannerImpl.h b/clang/include/clang/DependencyScanning/DependencyScannerImpl.h index 9e23c0f87f273..f43c7f70183fd 100644 --- a/clang/include/clang/DependencyScanning/DependencyScannerImpl.h +++ b/clang/include/clang/DependencyScanning/DependencyScannerImpl.h @@ -98,7 +98,8 @@ std::unique_ptr createCompilerInvocation(ArrayRef CommandLine, DiagnosticsEngine &Diags); -std::pair, std::vector> +std::pair, + std::vector> initVFSForTUBufferScanning(IntrusiveRefCntPtr BaseFS, ArrayRef CommandLine, StringRef WorkingDirectory, diff --git a/clang/lib/DependencyScanning/DependencyScannerImpl.cpp b/clang/lib/DependencyScanning/DependencyScannerImpl.cpp index 191ffabeea4f2..201230d7d6a8e 100644 --- a/clang/lib/DependencyScanning/DependencyScannerImpl.cpp +++ b/clang/lib/DependencyScanning/DependencyScannerImpl.cpp @@ -430,7 +430,8 @@ dependencies::createCompilerInvocation(ArrayRef CommandLine, return Invocation; } -std::pair, std::vector> +std::pair, + std::vector> dependencies::initVFSForTUBufferScanning( IntrusiveRefCntPtr BaseFS, ArrayRef CommandLine, StringRef WorkingDirectory, @@ -438,7 +439,6 @@ dependencies::initVFSForTUBufferScanning( // Reset what might have been modified in the previous worker invocation. BaseFS->setCurrentWorkingDirectory(WorkingDirectory); - IntrusiveRefCntPtr ModifiedFS; auto OverlayFS = llvm::makeIntrusiveRefCnt(BaseFS); auto InMemoryFS = llvm::makeIntrusiveRefCnt(); @@ -449,11 +449,10 @@ dependencies::initVFSForTUBufferScanning( IntrusiveRefCntPtr InMemoryOverlay = InMemoryFS; OverlayFS->pushOverlay(InMemoryOverlay); - ModifiedFS = OverlayFS; std::vector ModifiedCommandLine(CommandLine); ModifiedCommandLine.emplace_back(InputPath); - return std::make_pair(ModifiedFS, ModifiedCommandLine); + return std::make_pair(OverlayFS, ModifiedCommandLine); } std::pair,