[PATCH] D108979: [clang][deps] NFC: Stop going through ClangTool
Jan Svoboda via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 3 04:36:08 PDT 2021
jansvoboda11 updated this revision to Diff 370545.
jansvoboda11 added a comment.
Resolve test failing on Windows by re-setting the VFS on `FileManager`.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108979/new/
https://reviews.llvm.org/D108979
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
@@ -308,18 +308,28 @@
llvm::Error DependencyScanningWorker::computeDependencies(
const std::string &Input, StringRef WorkingDirectory,
const CompilationDatabase &CDB, DependencyConsumer &Consumer) {
+ // Reset what might have been modified in the previous worker invocation.
RealFS->setCurrentWorkingDirectory(WorkingDirectory);
+ if (Files)
+ Files->setVirtualFileSystem(RealFS);
+
+ llvm::IntrusiveRefCntPtr<FileManager> CurrentFiles =
+ Files ? Files : new FileManager(FileSystemOptions(), RealFS);
+
+ // FIXME: Avoid this copy.
+ std::vector<CompileCommand> CompileCommands = CDB.getCompileCommands(Input);
+ const std::vector<std::string> &CommandLine =
+ CompileCommands.front().CommandLine;
+
return runWithDiags(DiagOpts.get(), [&](DiagnosticConsumer &DC) {
- /// Create the tool that uses the underlying file system to ensure that any
- /// file system requests that are made by the driver do not go through the
- /// dependency scanning filesystem.
- tooling::ClangTool Tool(CDB, Input, PCHContainerOps, RealFS, Files);
- Tool.clearArgumentsAdjusters();
- Tool.setRestoreWorkingDir(false);
- Tool.setPrintErrorMessage(false);
- Tool.setDiagnosticConsumer(&DC);
DependencyScanningAction Action(WorkingDirectory, Consumer, DepFS,
PPSkipMappings.get(), Format);
- return !Tool.run(&Action);
+ // Create an invocation that uses the underlying file system to ensure that
+ // any file system requests that are made by the driver do not go through
+ // the dependency scanning filesystem.
+ ToolInvocation Invocation(CommandLine, &Action, CurrentFiles.get(),
+ PCHContainerOps);
+ Invocation.setDiagnosticConsumer(&DC);
+ return Invocation.run();
});
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108979.370545.patch
Type: text/x-patch
Size: 2095 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210903/80e9df26/attachment.bin>
More information about the cfe-commits
mailing list