]> granicus.if.org Git - clang/commitdiff
[Modules] Make our on-disk hash table of selector IDs be built in
authorChandler Carruth <chandlerc@gmail.com>
Fri, 27 Mar 2015 00:47:43 +0000 (00:47 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Fri, 27 Mar 2015 00:47:43 +0000 (00:47 +0000)
a deterministic order.

This uses a MapVector to track the insertion order of selectors.

Found by inspection.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233342 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Serialization/ASTWriter.h
lib/Serialization/ASTWriter.cpp

index bd01fc7df13e718d77f1d07e744baedb4da35879..d7a801df3691552fcfa155fa681b7601ffff0a13 100644 (file)
@@ -276,7 +276,7 @@ private:
   serialization::SelectorID NextSelectorID;
 
   /// \brief Map that provides the ID numbers of each Selector.
-  llvm::DenseMap<Selector, serialization::SelectorID> SelectorIDs;
+  llvm::MapVector<Selector, serialization::SelectorID> SelectorIDs;
 
   /// \brief Offset of each selector within the method pool/selector
   /// table, indexed by the Selector ID (-1).
index 990a565e5036fd5f471717e99ad9af5872a092bb..e5891abb56ab78a4218e10fe101e2fe97003cc28 100644 (file)
@@ -3029,13 +3029,12 @@ void ASTWriter::WriteSelectors(Sema &SemaRef) {
     // Create the on-disk hash table representation. We walk through every
     // selector we've seen and look it up in the method pool.
     SelectorOffsets.resize(NextSelectorID - FirstSelectorID);
-    for (llvm::DenseMap<Selector, SelectorID>::iterator
-             I = SelectorIDs.begin(), E = SelectorIDs.end();
-         I != E; ++I) {
-      Selector S = I->first;
+    for (auto &SelectorAndID : SelectorIDs) {
+      Selector S = SelectorAndID.first;
+      SelectorID ID = SelectorAndID.second;
       Sema::GlobalMethodPool::iterator F = SemaRef.MethodPool.find(S);
       ASTMethodPoolTrait::data_type Data = {
-        I->second,
+        ID,
         ObjCMethodList(),
         ObjCMethodList()
       };
@@ -3045,7 +3044,7 @@ void ASTWriter::WriteSelectors(Sema &SemaRef) {
       }
       // Only write this selector if it's not in an existing AST or something
       // changed.
-      if (Chain && I->second < FirstSelectorID) {
+      if (Chain && ID < FirstSelectorID) {
         // Selector already exists. Did it change?
         bool changed = false;
         for (ObjCMethodList *M = &Data.Instance;