[cfe-commits] r145738 - /cfe/trunk/lib/Serialization/ASTWriter.cpp

Douglas Gregor dgregor at apple.com
Fri Dec 2 17:15:29 PST 2011


Author: dgregor
Date: Fri Dec  2 19:15:29 2011
New Revision: 145738

URL: http://llvm.org/viewvc/llvm-project?rev=145738&view=rev
Log:
Module files representing actual modules don't need to know the set of modules they import, since that information isn't actually used. Drop it from the AST file


Modified:
    cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=145738&r1=145737&r2=145738&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Fri Dec  2 19:15:29 2011
@@ -3335,25 +3335,26 @@
        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();





More information about the cfe-commits mailing list