Author: rsmith Date: Thu Aug 13 12:57:10 2015 New Revision: 244923 URL: http://llvm.org/viewvc/llvm-project?rev=244923&view=rev Log: [modules] Change the way we deal with .d output for explicitly-specified module files: include the .pcm file itself in the .d output, rather than including its own input files. Other forms of module file continue to be transparent for .d output.
Arguably, the input files for the .pcm file are still inputs to the compilation, but that's unnecessary for make-like build systems (where the mtime of the .pcm file is sufficient) and harmful for smarter build systems that know about module files and want to track only the local dependencies. Modified: cfe/trunk/include/clang/Serialization/ASTReader.h cfe/trunk/lib/Frontend/DependencyFile.cpp cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/test/Modules/dependency-gen.modulemap Modified: cfe/trunk/include/clang/Serialization/ASTReader.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=244923&r1=244922&r2=244923&view=diff ============================================================================== --- cfe/trunk/include/clang/Serialization/ASTReader.h (original) +++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Aug 13 12:57:10 2015 @@ -179,7 +179,8 @@ public: unsigned Value) {} /// This is called for each AST file loaded. - virtual void visitModuleFile(StringRef Filename) {} + virtual void visitModuleFile(StringRef Filename, + serialization::ModuleKind Kind) {} /// \brief Returns true if this \c ASTReaderListener wants to receive the /// input files of the AST file via \c visitInputFile, false otherwise. @@ -194,7 +195,7 @@ public: /// /// \returns true to continue receiving the next input file, false to stop. virtual bool visitInputFile(StringRef Filename, bool isSystem, - bool isOverridden) { + bool isOverridden, bool isExplicitModule) { return true; } @@ -242,9 +243,10 @@ public: void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override; bool needsInputFileVisitation() override; bool needsSystemInputFileVisitation() override; - void visitModuleFile(StringRef Filename) override; + void visitModuleFile(StringRef Filename, + serialization::ModuleKind Kind) override; bool visitInputFile(StringRef Filename, bool isSystem, - bool isOverridden) override; + bool isOverridden, bool isExplicitModule) override; }; /// \brief ASTReaderListener implementation to validate the information of Modified: cfe/trunk/lib/Frontend/DependencyFile.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=244923&r1=244922&r2=244923&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/DependencyFile.cpp (original) +++ cfe/trunk/lib/Frontend/DependencyFile.cpp Thu Aug 13 12:57:10 2015 @@ -104,14 +104,15 @@ struct DepCollectorASTListener : public bool needsSystemInputFileVisitation() override { return DepCollector.needSystemDependencies(); } - void visitModuleFile(StringRef Filename) override { + void visitModuleFile(StringRef Filename, + serialization::ModuleKind Kind) override { DepCollector.maybeAddDependency(Filename, /*FromModule*/true, /*IsSystem*/false, /*IsModuleFile*/true, /*IsMissing*/false); } bool visitInputFile(StringRef Filename, bool IsSystem, - bool IsOverridden) override { - if (IsOverridden) + bool IsOverridden, bool IsExplicitModule) override { + if (IsOverridden || IsExplicitModule) return true; DepCollector.maybeAddDependency(Filename, /*FromModule*/true, IsSystem, @@ -226,9 +227,10 @@ public: bool needsSystemInputFileVisitation() override { return Parent.includeSystemHeaders(); } - void visitModuleFile(StringRef Filename) override; + void visitModuleFile(StringRef Filename, + serialization::ModuleKind Kind) override; bool visitInputFile(StringRef Filename, bool isSystem, - bool isOverridden) override; + bool isOverridden, bool isExplicitModule) override; }; } @@ -472,16 +474,18 @@ void DFGImpl::OutputDependencyFile() { } bool DFGASTReaderListener::visitInputFile(llvm::StringRef Filename, - bool IsSystem, bool IsOverridden) { + bool IsSystem, bool IsOverridden, + bool IsExplicitModule) { assert(!IsSystem || needsSystemInputFileVisitation()); - if (IsOverridden) + if (IsOverridden || IsExplicitModule) return true; Parent.AddFilename(Filename); return true; } -void DFGASTReaderListener::visitModuleFile(llvm::StringRef Filename) { - if (Parent.includeModuleFiles()) +void DFGASTReaderListener::visitModuleFile(llvm::StringRef Filename, + serialization::ModuleKind Kind) { + if (Parent.includeModuleFiles() || Kind == MK_ExplicitModule) Parent.AddFilename(Filename); } Modified: cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp?rev=244923&r1=244922&r2=244923&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp (original) +++ cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp Thu Aug 13 12:57:10 2015 @@ -32,8 +32,8 @@ public: : Collector(Collector) {} bool needsInputFileVisitation() override { return true; } bool needsSystemInputFileVisitation() override { return true; } - bool visitInputFile(StringRef Filename, bool IsSystem, - bool IsOverridden) override; + bool visitInputFile(StringRef Filename, bool IsSystem, bool IsOverridden, + bool IsExplicitModule) override; }; } @@ -85,7 +85,8 @@ std::error_code ModuleDependencyListener } bool ModuleDependencyListener::visitInputFile(StringRef Filename, bool IsSystem, - bool IsOverridden) { + bool IsOverridden, + bool IsExplicitModule) { if (Collector.insertSeen(Filename)) if (copyToRoot(Filename)) Collector.setHasErrors(); Modified: cfe/trunk/lib/Serialization/ASTReader.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=244923&r1=244922&r2=244923&view=diff ============================================================================== --- cfe/trunk/lib/Serialization/ASTReader.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Aug 13 12:57:10 2015 @@ -138,20 +138,24 @@ bool ChainedASTReaderListener::needsSyst return First->needsSystemInputFileVisitation() || Second->needsSystemInputFileVisitation(); } -void ChainedASTReaderListener::visitModuleFile(StringRef Filename) { - First->visitModuleFile(Filename); - Second->visitModuleFile(Filename); +void ChainedASTReaderListener::visitModuleFile(StringRef Filename, + ModuleKind Kind) { + First->visitModuleFile(Filename, Kind); + Second->visitModuleFile(Filename, Kind); } bool ChainedASTReaderListener::visitInputFile(StringRef Filename, bool isSystem, - bool isOverridden) { + bool isOverridden, + bool isExplicitModule) { bool Continue = false; if (First->needsInputFileVisitation() && (!isSystem || First->needsSystemInputFileVisitation())) - Continue |= First->visitInputFile(Filename, isSystem, isOverridden); + Continue |= First->visitInputFile(Filename, isSystem, isOverridden, + isExplicitModule); if (Second->needsInputFileVisitation() && (!isSystem || Second->needsSystemInputFileVisitation())) - Continue |= Second->visitInputFile(Filename, isSystem, isOverridden); + Continue |= Second->visitInputFile(Filename, isSystem, isOverridden, + isExplicitModule); return Continue; } @@ -2106,7 +2110,7 @@ ASTReader::ReadControlBlock(ModuleFile & } if (Listener) - Listener->visitModuleFile(F.FileName); + Listener->visitModuleFile(F.FileName, F.Kind); if (Listener && Listener->needsInputFileVisitation()) { unsigned N = Listener->needsSystemInputFileVisitation() ? NumInputs @@ -2114,7 +2118,8 @@ ASTReader::ReadControlBlock(ModuleFile & for (unsigned I = 0; I < N; ++I) { bool IsSystem = I >= NumUserInputs; InputFileInfo FI = readInputFileInfo(F, I+1); - Listener->visitInputFile(FI.Filename, IsSystem, FI.Overridden); + Listener->visitInputFile(FI.Filename, IsSystem, FI.Overridden, + F.Kind == MK_ExplicitModule); } } @@ -4194,8 +4199,8 @@ bool ASTReader::readASTFileControlBlock( bool Overridden = static_cast<bool>(Record[3]); std::string Filename = Blob; ResolveImportedPath(Filename, ModuleDir); - shouldContinue = - Listener.visitInputFile(Filename, isSystemFile, Overridden); + shouldContinue = Listener.visitInputFile( + Filename, isSystemFile, Overridden, /*IsExplicitModule*/false); break; } if (!shouldContinue) Modified: cfe/trunk/test/Modules/dependency-gen.modulemap URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-gen.modulemap?rev=244923&r1=244922&r2=244923&view=diff ============================================================================== --- cfe/trunk/test/Modules/dependency-gen.modulemap (original) +++ cfe/trunk/test/Modules/dependency-gen.modulemap Thu Aug 13 12:57:10 2015 @@ -1,9 +1,9 @@ // RUN: cd %S // RUN: rm -rf %t // -// RUN: %clang_cc1 -I. -x c++ -fmodule-name=test -fmodules -emit-module -fno-validate-pch -fmodules-strict-decluse %s -dependency-file - -MT implicit.pcm -o %t/implicit.pcm -fmodules-cache-path=%t -fmodule-map-file-home-is-cwd | FileCheck %s --check-prefix=IMPLICIT +// RUN: %clang_cc1 -I. -x c++ -fmodule-name=test -fmodules -emit-module -fno-validate-pch -fmodules-strict-decluse %s -dependency-file - -MT implicit.pcm -o %t/implicit.pcm -fmodules-cache-path=%t -fmodule-map-file-home-is-cwd -fmodule-map-file=%S/Inputs/dependency-gen-base.modulemap | FileCheck %s --check-prefix=IMPLICIT // -// RUN: %clang_cc1 -I. -x c++ -fmodule-name=test-base -fmodules -emit-module -fno-validate-pch -fmodules-strict-decluse Inputs/dependency-gen-base.modulemap -o %t/base.pcm -fmodule-map-file-home-is-cwd +// RUN: %clang_cc1 -I. -x c++ -fmodule-name=test-base -fmodules -emit-module -fno-validate-pch -fmodules-strict-decluse Inputs/dependency-gen-base.modulemap -o %t/base.pcm -fmodule-map-file-home-is-cwd -fmodule-map-file=%S/Inputs/dependency-gen-base.modulemap // RUN: %clang_cc1 -I. -x c++ -fmodule-name=test -fmodules -emit-module -fno-validate-pch -fmodules-strict-decluse -fmodule-file=%t/base.pcm %s -dependency-file - -MT explicit.pcm -o %t/explicit.pcm -fmodules-cache-path=%t -fmodule-map-file-home-is-cwd | FileCheck %s --check-prefix=EXPLICIT module "test" { export * @@ -11,8 +11,6 @@ module "test" { use "test-base" use "test-base2" } -extern module "test-base2" "Inputs/dependency-gen-base2.modulemap" -extern module "test-base" "Inputs/dependency-gen-base.modulemap" // For implicit use of a module via the module cache, the input files // referenced by the .pcm are also dependencies of this build. @@ -28,16 +26,11 @@ extern module "test-base" "Inputs/depend // and included headers are not dependencies of this target (they are instead // dependencies of the explicitly-specified .pcm input). // -// FIXME: We should avoid loading the other referenced module maps (we already -// have a parsed copy of their contents from the .pcm file) and thus not list -// them here. -// -// FIXME: We should list a dependency on the explicitly specified .pcm files -// (whether or not -module-file-deps is specified on the command line). -// -// EXPLICIT-FIXME-NOT: dependency-gen- -// EXPLICIT-FIXME: {{.*}}/base.pcm -// // EXPLICIT: {{^}}explicit.pcm: +// EXPLICIT-NOT: dependency-gen- +// EXPLICIT: base.pcm +// EXPLICIT-NOT: dependency-gen- // EXPLICIT: {{.*[/\\]}}dependency-gen.modulemap +// EXPLICIT-NOT: dependency-gen- // EXPLICIT: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen.h +// EXPLICIT-NOT: dependency-gen- _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits