Index: cfe/trunk/include/clang/Frontend/CompilerInstance.h =================================================================== --- cfe/trunk/include/clang/Frontend/CompilerInstance.h +++ cfe/trunk/include/clang/Frontend/CompilerInstance.h @@ -662,6 +662,8 @@ bool AllowPCHWithCompilerErrors, Preprocessor &PP, ASTContext &Context, const PCHContainerReader &PCHContainerRdr, ArrayRef> Extensions, + DependencyFileGenerator *DependencyFile, + ArrayRef> DependencyCollectors, void *DeserializationListener, bool OwnDeserializationListener, bool Preamble, bool UseGlobalModuleIndex); Index: cfe/trunk/lib/Frontend/CompilerInstance.cpp =================================================================== --- cfe/trunk/lib/Frontend/CompilerInstance.cpp +++ cfe/trunk/lib/Frontend/CompilerInstance.cpp @@ -497,6 +497,8 @@ AllowPCHWithCompilerErrors, getPreprocessor(), getASTContext(), getPCHContainerReader(), getFrontendOpts().ModuleFileExtensions, + TheDependencyFileGenerator.get(), + DependencyCollectors, DeserializationListener, OwnDeserializationListener, Preamble, getFrontendOpts().UseGlobalModuleIndex); @@ -507,6 +509,8 @@ bool AllowPCHWithCompilerErrors, Preprocessor &PP, ASTContext &Context, const PCHContainerReader &PCHContainerRdr, ArrayRef> Extensions, + DependencyFileGenerator *DependencyFile, + ArrayRef> DependencyCollectors, void *DeserializationListener, bool OwnDeserializationListener, bool Preamble, bool UseGlobalModuleIndex) { HeaderSearchOptions &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts(); @@ -524,6 +528,12 @@ Reader->setDeserializationListener( static_cast(DeserializationListener), /*TakeOwnership=*/OwnDeserializationListener); + + if (DependencyFile) + DependencyFile->AttachToASTReader(*Reader); + for (auto &Listener : DependencyCollectors) + Listener->attachToASTReader(*Reader); + switch (Reader->ReadAST(Path, Preamble ? serialization::MK_Preamble : serialization::MK_PCH, Index: cfe/trunk/test/PCH/emit-dependencies.c =================================================================== --- cfe/trunk/test/PCH/emit-dependencies.c +++ cfe/trunk/test/PCH/emit-dependencies.c @@ -0,0 +1,9 @@ +// RUN: rm -f %t.pch +// RUN: %clang_cc1 -emit-pch -o %t.pch %S/Inputs/chain-decls1.h +// RUN: %clang_cc1 -include-pch %t.pch -fsyntax-only -MT %s.o -dependency-file - %s | FileCheck %s +// CHECK: Inputs/chain-decls1.h + +int main() { + f(); + return 0; +}