diff options
author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2018-09-11 05:17:13 +0000 |
---|---|---|
committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2018-09-11 05:17:13 +0000 |
commit | 163e2f16ea8dd6dcced00c115e362c86ab2842df (patch) | |
tree | e3a510284c91c17db63e83522d2098b503b84951 | |
parent | 7e7b13d3b15e5870a86d1ef50b952d6be4e1c178 (diff) |
[Modules] Add imported modules to the output of -module-file-info
Fix a bug in the deserialization of IMPORTS section and allow for
imported modules to also be printed with -module-file-info.
rdar://problem/43867753
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341902 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Serialization/ASTReader.h | 2 | ||||
-rw-r--r-- | lib/Frontend/FrontendActions.cpp | 11 | ||||
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 6 | ||||
-rw-r--r-- | test/Modules/module_file_info.m | 1 |
4 files changed, 16 insertions, 4 deletions
diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index 1efadc7435..98f8f5af48 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -232,7 +232,7 @@ public: /// If needsImportVisitation returns \c true, this is called for each /// AST file imported by this AST file. - virtual void visitImport(StringRef Filename) {} + virtual void visitImport(StringRef ModuleName, StringRef Filename) {} /// Indicates that a particular module file extension has been read. virtual void readModuleFileExtension( diff --git a/lib/Frontend/FrontendActions.cpp b/lib/Frontend/FrontendActions.cpp index 342081eba6..40008bf3cd 100644 --- a/lib/Frontend/FrontendActions.cpp +++ b/lib/Frontend/FrontendActions.cpp @@ -601,6 +601,17 @@ namespace { return true; } + + /// Returns true if this \c ASTReaderListener wants to receive the + /// imports of the AST file via \c visitImport, false otherwise. + bool needsImportVisitation() const override { return true; } + + /// If needsImportVisitation returns \c true, this is called for each + /// AST file imported by this AST file. + void visitImport(StringRef ModuleName, StringRef Filename) override { + Out.indent(2) << "Imports module '" << ModuleName + << "': " << Filename.str() << "\n"; + } #undef DUMP_BOOLEAN }; } diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index a9acf4e2f4..b60e5f14a6 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -4868,11 +4868,11 @@ bool ASTReader::readASTFileControlBlock( unsigned Idx = 0, N = Record.size(); while (Idx < N) { // Read information about the AST file. - Idx += 5; // ImportLoc, Size, ModTime, Signature - SkipString(Record, Idx); // Module name; FIXME: pass to listener? + Idx += 1+1+1+1+5; // Kind, ImportLoc, Size, ModTime, Signature + std::string ModuleName = ReadString(Record, Idx); std::string Filename = ReadString(Record, Idx); ResolveImportedPath(Filename, ModuleDir); - Listener.visitImport(Filename); + Listener.visitImport(ModuleName, Filename); } break; } diff --git a/test/Modules/module_file_info.m b/test/Modules/module_file_info.m index 05d401b945..64ed2be2d8 100644 --- a/test/Modules/module_file_info.m +++ b/test/Modules/module_file_info.m @@ -16,6 +16,7 @@ // CHECK: Module name: DependsOnModule // CHECK: Module map file: {{.*}}DependsOnModule.framework{{[/\\]}}module.map +// CHECK: Imports module 'Module': {{.*}}Module.pcm // CHECK: Language options: // CHECK: C99: Yes |