Index: lib/Serialization/ASTReaderDecl.cpp =================================================================== --- lib/Serialization/ASTReaderDecl.cpp +++ lib/Serialization/ASTReaderDecl.cpp @@ -3788,9 +3788,31 @@ break; } - case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION: - // It will be added to the template's specializations set when loaded. - (void)Record.readDecl(); + case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION: { + // It will be added to the template's lazy specialization set when loaded. + // FIXME: reduce the copy paste. + SmallVector SpecID; + if (auto *CTD = dyn_cast(D)) { + SpecID.push_back(ReadDeclID()); + auto *CommonPtr = CTD->getCommonPtr(); + CommonPtr->LazySpecializations = newDeclIDList( + Reader.getContext(), CommonPtr->LazySpecializations, SpecID); + + } else if (auto *FTD = dyn_cast(D)) { + SpecID.push_back(ReadDeclID()); + auto *CommonPtr = FTD->getCommonPtr(); + CommonPtr->LazySpecializations = newDeclIDList( + Reader.getContext(), CommonPtr->LazySpecializations, SpecID); + + } else if (auto *VTD = dyn_cast(D)) { + SpecID.push_back(ReadDeclID()); + auto *CommonPtr = VTD->getCommonPtr(); + CommonPtr->LazySpecializations = newDeclIDList( + Reader.getContext(), CommonPtr->LazySpecializations, SpecID); + + } else // TypeAliasTemplateDecl + assert(0 && "TypeAliasTemplateDecl doesn't have specs!"); + } break; case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE: {