@@ -14,27 +14,6 @@ using namespace clang;
1414using namespace tooling ;
1515using 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-
3817DependencyScanningTool::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-
144107FullDependenciesResult 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- }
0 commit comments