From f09fab4349178d9604dcf326d928b02c05783502 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Fri, 27 Mar 2015 00:47:43 +0000 Subject: [PATCH] [Modules] Make our on-disk hash table of selector IDs be built in 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 | 2 +- lib/Serialization/ASTWriter.cpp | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h index bd01fc7df1..d7a801df36 100644 --- a/include/clang/Serialization/ASTWriter.h +++ b/include/clang/Serialization/ASTWriter.h @@ -276,7 +276,7 @@ private: serialization::SelectorID NextSelectorID; /// \brief Map that provides the ID numbers of each Selector. - llvm::DenseMap SelectorIDs; + llvm::MapVector SelectorIDs; /// \brief Offset of each selector within the method pool/selector /// table, indexed by the Selector ID (-1). diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 990a565e50..e5891abb56 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -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::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; -- 2.40.0