[cfe-commits] r146445 - in /cfe/trunk/lib/Serialization: ASTWriter.cpp ASTWriterDecl.cpp

Douglas Gregor dgregor at apple.com
Mon Dec 12 15:17:57 PST 2011


Author: dgregor
Date: Mon Dec 12 17:17:57 2011
New Revision: 146445

URL: http://llvm.org/viewvc/llvm-project?rev=146445&view=rev
Log:
Tweak submodule ID handling in the AST writer

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

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=146445&r1=146444&r2=146445&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Mon Dec 12 17:17:57 2011
@@ -1970,7 +1970,7 @@
     if (!Mod->Imports.empty()) {
       Record.clear();
       for (unsigned I = 0, N = Mod->Imports.size(); I != N; ++I) {
-        unsigned ImportedID = SubmoduleIDs[Mod->Imports[I]];
+        unsigned ImportedID = getSubmoduleID(Mod->Imports[I]);
         assert(ImportedID && "Unknown submodule!");                                           
         Record.push_back(ImportedID);
       }
@@ -1981,10 +1981,14 @@
     if (!Mod->Exports.empty()) {
       Record.clear();
       for (unsigned I = 0, N = Mod->Exports.size(); I != N; ++I) {
-        unsigned ExportedID = SubmoduleIDs[Mod->Exports[I].getPointer()];
-        assert((ExportedID || !Mod->Exports[I].getPointer()) &&
-               "Unknown submodule!");                                           
-        Record.push_back(ExportedID);
+        if (Module *Exported = Mod->Exports[I].getPointer()) {
+          unsigned ExportedID = SubmoduleIDs[Exported];
+          assert(ExportedID > 0 && "Unknown submodule ID?");
+          Record.push_back(ExportedID);
+        } else {
+          Record.push_back(0);
+        }
+        
         Record.push_back(Mod->Exports[I].getInt());
       }
       Stream.EmitRecord(SUBMODULE_EXPORTS, Record);

Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=146445&r1=146444&r2=146445&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Mon Dec 12 17:17:57 2011
@@ -976,7 +976,6 @@
 
 void ASTDeclWriter::VisitImportDecl(ImportDecl *D) {
   VisitDecl(D);
-  Writer.SubmoduleIDs[D->getImportedModule()];
   ArrayRef<SourceLocation> IdentifierLocs = D->getIdentifierLocs();
   Record.push_back(!IdentifierLocs.empty());
   if (IdentifierLocs.empty()) {





More information about the cfe-commits mailing list