Skip to content

Commit 57fcbd4

Browse files
authored
[clang][DependencyScanning] Unify initVFS helpers to return OverlayFileSystem (NFC) (#172166)
This patch is part of a series of splitting the work from #169964 into smaller changes (see review linked below). As part of this work, the regular and by-name dependency scanning APIs need to be extended to allow the VFS to be initialized via the initVFS helpers before invoking the scanning API, with the resulting overlay filesystem passed into the worker instead. To make the newly added API changes consistent, this patch updates both helpers to return an OverlayFileSystem. #169964 (review)
1 parent 5ba6256 commit 57fcbd4

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

clang/include/clang/DependencyScanning/DependencyScannerImpl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ std::unique_ptr<CompilerInvocation>
9898
createCompilerInvocation(ArrayRef<std::string> CommandLine,
9999
DiagnosticsEngine &Diags);
100100

101-
std::pair<IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::vector<std::string>>
101+
std::pair<IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>,
102+
std::vector<std::string>>
102103
initVFSForTUBufferScanning(IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS,
103104
ArrayRef<std::string> CommandLine,
104105
StringRef WorkingDirectory,

clang/lib/DependencyScanning/DependencyScannerImpl.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,15 +430,15 @@ dependencies::createCompilerInvocation(ArrayRef<std::string> CommandLine,
430430
return Invocation;
431431
}
432432

433-
std::pair<IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::vector<std::string>>
433+
std::pair<IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>,
434+
std::vector<std::string>>
434435
dependencies::initVFSForTUBufferScanning(
435436
IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS,
436437
ArrayRef<std::string> CommandLine, StringRef WorkingDirectory,
437438
llvm::MemoryBufferRef TUBuffer) {
438439
// Reset what might have been modified in the previous worker invocation.
439440
BaseFS->setCurrentWorkingDirectory(WorkingDirectory);
440441

441-
IntrusiveRefCntPtr<llvm::vfs::FileSystem> ModifiedFS;
442442
auto OverlayFS =
443443
llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(BaseFS);
444444
auto InMemoryFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
@@ -449,11 +449,10 @@ dependencies::initVFSForTUBufferScanning(
449449
IntrusiveRefCntPtr<llvm::vfs::FileSystem> InMemoryOverlay = InMemoryFS;
450450

451451
OverlayFS->pushOverlay(InMemoryOverlay);
452-
ModifiedFS = OverlayFS;
453452
std::vector<std::string> ModifiedCommandLine(CommandLine);
454453
ModifiedCommandLine.emplace_back(InputPath);
455454

456-
return std::make_pair(ModifiedFS, ModifiedCommandLine);
455+
return std::make_pair(OverlayFS, ModifiedCommandLine);
457456
}
458457

459458
std::pair<IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>,

0 commit comments

Comments
 (0)