Skip to content

Commit e60fcfd

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
1 parent 3077d61 commit e60fcfd

File tree

4 files changed

+3
-150
lines changed

4 files changed

+3
-150
lines changed

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,15 @@ class DependencyScanningTool {
108108
LookupModuleOutputCallback LookupModuleOutput,
109109
std::optional<StringRef> ModuleName = std::nullopt);
110110

111-
llvm::Expected<FullDependenciesResult> getFullDependenciesLegacyDriverCommand(
112-
const std::vector<std::string> &CommandLine, StringRef CWD,
113-
const llvm::StringSet<> &AlreadySeen,
114-
LookupModuleOutputCallback LookupModuleOutput,
115-
std::optional<StringRef> ModuleName = std::nullopt);
116-
117111
private:
118112
DependencyScanningWorker Worker;
119113
};
120114

121115
class FullDependencyConsumer : public DependencyConsumer {
122116
public:
123117
FullDependencyConsumer(const llvm::StringSet<> &AlreadySeen,
124-
LookupModuleOutputCallback LookupModuleOutput,
125-
bool EagerLoadModules)
126-
: AlreadySeen(AlreadySeen), LookupModuleOutput(LookupModuleOutput),
127-
EagerLoadModules(EagerLoadModules) {}
118+
LookupModuleOutputCallback LookupModuleOutput)
119+
: AlreadySeen(AlreadySeen), LookupModuleOutput(LookupModuleOutput) {}
128120

129121
void handleBuildCommand(Command Cmd) override {
130122
Commands.push_back(std::move(Cmd));
@@ -153,9 +145,6 @@ class FullDependencyConsumer : public DependencyConsumer {
153145
return LookupModuleOutput(ID, Kind);
154146
}
155147

156-
FullDependenciesResult getFullDependenciesLegacyDriverCommand(
157-
const std::vector<std::string> &OriginalCommandLine) const;
158-
159148
FullDependenciesResult takeFullDependencies();
160149

161150
private:
@@ -168,7 +157,6 @@ class FullDependencyConsumer : public DependencyConsumer {
168157
std::vector<std::string> OutputPaths;
169158
const llvm::StringSet<> &AlreadySeen;
170159
LookupModuleOutputCallback LookupModuleOutput;
171-
bool EagerLoadModules;
172160
};
173161

174162
} // end namespace dependencies

clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp

Lines changed: 1 addition & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,6 @@ using namespace clang;
1414
using namespace tooling;
1515
using namespace dependencies;
1616

17-
static std::vector<std::string>
18-
makeTUCommandLineWithoutPaths(ArrayRef<std::string> OriginalCommandLine) {
19-
std::vector<std::string> Args = OriginalCommandLine;
20-
21-
Args.push_back("-fno-implicit-modules");
22-
Args.push_back("-fno-implicit-module-maps");
23-
24-
// These arguments are unused in explicit compiles.
25-
llvm::erase_if(Args, [](StringRef Arg) {
26-
if (Arg.consume_front("-fmodules-")) {
27-
return Arg.startswith("cache-path=") ||
28-
Arg.startswith("prune-interval=") ||
29-
Arg.startswith("prune-after=") ||
30-
Arg == "validate-once-per-build-session";
31-
}
32-
return Arg.startswith("-fbuild-session-file=");
33-
});
34-
35-
return Args;
36-
}
37-
3817
DependencyScanningTool::DependencyScanningTool(
3918
DependencyScanningService &Service,
4019
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS)
@@ -117,30 +96,14 @@ DependencyScanningTool::getFullDependencies(
11796
const llvm::StringSet<> &AlreadySeen,
11897
LookupModuleOutputCallback LookupModuleOutput,
11998
std::optional<StringRef> ModuleName) {
120-
FullDependencyConsumer Consumer(AlreadySeen, LookupModuleOutput,
121-
Worker.shouldEagerLoadModules());
99+
FullDependencyConsumer Consumer(AlreadySeen, LookupModuleOutput);
122100
llvm::Error Result =
123101
Worker.computeDependencies(CWD, CommandLine, Consumer, ModuleName);
124102
if (Result)
125103
return std::move(Result);
126104
return Consumer.takeFullDependencies();
127105
}
128106

129-
llvm::Expected<FullDependenciesResult>
130-
DependencyScanningTool::getFullDependenciesLegacyDriverCommand(
131-
const std::vector<std::string> &CommandLine, StringRef CWD,
132-
const llvm::StringSet<> &AlreadySeen,
133-
LookupModuleOutputCallback LookupModuleOutput,
134-
std::optional<StringRef> ModuleName) {
135-
FullDependencyConsumer Consumer(AlreadySeen, LookupModuleOutput,
136-
Worker.shouldEagerLoadModules());
137-
llvm::Error Result =
138-
Worker.computeDependencies(CWD, CommandLine, Consumer, ModuleName);
139-
if (Result)
140-
return std::move(Result);
141-
return Consumer.getFullDependenciesLegacyDriverCommand(CommandLine);
142-
}
143-
144107
FullDependenciesResult FullDependencyConsumer::takeFullDependencies() {
145108
FullDependenciesResult FDR;
146109
FullDependencies &FD = FDR.FullDeps;
@@ -163,50 +126,3 @@ FullDependenciesResult FullDependencyConsumer::takeFullDependencies() {
163126

164127
return FDR;
165128
}
166-
167-
FullDependenciesResult
168-
FullDependencyConsumer::getFullDependenciesLegacyDriverCommand(
169-
const std::vector<std::string> &OriginalCommandLine) const {
170-
FullDependencies FD;
171-
172-
FD.DriverCommandLine = makeTUCommandLineWithoutPaths(
173-
ArrayRef<std::string>(OriginalCommandLine).slice(1));
174-
175-
FD.ID.ContextHash = std::move(ContextHash);
176-
177-
FD.FileDeps.assign(Dependencies.begin(), Dependencies.end());
178-
179-
for (const PrebuiltModuleDep &PMD : PrebuiltModuleDeps)
180-
FD.DriverCommandLine.push_back("-fmodule-file=" + PMD.PCMFile);
181-
182-
for (auto &&M : ClangModuleDeps) {
183-
auto &MD = M.second;
184-
if (MD.ImportedByMainFile) {
185-
FD.ClangModuleDeps.push_back(MD.ID);
186-
auto PCMPath = LookupModuleOutput(MD.ID, ModuleOutputKind::ModuleFile);
187-
if (EagerLoadModules) {
188-
FD.DriverCommandLine.push_back("-fmodule-file=" + PCMPath);
189-
} else {
190-
FD.DriverCommandLine.push_back("-fmodule-map-file=" +
191-
MD.ClangModuleMapFile);
192-
FD.DriverCommandLine.push_back("-fmodule-file=" + MD.ID.ModuleName +
193-
"=" + PCMPath);
194-
}
195-
}
196-
}
197-
198-
FD.PrebuiltModuleDeps = std::move(PrebuiltModuleDeps);
199-
200-
FullDependenciesResult FDR;
201-
202-
for (auto &&M : ClangModuleDeps) {
203-
// TODO: Avoid handleModuleDependency even being called for modules
204-
// we've already seen.
205-
if (AlreadySeen.count(M.first))
206-
continue;
207-
FDR.DiscoveredModules.push_back(std::move(M.second));
208-
}
209-
210-
FDR.FullDeps = std::move(FD);
211-
return FDR;
212-
}

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
@@ -178,11 +178,6 @@ llvm::cl::list<std::string> ModuleDepTargets(
178178
llvm::cl::desc("The names of dependency targets for the dependency file"),
179179
llvm::cl::cat(DependencyScannerCategory));
180180

181-
llvm::cl::opt<bool> DeprecatedDriverCommand(
182-
"deprecated-driver-command", llvm::cl::Optional,
183-
llvm::cl::desc("use a single driver command to build the tu (deprecated)"),
184-
llvm::cl::cat(DependencyScannerCategory));
185-
186181
enum ResourceDirRecipeKind {
187182
RDRK_ModifyCompilerPath,
188183
RDRK_InvokeCompiler,
@@ -581,14 +576,6 @@ int main(int argc, const char **argv) {
581576
if (handleMakeDependencyToolResult(Filename, MaybeFile, DependencyOS,
582577
Errs))
583578
HadErrors = true;
584-
} else if (DeprecatedDriverCommand) {
585-
auto MaybeFullDeps =
586-
WorkerTools[I]->getFullDependenciesLegacyDriverCommand(
587-
Input->CommandLine, CWD, AlreadySeenModules, LookupOutput,
588-
MaybeModuleName);
589-
if (handleFullDependencyToolResult(Filename, MaybeFullDeps, FD,
590-
LocalIndex, DependencyOS, Errs))
591-
HadErrors = true;
592579
} else {
593580
auto MaybeFullDeps = WorkerTools[I]->getFullDependencies(
594581
Input->CommandLine, CWD, AlreadySeenModules, LookupOutput,

0 commit comments

Comments
 (0)