]> granicus.if.org Git - clang/commitdiff
[Modules] Add imported modules to the output of -module-file-info
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Tue, 11 Sep 2018 05:17:13 +0000 (05:17 +0000)
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Tue, 11 Sep 2018 05:17:13 +0000 (05:17 +0000)
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

include/clang/Serialization/ASTReader.h
lib/Frontend/FrontendActions.cpp
lib/Serialization/ASTReader.cpp
test/Modules/module_file_info.m

index 1efadc74352827a4d80ab298400ca684785efe8c..98f8f5af48655afced6d2d636c20e9a975a1bcd0 100644 (file)
@@ -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(
index 342081eba672ebce75d0c878ae27f6eccf2342d5..40008bf3cdda442d53bdc95e762d5884eff5b942 100644 (file)
@@ -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
   };
 }
index a9acf4e2f4f128032d5a470cb8ffc1811e7464a9..b60e5f14a6769783b472664e5536de53bf37b04a 100644 (file)
@@ -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;
     }
index 05d401b9450a16acbe0c47e0467b0ca9dfb6d187..64ed2be2d85a82c93b0fe85c4a94b22b290677a4 100644 (file)
@@ -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