jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, benlangmuir.
Herald added a subscriber: ributzka.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This API is no longer necessary, so let's remove it to simplify the internal 
APIs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140175

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/test/ClangScanDeps/deprecated-driver-api.c
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===================================================================
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -177,11 +177,6 @@
     llvm::cl::desc("The names of dependency targets for the dependency file"),
     llvm::cl::cat(DependencyScannerCategory));
 
-llvm::cl::opt<bool> DeprecatedDriverCommand(
-    "deprecated-driver-command", llvm::cl::Optional,
-    llvm::cl::desc("use a single driver command to build the tu (deprecated)"),
-    llvm::cl::cat(DependencyScannerCategory));
-
 enum ResourceDirRecipeKind {
   RDRK_ModifyCompilerPath,
   RDRK_InvokeCompiler,
@@ -580,14 +575,6 @@
           if (handleMakeDependencyToolResult(Filename, MaybeFile, DependencyOS,
                                              Errs))
             HadErrors = true;
-        } else if (DeprecatedDriverCommand) {
-          auto MaybeFullDeps =
-              WorkerTools[I]->getFullDependenciesLegacyDriverCommand(
-                  Input->CommandLine, CWD, AlreadySeenModules, LookupOutput,
-                  MaybeModuleName);
-          if (handleFullDependencyToolResult(Filename, MaybeFullDeps, FD,
-                                             LocalIndex, DependencyOS, Errs))
-            HadErrors = true;
         } else {
           auto MaybeFullDeps = WorkerTools[I]->getFullDependencies(
               Input->CommandLine, CWD, AlreadySeenModules, LookupOutput,
Index: clang/test/ClangScanDeps/deprecated-driver-api.c
===================================================================
--- clang/test/ClangScanDeps/deprecated-driver-api.c
+++ /dev/null
@@ -1,38 +0,0 @@
-// Test the deprecated version of the API that returns a driver command instead
-// of multiple -cc1 commands.
-
-// RUN: rm -rf %t
-// RUN: split-file %s %t
-// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.in > %t/cdb.json
-
-// RUN: clang-scan-deps -compilation-database=%t/cdb.json -format experimental-full \
-// RUN:   -deprecated-driver-command | sed 's:\\\\\?:/:g' | FileCheck %s
-
-// CHECK: "command-line": [
-// CHECK:   "-c"
-// CHECK:   "{{.*}}tu.c"
-// CHECK:   "-save-temps"
-// CHECK:   "-fno-implicit-modules"
-// CHECK:   "-fno-implicit-module-maps"
-// CHECK: ]
-// CHECK: "file-deps": [
-// CHECK:   "{{.*}}tu.c",
-// CHECK:   "{{.*}}header.h"
-// CHECK: ]
-
-//--- cdb.json.in
-[{
-  "directory": "DIR",
-  "command": "clang -c DIR/tu.c -save-temps",
-  "file": "DIR/tu.c"
-}]
-
-//--- header.h
-void bar(void);
-
-//--- tu.c
-#include "header.h"
-
-void foo(void) {
-  bar();
-}
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===================================================================
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -13,27 +13,6 @@
 using namespace tooling;
 using namespace dependencies;
 
-static std::vector<std::string>
-makeTUCommandLineWithoutPaths(ArrayRef<std::string> OriginalCommandLine) {
-  std::vector<std::string> Args = OriginalCommandLine;
-
-  Args.push_back("-fno-implicit-modules");
-  Args.push_back("-fno-implicit-module-maps");
-
-  // These arguments are unused in explicit compiles.
-  llvm::erase_if(Args, [](StringRef Arg) {
-    if (Arg.consume_front("-fmodules-")) {
-      return Arg.startswith("cache-path=") ||
-             Arg.startswith("prune-interval=") ||
-             Arg.startswith("prune-after=") ||
-             Arg == "validate-once-per-build-session";
-    }
-    return Arg.startswith("-fbuild-session-file=");
-  });
-
-  return Args;
-}
-
 DependencyScanningTool::DependencyScanningTool(
     DependencyScanningService &Service,
     llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS)
@@ -116,8 +95,7 @@
     const llvm::StringSet<> &AlreadySeen,
     LookupModuleOutputCallback LookupModuleOutput,
     llvm::Optional<StringRef> ModuleName) {
-  FullDependencyConsumer Consumer(AlreadySeen, LookupModuleOutput,
-                                  Worker.shouldEagerLoadModules());
+  FullDependencyConsumer Consumer(AlreadySeen, LookupModuleOutput);
   llvm::Error Result =
       Worker.computeDependencies(CWD, CommandLine, Consumer, ModuleName);
   if (Result)
@@ -125,21 +103,6 @@
   return Consumer.takeFullDependencies();
 }
 
-llvm::Expected<FullDependenciesResult>
-DependencyScanningTool::getFullDependenciesLegacyDriverCommand(
-    const std::vector<std::string> &CommandLine, StringRef CWD,
-    const llvm::StringSet<> &AlreadySeen,
-    LookupModuleOutputCallback LookupModuleOutput,
-    llvm::Optional<StringRef> ModuleName) {
-  FullDependencyConsumer Consumer(AlreadySeen, LookupModuleOutput,
-                                  Worker.shouldEagerLoadModules());
-  llvm::Error Result =
-      Worker.computeDependencies(CWD, CommandLine, Consumer, ModuleName);
-  if (Result)
-    return std::move(Result);
-  return Consumer.getFullDependenciesLegacyDriverCommand(CommandLine);
-}
-
 FullDependenciesResult FullDependencyConsumer::takeFullDependencies() {
   FullDependenciesResult FDR;
   FullDependencies &FD = FDR.FullDeps;
@@ -162,50 +125,3 @@
 
   return FDR;
 }
-
-FullDependenciesResult
-FullDependencyConsumer::getFullDependenciesLegacyDriverCommand(
-    const std::vector<std::string> &OriginalCommandLine) const {
-  FullDependencies FD;
-
-  FD.DriverCommandLine = makeTUCommandLineWithoutPaths(
-      ArrayRef<std::string>(OriginalCommandLine).slice(1));
-
-  FD.ID.ContextHash = std::move(ContextHash);
-
-  FD.FileDeps.assign(Dependencies.begin(), Dependencies.end());
-
-  for (const PrebuiltModuleDep &PMD : PrebuiltModuleDeps)
-    FD.DriverCommandLine.push_back("-fmodule-file=" + PMD.PCMFile);
-
-  for (auto &&M : ClangModuleDeps) {
-    auto &MD = M.second;
-    if (MD.ImportedByMainFile) {
-      FD.ClangModuleDeps.push_back(MD.ID);
-      auto PCMPath = LookupModuleOutput(MD.ID, ModuleOutputKind::ModuleFile);
-      if (EagerLoadModules) {
-        FD.DriverCommandLine.push_back("-fmodule-file=" + PCMPath);
-      } else {
-        FD.DriverCommandLine.push_back("-fmodule-map-file=" +
-                                       MD.ClangModuleMapFile);
-        FD.DriverCommandLine.push_back("-fmodule-file=" + MD.ID.ModuleName +
-                                       "=" + PCMPath);
-      }
-    }
-  }
-
-  FD.PrebuiltModuleDeps = std::move(PrebuiltModuleDeps);
-
-  FullDependenciesResult FDR;
-
-  for (auto &&M : ClangModuleDeps) {
-    // TODO: Avoid handleModuleDependency even being called for modules
-    //   we've already seen.
-    if (AlreadySeen.count(M.first))
-      continue;
-    FDR.DiscoveredModules.push_back(std::move(M.second));
-  }
-
-  FDR.FullDeps = std::move(FD);
-  return FDR;
-}
Index: clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
===================================================================
--- clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
+++ clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
@@ -107,12 +107,6 @@
                       LookupModuleOutputCallback LookupModuleOutput,
                       llvm::Optional<StringRef> ModuleName = std::nullopt);
 
-  llvm::Expected<FullDependenciesResult> getFullDependenciesLegacyDriverCommand(
-      const std::vector<std::string> &CommandLine, StringRef CWD,
-      const llvm::StringSet<> &AlreadySeen,
-      LookupModuleOutputCallback LookupModuleOutput,
-      llvm::Optional<StringRef> ModuleName = std::nullopt);
-
 private:
   DependencyScanningWorker Worker;
 };
@@ -120,10 +114,8 @@
 class FullDependencyConsumer : public DependencyConsumer {
 public:
   FullDependencyConsumer(const llvm::StringSet<> &AlreadySeen,
-                         LookupModuleOutputCallback LookupModuleOutput,
-                         bool EagerLoadModules)
-      : AlreadySeen(AlreadySeen), LookupModuleOutput(LookupModuleOutput),
-        EagerLoadModules(EagerLoadModules) {}
+                         LookupModuleOutputCallback LookupModuleOutput)
+      : AlreadySeen(AlreadySeen), LookupModuleOutput(LookupModuleOutput) {}
 
   void handleBuildCommand(Command Cmd) override {
     Commands.push_back(std::move(Cmd));
@@ -152,9 +144,6 @@
     return LookupModuleOutput(ID, Kind);
   }
 
-  FullDependenciesResult getFullDependenciesLegacyDriverCommand(
-      const std::vector<std::string> &OriginalCommandLine) const;
-
   FullDependenciesResult takeFullDependencies();
 
 private:
@@ -167,7 +156,6 @@
   std::vector<std::string> OutputPaths;
   const llvm::StringSet<> &AlreadySeen;
   LookupModuleOutputCallback LookupModuleOutput;
-  bool EagerLoadModules;
 };
 
 } // end namespace dependencies
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D140175: [clang][deps... Jan Svoboda via Phabricator via cfe-commits

Reply via email to