[PATCH] D108980: [clang][deps] NFC: Remove CompilationDatabase from DependencyScanningWorker API

Jan Svoboda via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 10 02:23:22 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG729f7b122081: [clang][deps] NFC: Remove CompilationDatabase from DependencyScanningWorker API (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D108980?vs=369663&id=371840#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108980/new/

https://reviews.llvm.org/D108980

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  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
@@ -318,9 +318,8 @@
 }
 
 llvm::Error DependencyScanningWorker::computeDependencies(
-    const std::string &Input, StringRef WorkingDirectory,
-    const CompilationDatabase &CDB, DependencyConsumer &Consumer,
-    llvm::Optional<StringRef> ModuleName) {
+    StringRef WorkingDirectory, const std::vector<std::string> &CommandLine,
+    DependencyConsumer &Consumer, llvm::Optional<StringRef> ModuleName) {
   // Reset what might have been modified in the previous worker invocation.
   RealFS->setCurrentWorkingDirectory(WorkingDirectory);
   if (Files)
@@ -329,11 +328,6 @@
   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;
-
   Optional<std::vector<std::string>> ModifiedCommandLine;
   if (ModuleName.hasValue()) {
     ModifiedCommandLine = CommandLine;
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===================================================================
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ 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<std::string> 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<std::string> 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();
Index: clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
===================================================================
--- clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
+++ 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<std::string> &CommandLine,
                                   DependencyConsumer &Consumer,
                                   llvm::Optional<StringRef> ModuleName = None);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108980.371840.patch
Type: text/x-patch
Size: 4668 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210910/9bab89e2/attachment.bin>


More information about the cfe-commits mailing list