]> granicus.if.org Git - clang/commitdiff
Module files representing actual modules don't need to know the set of modules they...
authorDouglas Gregor <dgregor@apple.com>
Sat, 3 Dec 2011 01:15:29 +0000 (01:15 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sat, 3 Dec 2011 01:15:29 +0000 (01:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145738 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ASTWriter.cpp

index 15db7050e982a465057ab4bcee9db03a609d8498..b6198184cca92f0c770904d4c1a26d3d161d46ec 100644 (file)
@@ -3335,25 +3335,26 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
        I != E; ++I)
     WriteDeclContextVisibleUpdate(*I);
 
-  // Write the submodules that were imported, if any.
-  RecordData ImportedModules;
-  for (ASTContext::import_iterator I = Context.local_import_begin(),
-                                IEnd = Context.local_import_end();
-       I != IEnd; ++I) {
-    assert(SubmoduleIDs.find(I->getImportedModule()) != SubmoduleIDs.end());
-    ImportedModules.push_back(SubmoduleIDs[I->getImportedModule()]);
-  }
-  if (!ImportedModules.empty()) {
-    // Sort module IDs.
-    llvm::array_pod_sort(ImportedModules.begin(), ImportedModules.end());
-    
-    // Unique module IDs.
-    ImportedModules.erase(std::unique(ImportedModules.begin(), 
-                                      ImportedModules.end()),
-                          ImportedModules.end());
-    
-    Stream.EmitRecord(IMPORTED_MODULES, ImportedModules);
-    ImportedModules.clear();
+  if (!WritingModule) {
+    // Write the submodules that were imported, if any.
+    RecordData ImportedModules;
+    for (ASTContext::import_iterator I = Context.local_import_begin(),
+                                  IEnd = Context.local_import_end();
+         I != IEnd; ++I) {
+      assert(SubmoduleIDs.find(I->getImportedModule()) != SubmoduleIDs.end());
+      ImportedModules.push_back(SubmoduleIDs[I->getImportedModule()]);
+    }
+    if (!ImportedModules.empty()) {
+      // Sort module IDs.
+      llvm::array_pod_sort(ImportedModules.begin(), ImportedModules.end());
+      
+      // Unique module IDs.
+      ImportedModules.erase(std::unique(ImportedModules.begin(), 
+                                        ImportedModules.end()),
+                            ImportedModules.end());
+      
+      Stream.EmitRecord(IMPORTED_MODULES, ImportedModules);
+    }
   }
   
   WriteDeclUpdatesBlocks();