This patch extends the previous patch by starting to incorporate more functionality, like lookup-by-name and exporting lookup tables, into the module manager.  Methods now have documentation.  A few more functions have been switched over to the new iterator style and away from manual/explicit iteration.  Ultimately we want to move away from name lookup here, as symlinks make filenames not a safe unique value, but we use it here as a stopgap before better measures are in place (namely instead using FileEntry* from a global FileManager).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136107 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp
index c94b96d..14824a0 100644
--- a/lib/Serialization/ASTWriter.cpp
+++ b/lib/Serialization/ASTWriter.cpp
@@ -969,7 +969,8 @@
   Record.push_back(CLANG_VERSION_MINOR);
   Record.push_back(!isysroot.empty());
   // FIXME: This writes the absolute path for chained headers.
-  const std::string &BlobStr = Chain ? Chain->getFileName() : Target.getTriple().getTriple();
+  const std::string &BlobStr =
+                  Chain ? Chain->getFileName() : Target.getTriple().getTriple();
   Stream.EmitRecordWithBlob(MetaAbbrevCode, Record, BlobStr);
 
   // Original file name and file ID
@@ -1548,14 +1549,8 @@
     // Sorted by offset.
     typedef std::pair<uint32_t, StringRef> ModuleOffset;
     SmallVector<ModuleOffset, 16> Modules;
-    Modules.reserve(Chain->Modules.size());
-    for (llvm::StringMap<Module*>::const_iterator
-             I = Chain->Modules.begin(), E = Chain->Modules.end();
-         I != E; ++I) {
-      Modules.push_back(ModuleOffset(I->getValue()->SLocEntryBaseOffset,
-                                     I->getKey()));
-    }
-    std::sort(Modules.begin(), Modules.end());
+
+    Chain->ModuleMgr.exportLookup(Modules);
 
     Abbrev = new BitCodeAbbrev();
     Abbrev->Add(BitCodeAbbrevOp(SOURCE_LOCATION_MAP));