CompilerInvocation OriginalInvocation(*Invocation);
// Create a compiler instance to handle the actual work.
- CompilerInstance Compiler(std::move(PCHContainerOps));
- Compiler.setInvocation(std::move(Invocation));
+ CompilerInstance ScanInstance(std::move(PCHContainerOps));
+ ScanInstance.setInvocation(std::move(Invocation));
// Create the compiler's actual diagnostics engine.
- sanitizeDiagOpts(Compiler.getDiagnosticOpts());
- Compiler.createDiagnostics(DiagConsumer, /*ShouldOwnClient=*/false);
- if (!Compiler.hasDiagnostics())
+ sanitizeDiagOpts(ScanInstance.getDiagnosticOpts());
+ ScanInstance.createDiagnostics(DiagConsumer, /*ShouldOwnClient=*/false);
+ if (!ScanInstance.hasDiagnostics())
return false;
- Compiler.getPreprocessorOpts().AllowPCHWithDifferentModulesCachePath = true;
+ ScanInstance.getPreprocessorOpts().AllowPCHWithDifferentModulesCachePath =
+ true;
FileMgr->getFileSystemOpts().WorkingDir = std::string(WorkingDirectory);
- Compiler.setFileManager(FileMgr);
- Compiler.createSourceManager(*FileMgr);
+ ScanInstance.setFileManager(FileMgr);
+ ScanInstance.createSourceManager(*FileMgr);
llvm::StringSet<> PrebuiltModulesInputFiles;
// Store the list of prebuilt module files into header search options. This
// will prevent the implicit build to create duplicate modules and will
// force reuse of the existing prebuilt module files instead.
- if (!Compiler.getPreprocessorOpts().ImplicitPCHInclude.empty())
+ if (!ScanInstance.getPreprocessorOpts().ImplicitPCHInclude.empty())
visitPrebuiltModule(
- Compiler.getPreprocessorOpts().ImplicitPCHInclude, Compiler,
- Compiler.getHeaderSearchOpts().PrebuiltModuleFiles,
+ ScanInstance.getPreprocessorOpts().ImplicitPCHInclude, ScanInstance,
+ ScanInstance.getHeaderSearchOpts().PrebuiltModuleFiles,
PrebuiltModulesInputFiles, /*VisitInputFiles=*/DepFS != nullptr);
// Use the dependency scanning optimized file system if requested to do so.
if (DepFS) {
- const CompilerInvocation &CI = Compiler.getInvocation();
DepFS->clearIgnoredFiles();
// Ignore any files that contributed to prebuilt modules. The implicit
// build validates the modules by comparing the reported sizes of their
// Add any filenames that were explicity passed in the build settings and
// that might be opened, as we want to ensure we don't run source
// minimization on them.
- for (const auto &Entry : CI.getHeaderSearchOpts().UserEntries)
- DepFS->ignoreFile(Entry.Path);
- for (const auto &Entry : CI.getHeaderSearchOpts().VFSOverlayFiles)
- DepFS->ignoreFile(Entry);
+ for (const auto &E : ScanInstance.getHeaderSearchOpts().UserEntries)
+ DepFS->ignoreFile(E.Path);
+ for (const auto &F : ScanInstance.getHeaderSearchOpts().VFSOverlayFiles)
+ DepFS->ignoreFile(F);
// Support for virtual file system overlays on top of the caching
// filesystem.
FileMgr->setVirtualFileSystem(createVFSFromCompilerInvocation(
- CI, Compiler.getDiagnostics(), DepFS));
+ ScanInstance.getInvocation(), ScanInstance.getDiagnostics(), DepFS));
// Pass the skip mappings which should speed up excluded conditional block
// skipping in the preprocessor.
if (PPSkipMappings)
- Compiler.getPreprocessorOpts()
+ ScanInstance.getPreprocessorOpts()
.ExcludedConditionalDirectiveSkipMappings = PPSkipMappings;
}
// which ensures that the compiler won't create new dependency collectors,
// and thus won't write out the extra '.d' files to disk.
auto Opts = std::make_unique<DependencyOutputOptions>();
- std::swap(*Opts, Compiler.getInvocation().getDependencyOutputOpts());
+ std::swap(*Opts, ScanInstance.getInvocation().getDependencyOutputOpts());
// We need at least one -MT equivalent for the generator of make dependency
// files to work.
if (Opts->Targets.empty())
- Opts->Targets = {deduceDepTarget(Compiler.getFrontendOpts().OutputFile,
- Compiler.getFrontendOpts().Inputs)};
+ Opts->Targets = {
+ deduceDepTarget(ScanInstance.getFrontendOpts().OutputFile,
+ ScanInstance.getFrontendOpts().Inputs)};
Opts->IncludeSystemHeaders = true;
switch (Format) {
case ScanningOutputFormat::Make:
- Compiler.addDependencyCollector(
+ ScanInstance.addDependencyCollector(
std::make_shared<DependencyConsumerForwarder>(std::move(Opts),
Consumer));
break;
case ScanningOutputFormat::Full:
- Compiler.addDependencyCollector(std::make_shared<ModuleDepCollector>(
- std::move(Opts), Compiler, Consumer, std::move(OriginalInvocation),
- OptimizeArgs));
+ ScanInstance.addDependencyCollector(std::make_shared<ModuleDepCollector>(
+ std::move(Opts), ScanInstance, Consumer,
+ std::move(OriginalInvocation), OptimizeArgs));
break;
}
//
// TODO: Implement diagnostic bucketing to reduce the impact of strict
// context hashing.
- Compiler.getHeaderSearchOpts().ModulesStrictContextHash = true;
+ ScanInstance.getHeaderSearchOpts().ModulesStrictContextHash = true;
std::unique_ptr<FrontendAction> Action;
else
Action = std::make_unique<ReadPCHAndPreprocessAction>();
- const bool Result = Compiler.ExecuteAction(*Action);
+ const bool Result = ScanInstance.ExecuteAction(*Action);
if (!DepFS)
FileMgr->clearStatCache();
return Result;
FileID PrevFID) {
if (Reason != PPCallbacks::EnterFile)
return;
-
+
// This has to be delayed as the context hash can change at the start of
// `CompilerInstance::ExecuteAction`.
if (MDC.ContextHash.empty()) {
- MDC.ContextHash = MDC.Instance.getInvocation().getModuleHash();
+ MDC.ContextHash = MDC.ScanInstance.getInvocation().getModuleHash();
MDC.Consumer.handleContextHash(MDC.ContextHash);
}
- SourceManager &SM = MDC.Instance.getSourceManager();
+ SourceManager &SM = MDC.ScanInstance.getSourceManager();
// Dependency generation really does want to go all the way to the
// file entry for a source location to find out what is depended on.
}
void ModuleDepCollectorPP::EndOfMainFile() {
- FileID MainFileID = MDC.Instance.getSourceManager().getMainFileID();
- MDC.MainFile = std::string(
- MDC.Instance.getSourceManager().getFileEntryForID(MainFileID)->getName());
+ FileID MainFileID = MDC.ScanInstance.getSourceManager().getMainFileID();
+ MDC.MainFile = std::string(MDC.ScanInstance.getSourceManager()
+ .getFileEntryForID(MainFileID)
+ ->getName());
- if (!MDC.Instance.getPreprocessorOpts().ImplicitPCHInclude.empty())
+ if (!MDC.ScanInstance.getPreprocessorOpts().ImplicitPCHInclude.empty())
MDC.FileDeps.push_back(
- MDC.Instance.getPreprocessorOpts().ImplicitPCHInclude);
+ MDC.ScanInstance.getPreprocessorOpts().ImplicitPCHInclude);
for (const Module *M : DirectModularDeps) {
// A top-level module might not be actually imported as a module when
MD.ImplicitModulePCMPath = std::string(M->getASTFile()->getName());
MD.IsSystem = M->IsSystem;
- const FileEntry *ModuleMap = MDC.Instance.getPreprocessor()
+ const FileEntry *ModuleMap = MDC.ScanInstance.getPreprocessor()
.getHeaderSearchInfo()
.getModuleMap()
.getModuleMapFileForUniquing(M);
MD.ClangModuleMapFile = std::string(ModuleMap ? ModuleMap->getName() : "");
serialization::ModuleFile *MF =
- MDC.Instance.getASTReader()->getModuleManager().lookup(M->getASTFile());
- MDC.Instance.getASTReader()->visitInputFiles(
+ MDC.ScanInstance.getASTReader()->getModuleManager().lookup(
+ M->getASTFile());
+ MDC.ScanInstance.getASTReader()->visitInputFiles(
*MF, true, true, [&](const serialization::InputFile &IF, bool isSystem) {
// __inferred_module.map is the result of the way in which an implicit
// module build handles inferred modules. It adds an overlay VFS with
MD, [&](CompilerInvocation &CI) {
if (MDC.OptimizeArgs)
optimizeHeaderSearchOpts(CI.getHeaderSearchOpts(),
- *MDC.Instance.getASTReader(), *MF);
+ *MDC.ScanInstance.getASTReader(), *MF);
});
MD.ID.ContextHash = MD.Invocation.getModuleHash();
}
ModuleDepCollector::ModuleDepCollector(
- std::unique_ptr<DependencyOutputOptions> Opts, CompilerInstance &I,
- DependencyConsumer &C, CompilerInvocation &&OriginalCI, bool OptimizeArgs)
- : Instance(I), Consumer(C), Opts(std::move(Opts)),
+ std::unique_ptr<DependencyOutputOptions> Opts,
+ CompilerInstance &ScanInstance, DependencyConsumer &C,
+ CompilerInvocation &&OriginalCI, bool OptimizeArgs)
+ : ScanInstance(ScanInstance), Consumer(C), Opts(std::move(Opts)),
OriginalInvocation(std::move(OriginalCI)), OptimizeArgs(OptimizeArgs) {}
void ModuleDepCollector::attachToPreprocessor(Preprocessor &PP) {
bool ModuleDepCollector::isPrebuiltModule(const Module *M) {
std::string Name(M->getTopLevelModuleName());
const auto &PrebuiltModuleFiles =
- Instance.getHeaderSearchOpts().PrebuiltModuleFiles;
+ ScanInstance.getHeaderSearchOpts().PrebuiltModuleFiles;
auto PrebuiltModuleFileIt = PrebuiltModuleFiles.find(Name);
if (PrebuiltModuleFileIt == PrebuiltModuleFiles.end())
return false;