Index: include/clang/Serialization/ASTReader.h =================================================================== --- include/clang/Serialization/ASTReader.h +++ include/clang/Serialization/ASTReader.h @@ -527,11 +527,9 @@ /// to apply once we finish processing an import. llvm::SmallVector PendingUpdateRecords; - enum class PendingFakeDefinitionKind { NotFake, Fake, FakeLoaded }; - /// The DefinitionData pointers that we faked up for class definitions /// that we needed but hadn't loaded yet. - llvm::DenseMap PendingFakeDefinitionData; + llvm::DenseSet PendingFakeDefinitionData; /// Exception specification updates that have been loaded but not yet /// propagated across the relevant redeclaration chain. The map key is the Index: lib/Serialization/ASTReaderDecl.cpp =================================================================== --- lib/Serialization/ASTReaderDecl.cpp +++ lib/Serialization/ASTReaderDecl.cpp @@ -1757,12 +1757,14 @@ } auto PFDI = Reader.PendingFakeDefinitionData.find(&DD); - if (PFDI != Reader.PendingFakeDefinitionData.end() && - PFDI->second == ASTReader::PendingFakeDefinitionKind::Fake) { + if (PFDI != Reader.PendingFakeDefinitionData.end()) { // We faked up this definition data because we found a class for which we'd // not yet loaded the definition. Replace it with the real thing now. + + Reader.PendingFakeDefinitionData.erase(PFDI); + + // FIXME: handle serialized lambdas assert(!DD.IsLambda && !MergeDD.IsLambda && "faked up lambda definition?"); - PFDI->second = ASTReader::PendingFakeDefinitionKind::FakeLoaded; // Don't change which declaration is the definition; that is required // to be invariant once we select it. @@ -3077,8 +3079,7 @@ RD->getCanonicalDecl()->DefinitionData = DD; // Track that we did this horrible thing so that we can fix it later. - Reader.PendingFakeDefinitionData.insert( - std::make_pair(DD, ASTReader::PendingFakeDefinitionKind::Fake)); + Reader.PendingFakeDefinitionData.insert(DD); } return DD->Definition;