diff options
Diffstat (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index ffba04f..07d4fe8 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -88,6 +88,8 @@ namespace clang { const SourceLocation ThisDeclLoc; using RecordData = ASTReader::RecordData; + using LazySpecializationInfo + = RedeclarableTemplateDecl::LazySpecializationInfo; TypeID DeferredTypeID = 0; unsigned AnonymousDeclNumber = 0; @@ -134,9 +136,16 @@ namespace clang { return Record.readString(); } - void readDeclIDList(SmallVectorImpl<DeclID> &IDs) { + LazySpecializationInfo ReadLazySpecializationInfo() { + DeclID ID = readDeclID(); + unsigned Hash = Record.readInt(); + bool IsPartial = Record.readInt(); + return LazySpecializationInfo(ID, Hash, IsPartial); + } + + void readDeclIDList(SmallVectorImpl<LazySpecializationInfo> &IDs) { for (unsigned I = 0, Size = Record.readInt(); I != Size; ++I) - IDs.push_back(readDeclID()); + IDs.push_back(ReadLazySpecializationInfo()); } Decl *readDecl() { @@ -267,7 +276,7 @@ namespace clang { template <typename T> static void AddLazySpecializations(T *D, - SmallVectorImpl<serialization::DeclID>& IDs) { + SmallVectorImpl<LazySpecializationInfo>& IDs) { if (IDs.empty()) return; @@ -277,12 +286,11 @@ namespace clang { auto *&LazySpecializations = D->getCommonPtr()->LazySpecializations; if (auto &Old = LazySpecializations) { - IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]); + IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0].DeclID); llvm::sort(IDs); IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end()); } - - auto *Result = new (C) serialization::DeclID[1 + IDs.size()]; + auto *Result = new (C) LazySpecializationInfo[1 + IDs.size()]; *Result = IDs.size(); std::copy(IDs.begin(), IDs.end(), Result + 1); @@ -320,7 +328,7 @@ namespace clang { void ReadFunctionDefinition(FunctionDecl *FD); void Visit(Decl *D); - void UpdateDecl(Decl *D, SmallVectorImpl<serialization::DeclID> &); + void UpdateDecl(Decl *D, llvm::SmallVectorImpl<LazySpecializationInfo>&); static void setNextObjCCategory(ObjCCategoryDecl *Cat, ObjCCategoryDecl *Next) { @@ -2450,7 +2458,7 @@ void ASTDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) { if (ThisDeclID == Redecl.getFirstID()) { // This ClassTemplateDecl owns a CommonPtr; read it to keep track of all of // the specializations. - SmallVector<serialization::DeclID, 32> SpecIDs; + SmallVector<LazySpecializationInfo, 32> SpecIDs; readDeclIDList(SpecIDs); ASTDeclReader::AddLazySpecializations(D, SpecIDs); } @@ -2478,7 +2486,7 @@ void ASTDeclReader::VisitVarTemplateDecl(VarTemplateDecl *D) { if (ThisDeclID == Redecl.getFirstID()) { // This VarTemplateDecl owns a CommonPtr; read it to keep track of all of // the specializations. - SmallVector<serialization::DeclID, 32> SpecIDs; + SmallVector<LazySpecializationInfo, 32> SpecIDs; readDeclIDList(SpecIDs); ASTDeclReader::AddLazySpecializations(D, SpecIDs); } @@ -2580,7 +2588,7 @@ void ASTDeclReader::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { if (ThisDeclID == Redecl.getFirstID()) { // This FunctionTemplateDecl owns a CommonPtr; read it. - SmallVector<serialization::DeclID, 32> SpecIDs; + SmallVector<LazySpecializationInfo, 32> SpecIDs; readDeclIDList(SpecIDs); ASTDeclReader::AddLazySpecializations(D, SpecIDs); } @@ -4191,7 +4199,9 @@ void ASTReader::loadDeclUpdateRecords(PendingUpdateRecord &Record) { ProcessingUpdatesRAIIObj ProcessingUpdates(*this); DeclUpdateOffsetsMap::iterator UpdI = DeclUpdateOffsets.find(ID); - SmallVector<serialization::DeclID, 8> PendingLazySpecializationIDs; + using LazySpecializationInfo + = RedeclarableTemplateDecl::LazySpecializationInfo; + llvm::SmallVector<LazySpecializationInfo, 8> PendingLazySpecializationIDs; if (UpdI != DeclUpdateOffsets.end()) { auto UpdateOffsets = std::move(UpdI->second); @@ -4461,7 +4471,7 @@ static void forAllLaterRedecls(DeclT *D, Fn F) { } void ASTDeclReader::UpdateDecl(Decl *D, - llvm::SmallVectorImpl<serialization::DeclID> &PendingLazySpecializationIDs) { + SmallVectorImpl<LazySpecializationInfo> &PendingLazySpecializationIDs) { while (Record.getIdx() < Record.size()) { switch ((DeclUpdateKind)Record.readInt()) { case UPD_CXX_ADDED_IMPLICIT_MEMBER: { @@ -4474,7 +4484,7 @@ void ASTDeclReader::UpdateDecl(Decl *D, case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION: // It will be added to the template's lazy specialization set. - PendingLazySpecializationIDs.push_back(readDeclID()); + PendingLazySpecializationIDs.push_back(ReadLazySpecializationInfo()); break; case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE: { |