From 8d9eb7acd548d592b9cf5775a00a6db2ee6933dd Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Wed, 19 Jun 2019 17:07:36 +0000 Subject: Unify DependencyFileGenerator class and DependencyCollector interface (NFCI) Make DependencyFileGenerator a DependencyCollector as it was intended when DependencyCollector was introduced. The missing PPCallbacks overrides are added to the DependencyCollector as well. This change will allow clang-scan-deps to access the produced dependencies without writing them out to .d files to disk, so that it will be able collate them and report them to the user. Differential Revision: https://reviews.llvm.org/D63290 llvm-svn: 363840 --- clang/lib/Frontend/CompilerInstance.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'clang/lib/Frontend/CompilerInstance.cpp') diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index fd33b85b31d..9cbc9ed1f79 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -415,8 +415,7 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) { // Handle generating dependencies, if requested. const DependencyOutputOptions &DepOpts = getDependencyOutputOpts(); if (!DepOpts.OutputFile.empty()) - TheDependencyFileGenerator.reset( - DependencyFileGenerator::CreateAndAttachToPreprocessor(*PP, DepOpts)); + addDependencyCollector(std::make_shared(DepOpts)); if (!DepOpts.DOTOutputFile.empty()) AttachDependencyGraphGen(*PP, DepOpts.DOTOutputFile, getHeaderSearchOpts().Sysroot); @@ -490,9 +489,9 @@ void CompilerInstance::createPCHExternalASTSource( Path, getHeaderSearchOpts().Sysroot, DisablePCHValidation, AllowPCHWithCompilerErrors, getPreprocessor(), getModuleCache(), getASTContext(), getPCHContainerReader(), - getFrontendOpts().ModuleFileExtensions, TheDependencyFileGenerator.get(), - DependencyCollectors, DeserializationListener, OwnDeserializationListener, - Preamble, getFrontendOpts().UseGlobalModuleIndex); + getFrontendOpts().ModuleFileExtensions, DependencyCollectors, + DeserializationListener, OwnDeserializationListener, Preamble, + getFrontendOpts().UseGlobalModuleIndex); } IntrusiveRefCntPtr CompilerInstance::createPCHExternalASTSource( @@ -501,7 +500,6 @@ IntrusiveRefCntPtr CompilerInstance::createPCHExternalASTSource( InMemoryModuleCache &ModuleCache, ASTContext &Context, const PCHContainerReader &PCHContainerRdr, ArrayRef> Extensions, - DependencyFileGenerator *DependencyFile, ArrayRef> DependencyCollectors, void *DeserializationListener, bool OwnDeserializationListener, bool Preamble, bool UseGlobalModuleIndex) { @@ -521,8 +519,6 @@ IntrusiveRefCntPtr CompilerInstance::createPCHExternalASTSource( static_cast(DeserializationListener), /*TakeOwnership=*/OwnDeserializationListener); - if (DependencyFile) - DependencyFile->AttachToASTReader(*Reader); for (auto &Listener : DependencyCollectors) Listener->attachToASTReader(*Reader); @@ -1492,8 +1488,6 @@ void CompilerInstance::createModuleManager() { if (hasASTConsumer()) ModuleManager->StartTranslationUnit(&getASTConsumer()); - if (TheDependencyFileGenerator) - TheDependencyFileGenerator->AttachToASTReader(*ModuleManager); for (auto &Listener : DependencyCollectors) Listener->attachToASTReader(*ModuleManager); } -- cgit v1.2.3