On Tue, Aug 11, 2015 at 4:57 AM, Manuel Klimek <kli...@google.com> wrote:
> I believe this breaks -fno-module-file-deps. > I don't think so; this affects which module map files end up in the .d file, not which .pcm files do. > On Sun, Aug 9, 2015 at 6:47 AM Richard Smith via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: rsmith >> Date: Sat Aug 8 23:46:57 2015 >> New Revision: 244413 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=244413&view=rev >> Log: >> [modules] When building a dependency file, include module maps parsed in >> the >> current compilation, not just those from imported modules. >> >> Modified: >> cfe/trunk/include/clang/Lex/ModuleMap.h >> cfe/trunk/lib/Frontend/DependencyFile.cpp >> cfe/trunk/lib/Lex/ModuleMap.cpp >> cfe/trunk/test/Modules/dependency-gen-pch.m >> cfe/trunk/test/Modules/dependency-gen.m >> cfe/trunk/test/Modules/dependency-gen.modulemap >> cfe/trunk/test/Modules/relative-dep-gen.cpp >> >> Modified: cfe/trunk/include/clang/Lex/ModuleMap.h >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=244413&r1=244412&r2=244413&view=diff >> >> ============================================================================== >> --- cfe/trunk/include/clang/Lex/ModuleMap.h (original) >> +++ cfe/trunk/include/clang/Lex/ModuleMap.h Sat Aug 8 23:46:57 2015 >> @@ -35,6 +35,22 @@ class DiagnosticConsumer; >> class DiagnosticsEngine; >> class HeaderSearch; >> class ModuleMapParser; >> + >> +/// \brief A mechanism to observe the actions of the module map parser >> as it >> +/// reads module map files. >> +class ModuleMapCallbacks { >> +public: >> + virtual ~ModuleMapCallbacks() {} >> + >> + /// \brief Called when a module map file has been read. >> + /// >> + /// \param FileStart A SourceLocation referring to the start of the >> file's >> + /// contents. >> + /// \param File The file itself. >> + /// \param IsSystem Whether this is a module map from a system include >> path. >> + virtual void moduleMapFileRead(SourceLocation FileStart, >> + const FileEntry &File, bool IsSystem) {} >> +}; >> >> class ModuleMap { >> SourceManager &SourceMgr; >> @@ -42,6 +58,8 @@ class ModuleMap { >> const LangOptions &LangOpts; >> const TargetInfo *Target; >> HeaderSearch &HeaderInfo; >> + >> + llvm::SmallVector<std::unique_ptr<ModuleMapCallbacks>, 1> Callbacks; >> >> /// \brief The directory used for Clang-supplied, builtin include >> headers, >> /// such as "stdint.h". >> @@ -263,6 +281,11 @@ public: >> BuiltinIncludeDir = Dir; >> } >> >> + /// \brief Add a module map callback. >> + void addModuleMapCallbacks(std::unique_ptr<ModuleMapCallbacks> >> Callback) { >> + Callbacks.push_back(std::move(Callback)); >> + } >> + >> /// \brief Retrieve the module that owns the given header file, if any. >> /// >> /// \param File The header file that is likely to be included. >> >> Modified: cfe/trunk/lib/Frontend/DependencyFile.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=244413&r1=244412&r2=244413&view=diff >> >> ============================================================================== >> --- cfe/trunk/lib/Frontend/DependencyFile.cpp (original) >> +++ cfe/trunk/lib/Frontend/DependencyFile.cpp Sat Aug 8 23:46:57 2015 >> @@ -18,6 +18,7 @@ >> #include "clang/Frontend/FrontendDiagnostic.h" >> #include "clang/Lex/DirectoryLookup.h" >> #include "clang/Lex/LexDiagnostic.h" >> +#include "clang/Lex/ModuleMap.h" >> #include "clang/Lex/PPCallbacks.h" >> #include "clang/Lex/Preprocessor.h" >> #include "clang/Serialization/ASTReader.h" >> @@ -82,6 +83,20 @@ struct DepCollectorPPCallbacks : public >> } >> }; >> >> +struct DepCollectorMMCallbacks : public ModuleMapCallbacks { >> + DependencyCollector &DepCollector; >> + DepCollectorMMCallbacks(DependencyCollector &DC) : DepCollector(DC) {} >> + >> + void moduleMapFileRead(SourceLocation Loc, const FileEntry &Entry, >> + bool IsSystem) override { >> + StringRef Filename = Entry.getName(); >> + DepCollector.maybeAddDependency(Filename, /*FromModule*/false, >> + /*IsSystem*/IsSystem, >> + /*IsModuleFile*/false, >> + /*IsMissing*/false); >> + } >> +}; >> + >> struct DepCollectorASTListener : public ASTReaderListener { >> DependencyCollector &DepCollector; >> DepCollectorASTListener(DependencyCollector &L) : DepCollector(L) { } >> @@ -132,6 +147,8 @@ DependencyCollector::~DependencyCollecto >> void DependencyCollector::attachToPreprocessor(Preprocessor &PP) { >> PP.addPPCallbacks( >> llvm::make_unique<DepCollectorPPCallbacks>(*this, >> PP.getSourceManager())); >> + PP.getHeaderSearchInfo().getModuleMap().addModuleMapCallbacks( >> + llvm::make_unique<DepCollectorMMCallbacks>(*this)); >> } >> void DependencyCollector::attachToASTReader(ASTReader &R) { >> R.addListener(llvm::make_unique<DepCollectorASTListener>(*this)); >> @@ -185,6 +202,17 @@ public: >> bool includeModuleFiles() const { return IncludeModuleFiles; } >> }; >> >> +class DFGMMCallback : public ModuleMapCallbacks { >> + DFGImpl &Parent; >> +public: >> + DFGMMCallback(DFGImpl &Parent) : Parent(Parent) {} >> + void moduleMapFileRead(SourceLocation Loc, const FileEntry &Entry, >> + bool IsSystem) override { >> + if (!IsSystem || Parent.includeSystemHeaders()) >> + Parent.AddFilename(Entry.getName()); >> + } >> +}; >> + >> class DFGASTReaderListener : public ASTReaderListener { >> DFGImpl &Parent; >> public: >> @@ -217,6 +245,8 @@ DependencyFileGenerator *DependencyFileG >> >> DFGImpl *Callback = new DFGImpl(&PP, Opts); >> PP.addPPCallbacks(std::unique_ptr<PPCallbacks>(Callback)); >> + PP.getHeaderSearchInfo().getModuleMap().addModuleMapCallbacks( >> + llvm::make_unique<DFGMMCallback>(*Callback)); >> return new DependencyFileGenerator(Callback); >> } >> >> >> Modified: cfe/trunk/lib/Lex/ModuleMap.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=244413&r1=244412&r2=244413&view=diff >> >> ============================================================================== >> --- cfe/trunk/lib/Lex/ModuleMap.cpp (original) >> +++ cfe/trunk/lib/Lex/ModuleMap.cpp Sat Aug 8 23:46:57 2015 >> @@ -2335,9 +2335,14 @@ bool ModuleMap::parseModuleMapFile(const >> >> // Parse this module map file. >> Lexer L(ID, SourceMgr.getBuffer(ID), SourceMgr, MMapLangOpts); >> + SourceLocation Start = L.getSourceLocation(); >> ModuleMapParser Parser(L, SourceMgr, Target, Diags, *this, File, Dir, >> BuiltinIncludeDir, IsSystem); >> bool Result = Parser.parseModuleMapFile(); >> ParsedModuleMap[File] = Result; >> + >> + // Notify callbacks that we parsed it. >> + for (const auto &Cb : Callbacks) >> + Cb->moduleMapFileRead(Start, *File, IsSystem); >> return Result; >> } >> >> Modified: cfe/trunk/test/Modules/dependency-gen-pch.m >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-gen-pch.m?rev=244413&r1=244412&r2=244413&view=diff >> >> ============================================================================== >> --- cfe/trunk/test/Modules/dependency-gen-pch.m (original) >> +++ cfe/trunk/test/Modules/dependency-gen-pch.m Sat Aug 8 23:46:57 2015 >> @@ -6,8 +6,8 @@ >> // RUN: FileCheck %s < %t.d >> // CHECK: dependency-gen-pch.m.o >> // CHECK-NEXT: dependency-gen-pch.m >> +// CHECK-NEXT: Inputs{{.}}module.map >> // CHECK-NEXT: diamond_top.pcm >> // CHECK-NEXT: Inputs{{.}}diamond_top.h >> -// CHECK-NEXT: Inputs{{.}}module.map >> >> #import "diamond_top.h" >> >> Modified: cfe/trunk/test/Modules/dependency-gen.m >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-gen.m?rev=244413&r1=244412&r2=244413&view=diff >> >> ============================================================================== >> --- cfe/trunk/test/Modules/dependency-gen.m (original) >> +++ cfe/trunk/test/Modules/dependency-gen.m Sat Aug 8 23:46:57 2015 >> @@ -4,8 +4,8 @@ >> // RUN: %clang_cc1 -x objective-c -isystem %S/Inputs/System/usr/include >> -dependency-file %t.d.1 -MT %s.o -I %S/Inputs -fsyntax-only -fmodules >> -fimplicit-module-maps -fmodules-cache-path=%t-mcp %s >> // RUN: FileCheck %s < %t.d.1 >> // CHECK: dependency-gen.m >> -// CHECK: Inputs{{.}}diamond_top.h >> // CHECK: Inputs{{.}}module.map >> +// CHECK: Inputs{{.}}diamond_top.h >> // CHECK-NOT: usr{{.}}include{{.}}module.map >> // CHECK-NOT: stdint.h >> >> @@ -13,8 +13,8 @@ >> // RUN: %clang_cc1 -x objective-c -isystem %S/Inputs/System/usr/include >> -dependency-file %t.d.2 -MT %s.o -I %S/Inputs -sys-header-deps >> -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-mcp >> %s >> // RUN: FileCheck %s -check-prefix=CHECK-SYS < %t.d.2 >> // CHECK-SYS: dependency-gen.m >> -// CHECK-SYS: Inputs{{.}}diamond_top.h >> // CHECK-SYS: Inputs{{.}}module.map >> +// CHECK-SYS: Inputs{{.}}diamond_top.h >> // CHECK-SYS: usr{{.}}include{{.}}module.map >> // CHECK-SYS: stdint.h >> >> >> Modified: cfe/trunk/test/Modules/dependency-gen.modulemap >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-gen.modulemap?rev=244413&r1=244412&r2=244413&view=diff >> >> ============================================================================== >> --- cfe/trunk/test/Modules/dependency-gen.modulemap (original) >> +++ cfe/trunk/test/Modules/dependency-gen.modulemap Sat Aug 8 23:46:57 >> 2015 >> @@ -15,5 +15,10 @@ module "test" { >> extern module "test-base2" "Inputs/dependency-gen-base2.modulemap" >> extern module "test-base" "Inputs/dependency-gen-base.modulemap" >> >> -// CHECK: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-included2.h >> -// CHECK: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-base.modulemap >> +// CHECK-DAG: {{[/\\]}}dependency-gen.modulemap >> +// CHECK-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-base.modulemap >> +// CHECK-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-base2.modulemap >> + >> +// CHECK-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen.h >> +// CHECK-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-included.h >> +// CHECK-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-included2.h >> >> Modified: cfe/trunk/test/Modules/relative-dep-gen.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/relative-dep-gen.cpp?rev=244413&r1=244412&r2=244413&view=diff >> >> ============================================================================== >> --- cfe/trunk/test/Modules/relative-dep-gen.cpp (original) >> +++ cfe/trunk/test/Modules/relative-dep-gen.cpp Sat Aug 8 23:46:57 2015 >> @@ -20,5 +20,11 @@ >> >> #include "Inputs/relative-dep-gen-1.h" >> >> -// CHECK-BUILD: mod.pcm: Inputs/relative-dep-gen-1.h >> Inputs/relative-dep-gen-2.h >> -// CHECK-USE: use.o: relative-dep-gen.cpp Inputs/relative-dep-gen-1.h >> +// CHECK-BUILD: mod.pcm: >> +// CHECK-BUILD: Inputs/relative-dep-gen{{(-cwd)?}}.modulemap >> +// CHECK-BUILD: Inputs/relative-dep-gen-1.h >> +// CHECK-BUILD: Inputs/relative-dep-gen-2.h >> +// CHECK-USE: use.o: >> +// CHECK-USE: Inputs/relative-dep-gen{{(-cwd)?}}.modulemap >> +// CHECK-USE: relative-dep-gen.cpp >> +// CHECK-USE: Inputs/relative-dep-gen-1.h >> >> >> _______________________________________________ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >> >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits