From c5e0f9b44782204437de21594c1748b1405d90bc Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sat, 3 Dec 2011 01:15:29 +0000 Subject: [PATCH] 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145738 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Serialization/ASTWriter.cpp | 39 +++++++++++++++++---------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 15db7050e9..b6198184cc 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -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(); -- 2.40.0