From: Douglas Gregor Date: Thu, 11 Oct 2012 17:31:34 +0000 (+0000) Subject: Make the deserialization of PendingMacroIDs deterministic. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e9652bf15246d6e08e953b52cdb7812ddb8a43e0;p=clang Make the deserialization of PendingMacroIDs deterministic. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165727 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index 3a938a24c7..2a9afc92e9 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -495,8 +495,8 @@ private: /// global method pool for this selector. llvm::DenseMap SelectorGeneration; - typedef llvm::DenseMap > + typedef llvm::MapVector > PendingMacroIDsMap; /// \brief Mapping from identifiers that have a macro history to the global @@ -1606,10 +1606,6 @@ public: /// \brief Note that this identifier is up-to-date. void markIdentifierUpToDate(IdentifierInfo *II); - /// \brief Read the macro definition corresponding to this iterator - /// into the unread macro record offsets table. - void LoadMacroDefinition(PendingMacroIDsMap::iterator Pos); - /// \brief Load all external visible decls in the given DeclContext. void completeVisibleDeclsMap(const DeclContext *DC); diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 861d99ee64..736f082d6f 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -1542,14 +1542,6 @@ void ASTReader::ReadDefinedMacros() { } } -void ASTReader::LoadMacroDefinition(PendingMacroIDsMap::iterator Pos) { - assert(Pos != PendingMacroIDs.end() && "Unknown macro definition"); - SmallVector GlobalIDs = Pos->second; - PendingMacroIDs.erase(Pos); - for (unsigned I = 0, N = GlobalIDs.size(); I != N; ++I) - getMacro(GlobalIDs[I]); -} - namespace { /// \brief Visitor class used to look up identifirs in an AST file. class IdentifierLookupVisitor { @@ -6517,9 +6509,15 @@ void ASTReader::finishPendingActions() { PendingDeclChains.clear(); // Load any pending macro definitions. - // FIXME: Non-determinism here. - while (!PendingMacroIDs.empty()) - LoadMacroDefinition(PendingMacroIDs.begin()); + for (unsigned I = 0; I != PendingMacroIDs.size(); ++I) { + // FIXME: std::move here + SmallVector GlobalIDs = PendingMacroIDs.begin()[I].second; + for (unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs; + ++IDIdx) { + getMacro(GlobalIDs[IDIdx]); + } + } + PendingMacroIDs.clear(); } // If we deserialized any C++ or Objective-C class definitions, any