Skip to content

Commit 92436eb

Browse files
committed
[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 (cherry picked from commit e60fcfd)
1 parent 12ae09b commit 92436eb

File tree

4 files changed

+3
-153
lines changed

4 files changed

+3
-153
lines changed

clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,6 @@ class DependencyScanningTool {
172172
return Worker.getOrCreateFileManager();
173173
}
174174

175-
llvm::Expected<FullDependenciesResult> getFullDependenciesLegacyDriverCommand(
176-
const std::vector<std::string> &CommandLine, StringRef CWD,
177-
const llvm::StringSet<> &AlreadySeen,
178-
LookupModuleOutputCallback LookupModuleOutput,
179-
llvm::Optional<StringRef> ModuleName = None);
180-
181175
private:
182176
DependencyScanningWorker Worker;
183177
};
@@ -186,12 +180,10 @@ class FullDependencyConsumer : public DependencyConsumer {
186180
public:
187181
FullDependencyConsumer(const llvm::StringSet<> &AlreadySeen,
188182
LookupModuleOutputCallback LookupModuleOutput,
189-
bool EagerLoadModules,
190183
CachingOnDiskFileSystemPtr CacheFS = nullptr,
191184
DepscanPrefixMapping PrefixMapping = {})
192185
: CacheFS(std::move(CacheFS)), PrefixMapping(std::move(PrefixMapping)),
193-
AlreadySeen(AlreadySeen), LookupModuleOutput(LookupModuleOutput),
194-
EagerLoadModules(EagerLoadModules) {}
186+
AlreadySeen(AlreadySeen), LookupModuleOutput(LookupModuleOutput) {}
195187

196188
llvm::Error initialize(CompilerInstance &ScanInstance,
197189
CompilerInvocation &NewInvocation) override;
@@ -239,9 +231,6 @@ class FullDependencyConsumer : public DependencyConsumer {
239231
return LookupModuleOutput(ID, Kind);
240232
}
241233

242-
FullDependenciesResult getFullDependenciesLegacyDriverCommand(
243-
const std::vector<std::string> &OriginalCommandLine) const;
244-
245234
FullDependenciesResult takeFullDependencies();
246235

247236
private:
@@ -259,7 +248,6 @@ class FullDependencyConsumer : public DependencyConsumer {
259248
std::vector<std::string> OutputPaths;
260249
const llvm::StringSet<> &AlreadySeen;
261250
LookupModuleOutputCallback LookupModuleOutput;
262-
bool EagerLoadModules;
263251
};
264252

265253
} // end namespace dependencies

clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp

Lines changed: 2 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,6 @@ using namespace tooling;
2222
using namespace dependencies;
2323
using llvm::Error;
2424

25-
static std::vector<std::string>
26-
makeTUCommandLineWithoutPaths(ArrayRef<std::string> OriginalCommandLine) {
27-
std::vector<std::string> Args = OriginalCommandLine;
28-
29-
Args.push_back("-fno-implicit-modules");
30-
Args.push_back("-fno-implicit-module-maps");
31-
32-
// These arguments are unused in explicit compiles.
33-
llvm::erase_if(Args, [](StringRef Arg) {
34-
if (Arg.consume_front("-fmodules-")) {
35-
return Arg.startswith("cache-path=") ||
36-
Arg.startswith("prune-interval=") ||
37-
Arg.startswith("prune-after=") ||
38-
Arg == "validate-once-per-build-session";
39-
}
40-
return Arg.startswith("-fbuild-session-file=");
41-
});
42-
43-
return Args;
44-
}
45-
4625
DependencyScanningTool::DependencyScanningTool(
4726
DependencyScanningService &Service,
4827
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS)
@@ -144,8 +123,8 @@ class GetDependencyTree : public FullDependencyConsumer {
144123

145124
GetDependencyTree(llvm::cas::CachingOnDiskFileSystem &FS,
146125
DepscanPrefixMapping PrefixMapping)
147-
: FullDependencyConsumer(AlreadySeen, nullptr, /*EagerModules=*/false,
148-
&FS, std::move(PrefixMapping)),
126+
: FullDependencyConsumer(AlreadySeen, nullptr, &FS,
127+
std::move(PrefixMapping)),
149128
FS(FS) {}
150129

151130
private:
@@ -567,7 +546,6 @@ DependencyScanningTool::getFullDependencies(
567546
LookupModuleOutputCallback LookupModuleOutput,
568547
llvm::Optional<StringRef> ModuleName, DepscanPrefixMapping PrefixMapping) {
569548
FullDependencyConsumer Consumer(AlreadySeen, LookupModuleOutput,
570-
Worker.shouldEagerLoadModules(),
571549
Worker.getCASFS(), std::move(PrefixMapping));
572550
llvm::Error Result =
573551
Worker.computeDependencies(CWD, CommandLine, Consumer, ModuleName);
@@ -576,22 +554,6 @@ DependencyScanningTool::getFullDependencies(
576554
return Consumer.takeFullDependencies();
577555
}
578556

579-
llvm::Expected<FullDependenciesResult>
580-
DependencyScanningTool::getFullDependenciesLegacyDriverCommand(
581-
const std::vector<std::string> &CommandLine, StringRef CWD,
582-
const llvm::StringSet<> &AlreadySeen,
583-
LookupModuleOutputCallback LookupModuleOutput,
584-
llvm::Optional<StringRef> ModuleName) {
585-
FullDependencyConsumer Consumer(AlreadySeen, LookupModuleOutput,
586-
Worker.shouldEagerLoadModules(),
587-
Worker.getCASFS());
588-
llvm::Error Result =
589-
Worker.computeDependencies(CWD, CommandLine, Consumer, ModuleName);
590-
if (Result)
591-
return std::move(Result);
592-
return Consumer.getFullDependenciesLegacyDriverCommand(CommandLine);
593-
}
594-
595557
Error FullDependencyConsumer::initialize(CompilerInstance &ScanInstance,
596558
CompilerInvocation &NewInvocation) {
597559
if (CacheFS) {
@@ -756,52 +718,3 @@ FullDependenciesResult FullDependencyConsumer::takeFullDependencies() {
756718

757719
return FDR;
758720
}
759-
760-
FullDependenciesResult
761-
FullDependencyConsumer::getFullDependenciesLegacyDriverCommand(
762-
const std::vector<std::string> &OriginalCommandLine) const {
763-
FullDependencies FD;
764-
765-
FD.DriverCommandLine = makeTUCommandLineWithoutPaths(
766-
ArrayRef<std::string>(OriginalCommandLine).slice(1));
767-
768-
FD.ID.ContextHash = std::move(ContextHash);
769-
770-
FD.FileDeps.assign(Dependencies.begin(), Dependencies.end());
771-
772-
for (const PrebuiltModuleDep &PMD : PrebuiltModuleDeps)
773-
FD.DriverCommandLine.push_back("-fmodule-file=" + PMD.PCMFile);
774-
775-
for (auto &&M : ClangModuleDeps) {
776-
auto &MD = M.second;
777-
if (MD.ImportedByMainFile) {
778-
FD.ClangModuleDeps.push_back(MD.ID);
779-
auto PCMPath = LookupModuleOutput(MD.ID, ModuleOutputKind::ModuleFile);
780-
if (EagerLoadModules) {
781-
FD.DriverCommandLine.push_back("-fmodule-file=" + PCMPath);
782-
} else {
783-
FD.DriverCommandLine.push_back("-fmodule-map-file=" +
784-
MD.ClangModuleMapFile);
785-
FD.DriverCommandLine.push_back("-fmodule-file=" + MD.ID.ModuleName +
786-
"=" + PCMPath);
787-
}
788-
}
789-
}
790-
791-
FD.PrebuiltModuleDeps = std::move(PrebuiltModuleDeps);
792-
793-
FD.CASFileSystemRootID = CASFileSystemRootID;
794-
795-
FullDependenciesResult FDR;
796-
797-
for (auto &&M : ClangModuleDeps) {
798-
// TODO: Avoid handleModuleDependency even being called for modules
799-
// we've already seen.
800-
if (AlreadySeen.count(M.first))
801-
continue;
802-
FDR.DiscoveredModules.push_back(std::move(M.second));
803-
}
804-
805-
FDR.FullDeps = std::move(FD);
806-
return FDR;
807-
}

clang/test/ClangScanDeps/deprecated-driver-api.c

Lines changed: 0 additions & 38 deletions
This file was deleted.

clang/tools/clang-scan-deps/ClangScanDeps.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,6 @@ llvm::cl::list<std::string> ModuleDepTargets(
194194
llvm::cl::desc("The names of dependency targets for the dependency file"),
195195
llvm::cl::cat(DependencyScannerCategory));
196196

197-
llvm::cl::opt<bool> DeprecatedDriverCommand(
198-
"deprecated-driver-command", llvm::cl::Optional,
199-
llvm::cl::desc("use a single driver command to build the tu (deprecated)"),
200-
llvm::cl::cat(DependencyScannerCategory));
201-
202197
enum ResourceDirRecipeKind {
203198
RDRK_ModifyCompilerPath,
204199
RDRK_InvokeCompiler,
@@ -945,14 +940,6 @@ int main(int argc, const char **argv) {
945940
std::unique_lock<std::mutex> LockGuard(Lock);
946941
TreeResults.emplace_back(LocalIndex, std::move(Filename),
947942
std::move(MaybeTree));
948-
} else if (DeprecatedDriverCommand) {
949-
auto MaybeFullDeps =
950-
WorkerTools[I]->getFullDependenciesLegacyDriverCommand(
951-
Input->CommandLine, CWD, AlreadySeenModules, LookupOutput,
952-
MaybeModuleName);
953-
if (handleFullDependencyToolResult(Filename, MaybeFullDeps, FD,
954-
LocalIndex, DependencyOS, Errs))
955-
HadErrors = true;
956943
} else {
957944
auto MaybeFullDeps = WorkerTools[I]->getFullDependencies(
958945
Input->CommandLine, CWD, AlreadySeenModules, LookupOutput,

0 commit comments

Comments
 (0)