diff --git a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h --- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h +++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h @@ -108,12 +108,6 @@ LookupModuleOutputCallback LookupModuleOutput, std::optional ModuleName = std::nullopt); - llvm::Expected getFullDependenciesLegacyDriverCommand( - const std::vector &CommandLine, StringRef CWD, - const llvm::StringSet<> &AlreadySeen, - LookupModuleOutputCallback LookupModuleOutput, - std::optional ModuleName = std::nullopt); - private: DependencyScanningWorker Worker; }; @@ -121,10 +115,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)); @@ -153,9 +145,6 @@ return LookupModuleOutput(ID, Kind); } - FullDependenciesResult getFullDependenciesLegacyDriverCommand( - const std::vector &OriginalCommandLine) const; - FullDependenciesResult takeFullDependencies(); private: @@ -168,7 +157,6 @@ std::vector OutputPaths; const llvm::StringSet<> &AlreadySeen; LookupModuleOutputCallback LookupModuleOutput; - bool EagerLoadModules; }; } // end namespace dependencies 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 @@ -14,27 +14,6 @@ using namespace tooling; using namespace dependencies; -static std::vector -makeTUCommandLineWithoutPaths(ArrayRef OriginalCommandLine) { - std::vector 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 FS) @@ -117,8 +96,7 @@ const llvm::StringSet<> &AlreadySeen, LookupModuleOutputCallback LookupModuleOutput, std::optional ModuleName) { - FullDependencyConsumer Consumer(AlreadySeen, LookupModuleOutput, - Worker.shouldEagerLoadModules()); + FullDependencyConsumer Consumer(AlreadySeen, LookupModuleOutput); llvm::Error Result = Worker.computeDependencies(CWD, CommandLine, Consumer, ModuleName); if (Result) @@ -126,21 +104,6 @@ return Consumer.takeFullDependencies(); } -llvm::Expected -DependencyScanningTool::getFullDependenciesLegacyDriverCommand( - const std::vector &CommandLine, StringRef CWD, - const llvm::StringSet<> &AlreadySeen, - LookupModuleOutputCallback LookupModuleOutput, - std::optional 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; @@ -163,50 +126,3 @@ return FDR; } - -FullDependenciesResult -FullDependencyConsumer::getFullDependenciesLegacyDriverCommand( - const std::vector &OriginalCommandLine) const { - FullDependencies FD; - - FD.DriverCommandLine = makeTUCommandLineWithoutPaths( - ArrayRef(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; -} diff --git a/clang/test/ClangScanDeps/deprecated-driver-api.c b/clang/test/ClangScanDeps/deprecated-driver-api.c deleted file mode 100644 --- a/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(); -} diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp --- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp +++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp @@ -178,11 +178,6 @@ llvm::cl::desc("The names of dependency targets for the dependency file"), llvm::cl::cat(DependencyScannerCategory)); -llvm::cl::opt 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, @@ -581,14 +576,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,