diff --git a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h --- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h +++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h @@ -74,16 +74,15 @@ public: DependencyScanningWorker(DependencyScanningService &Service); - /// Run the dependency scanning tool for a given clang driver invocation (as - /// specified for the given Input in the CDB), and report the discovered - /// dependencies to the provided consumer. If \p ModuleName isn't empty, this - /// function reports the dependencies of module \p ModuleName. + /// Run the dependency scanning tool for a given clang driver command-line, + /// and report the discovered dependencies to the provided consumer. If \p + /// ModuleName isn't empty, this function reports the dependencies of module + /// \p ModuleName. /// /// \returns A \c StringError with the diagnostic output if clang errors /// occurred, success otherwise. - llvm::Error computeDependencies(const std::string &Input, - StringRef WorkingDirectory, - const CompilationDatabase &CDB, + llvm::Error computeDependencies(StringRef WorkingDirectory, + const std::vector &CommandLine, DependencyConsumer &Consumer, llvm::Optional ModuleName = None); diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp --- a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp +++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp @@ -110,11 +110,13 @@ // behavior. assert(Compilations.getAllCompileCommands().size() == 1 && "Expected a compilation database with a single command!"); - std::string Input = Compilations.getAllCompileCommands().front().Filename; + // FIXME: Avoid this copy. + std::vector CommandLine = + Compilations.getAllCompileCommands().front().CommandLine; MakeDependencyPrinterConsumer Consumer; - auto Result = Worker.computeDependencies(Input, CWD, Compilations, Consumer, - ModuleName); + auto Result = + Worker.computeDependencies(CWD, CommandLine, Consumer, ModuleName); if (Result) return std::move(Result); std::string Output; @@ -196,11 +198,13 @@ // behavior. assert(Compilations.getAllCompileCommands().size() == 1 && "Expected a compilation database with a single command!"); - std::string Input = Compilations.getAllCompileCommands().front().Filename; + // FIXME: Avoid this copy. + std::vector CommandLine = + Compilations.getAllCompileCommands().front().CommandLine; FullDependencyPrinterConsumer Consumer(AlreadySeen); - llvm::Error Result = Worker.computeDependencies(Input, CWD, Compilations, - Consumer, ModuleName); + llvm::Error Result = + Worker.computeDependencies(CWD, CommandLine, Consumer, ModuleName); if (Result) return std::move(Result); return Consumer.getFullDependencies(); diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp --- a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp +++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp @@ -318,9 +318,8 @@ } llvm::Error DependencyScanningWorker::computeDependencies( - const std::string &Input, StringRef WorkingDirectory, - const CompilationDatabase &CDB, DependencyConsumer &Consumer, - llvm::Optional ModuleName) { + StringRef WorkingDirectory, const std::vector &CommandLine, + DependencyConsumer &Consumer, llvm::Optional ModuleName) { // Reset what might have been modified in the previous worker invocation. RealFS->setCurrentWorkingDirectory(WorkingDirectory); if (Files) @@ -329,11 +328,6 @@ llvm::IntrusiveRefCntPtr CurrentFiles = Files ? Files : new FileManager(FileSystemOptions(), RealFS); - // FIXME: Avoid this copy. - std::vector CompileCommands = CDB.getCompileCommands(Input); - const std::vector &CommandLine = - CompileCommands.front().CommandLine; - Optional> ModifiedCommandLine; if (ModuleName.hasValue()) { ModifiedCommandLine = CommandLine;