@@ -165,34 +165,34 @@ class DependencyScanningAction : public tooling::ToolAction {
165
165
CompilerInvocation OriginalInvocation (*Invocation);
166
166
167
167
// Create a compiler instance to handle the actual work.
168
- CompilerInstance Compiler (std::move (PCHContainerOps));
169
- Compiler .setInvocation (std::move (Invocation));
168
+ CompilerInstance ScanInstance (std::move (PCHContainerOps));
169
+ ScanInstance .setInvocation (std::move (Invocation));
170
170
171
171
// Create the compiler's actual diagnostics engine.
172
- sanitizeDiagOpts (Compiler .getDiagnosticOpts ());
173
- Compiler .createDiagnostics (DiagConsumer, /* ShouldOwnClient=*/ false );
174
- if (!Compiler .hasDiagnostics ())
172
+ sanitizeDiagOpts (ScanInstance .getDiagnosticOpts ());
173
+ ScanInstance .createDiagnostics (DiagConsumer, /* ShouldOwnClient=*/ false );
174
+ if (!ScanInstance .hasDiagnostics ())
175
175
return false ;
176
176
177
- Compiler.getPreprocessorOpts ().AllowPCHWithDifferentModulesCachePath = true ;
177
+ ScanInstance.getPreprocessorOpts ().AllowPCHWithDifferentModulesCachePath =
178
+ true ;
178
179
179
180
FileMgr->getFileSystemOpts ().WorkingDir = std::string (WorkingDirectory);
180
- Compiler .setFileManager (FileMgr);
181
- Compiler .createSourceManager (*FileMgr);
181
+ ScanInstance .setFileManager (FileMgr);
182
+ ScanInstance .createSourceManager (*FileMgr);
182
183
183
184
llvm::StringSet<> PrebuiltModulesInputFiles;
184
185
// Store the list of prebuilt module files into header search options. This
185
186
// will prevent the implicit build to create duplicate modules and will
186
187
// force reuse of the existing prebuilt module files instead.
187
- if (!Compiler .getPreprocessorOpts ().ImplicitPCHInclude .empty ())
188
+ if (!ScanInstance .getPreprocessorOpts ().ImplicitPCHInclude .empty ())
188
189
visitPrebuiltModule (
189
- Compiler .getPreprocessorOpts ().ImplicitPCHInclude , Compiler ,
190
- Compiler .getHeaderSearchOpts ().PrebuiltModuleFiles ,
190
+ ScanInstance .getPreprocessorOpts ().ImplicitPCHInclude , ScanInstance ,
191
+ ScanInstance .getHeaderSearchOpts ().PrebuiltModuleFiles ,
191
192
PrebuiltModulesInputFiles, /* VisitInputFiles=*/ DepFS != nullptr );
192
193
193
194
// Use the dependency scanning optimized file system if requested to do so.
194
195
if (DepFS) {
195
- const CompilerInvocation &CI = Compiler.getInvocation ();
196
196
DepFS->clearIgnoredFiles ();
197
197
// Ignore any files that contributed to prebuilt modules. The implicit
198
198
// build validates the modules by comparing the reported sizes of their
@@ -203,20 +203,20 @@ class DependencyScanningAction : public tooling::ToolAction {
203
203
// Add any filenames that were explicity passed in the build settings and
204
204
// that might be opened, as we want to ensure we don't run source
205
205
// minimization on them.
206
- for (const auto &Entry : CI .getHeaderSearchOpts ().UserEntries )
207
- DepFS->ignoreFile (Entry .Path );
208
- for (const auto &Entry : CI .getHeaderSearchOpts ().VFSOverlayFiles )
209
- DepFS->ignoreFile (Entry );
206
+ for (const auto &E : ScanInstance .getHeaderSearchOpts ().UserEntries )
207
+ DepFS->ignoreFile (E .Path );
208
+ for (const auto &F : ScanInstance .getHeaderSearchOpts ().VFSOverlayFiles )
209
+ DepFS->ignoreFile (F );
210
210
211
211
// Support for virtual file system overlays on top of the caching
212
212
// filesystem.
213
213
FileMgr->setVirtualFileSystem (createVFSFromCompilerInvocation (
214
- CI, Compiler .getDiagnostics (), DepFS));
214
+ ScanInstance. getInvocation (), ScanInstance .getDiagnostics (), DepFS));
215
215
216
216
// Pass the skip mappings which should speed up excluded conditional block
217
217
// skipping in the preprocessor.
218
218
if (PPSkipMappings)
219
- Compiler .getPreprocessorOpts ()
219
+ ScanInstance .getPreprocessorOpts ()
220
220
.ExcludedConditionalDirectiveSkipMappings = PPSkipMappings;
221
221
}
222
222
@@ -228,24 +228,25 @@ class DependencyScanningAction : public tooling::ToolAction {
228
228
// which ensures that the compiler won't create new dependency collectors,
229
229
// and thus won't write out the extra '.d' files to disk.
230
230
auto Opts = std::make_unique<DependencyOutputOptions>();
231
- std::swap (*Opts, Compiler .getInvocation ().getDependencyOutputOpts ());
231
+ std::swap (*Opts, ScanInstance .getInvocation ().getDependencyOutputOpts ());
232
232
// We need at least one -MT equivalent for the generator of make dependency
233
233
// files to work.
234
234
if (Opts->Targets .empty ())
235
- Opts->Targets = {deduceDepTarget (Compiler.getFrontendOpts ().OutputFile ,
236
- Compiler.getFrontendOpts ().Inputs )};
235
+ Opts->Targets = {
236
+ deduceDepTarget (ScanInstance.getFrontendOpts ().OutputFile ,
237
+ ScanInstance.getFrontendOpts ().Inputs )};
237
238
Opts->IncludeSystemHeaders = true ;
238
239
239
240
switch (Format) {
240
241
case ScanningOutputFormat::Make:
241
- Compiler .addDependencyCollector (
242
+ ScanInstance .addDependencyCollector (
242
243
std::make_shared<DependencyConsumerForwarder>(std::move (Opts),
243
244
Consumer));
244
245
break ;
245
246
case ScanningOutputFormat::Full:
246
- Compiler .addDependencyCollector (std::make_shared<ModuleDepCollector>(
247
- std::move (Opts), Compiler , Consumer, std::move (OriginalInvocation) ,
248
- OptimizeArgs));
247
+ ScanInstance .addDependencyCollector (std::make_shared<ModuleDepCollector>(
248
+ std::move (Opts), ScanInstance , Consumer,
249
+ std::move (OriginalInvocation), OptimizeArgs));
249
250
break ;
250
251
}
251
252
@@ -254,7 +255,7 @@ class DependencyScanningAction : public tooling::ToolAction {
254
255
//
255
256
// TODO: Implement diagnostic bucketing to reduce the impact of strict
256
257
// context hashing.
257
- Compiler .getHeaderSearchOpts ().ModulesStrictContextHash = true ;
258
+ ScanInstance .getHeaderSearchOpts ().ModulesStrictContextHash = true ;
258
259
259
260
std::unique_ptr<FrontendAction> Action;
260
261
@@ -263,7 +264,7 @@ class DependencyScanningAction : public tooling::ToolAction {
263
264
else
264
265
Action = std::make_unique<ReadPCHAndPreprocessAction>();
265
266
266
- const bool Result = Compiler .ExecuteAction (*Action);
267
+ const bool Result = ScanInstance .ExecuteAction (*Action);
267
268
if (!DepFS)
268
269
FileMgr->clearStatCache ();
269
270
return Result;
0 commit comments