Author: Jan Svoboda Date: 2023-02-01T13:46:26-08:00 New Revision: e60fcfd6e568d1471e40e6e8a14070ef126cdf4a
URL: https://github.com/llvm/llvm-project/commit/e60fcfd6e568d1471e40e6e8a14070ef126cdf4a DIFF: https://github.com/llvm/llvm-project/commit/e60fcfd6e568d1471e40e6e8a14070ef126cdf4a.diff LOG: [clang][deps] Remove support for the deprecated driver API This API is no longer necessary, so let's remove it to simplify the internal APIs. Reviewed By: benlangmuir, artemcm Differential Revision: https://reviews.llvm.org/D140175 Added: Modified: clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp clang/tools/clang-scan-deps/ClangScanDeps.cpp Removed: clang/test/ClangScanDeps/deprecated-driver-api.c ################################################################################ diff --git a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h index 6af878dbda959..9d247f96c30be 100644 --- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h +++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h @@ -108,12 +108,6 @@ class DependencyScanningTool { LookupModuleOutputCallback LookupModuleOutput, std::optional<StringRef> ModuleName = std::nullopt); - llvm::Expected<FullDependenciesResult> getFullDependenciesLegacyDriverCommand( - const std::vector<std::string> &CommandLine, StringRef CWD, - const llvm::StringSet<> &AlreadySeen, - LookupModuleOutputCallback LookupModuleOutput, - std::optional<StringRef> ModuleName = std::nullopt); - private: DependencyScanningWorker Worker; }; @@ -121,10 +115,8 @@ class DependencyScanningTool { 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 @@ class FullDependencyConsumer : public DependencyConsumer { return LookupModuleOutput(ID, Kind); } - FullDependenciesResult getFullDependenciesLegacyDriverCommand( - const std::vector<std::string> &OriginalCommandLine) const; - FullDependenciesResult takeFullDependencies(); private: @@ -168,7 +157,6 @@ class FullDependencyConsumer : public DependencyConsumer { std::vector<std::string> 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 index 3fcef00a57800..14d1859626f99 100644 --- a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp +++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp @@ -14,27 +14,6 @@ using namespace clang; 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) @@ -117,8 +96,7 @@ DependencyScanningTool::getFullDependencies( const llvm::StringSet<> &AlreadySeen, LookupModuleOutputCallback LookupModuleOutput, std::optional<StringRef> 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 @@ DependencyScanningTool::getFullDependencies( return Consumer.takeFullDependencies(); } -llvm::Expected<FullDependenciesResult> -DependencyScanningTool::getFullDependenciesLegacyDriverCommand( - const std::vector<std::string> &CommandLine, StringRef CWD, - const llvm::StringSet<> &AlreadySeen, - LookupModuleOutputCallback LookupModuleOutput, - std::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; @@ -163,50 +126,3 @@ FullDependenciesResult FullDependencyConsumer::takeFullDependencies() { 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; -} diff --git a/clang/test/ClangScanDeps/deprecated-driver-api.c b/clang/test/ClangScanDeps/deprecated-driver-api.c deleted file mode 100644 index 230673a5927ea..0000000000000 --- 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 index 0db7124c12308..b8256f6401227 100644 --- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp +++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp @@ -178,11 +178,6 @@ llvm::cl::list<std::string> ModuleDepTargets( 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, @@ -581,14 +576,6 @@ int main(int argc, const char **argv) { 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, _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits