@@ -354,6 +354,9 @@ class ASTIdentifierLookupTrait;
354354// / The on-disk hash table(s) used for DeclContext name lookup.
355355struct DeclContextLookupTable ;
356356
357+ // / The on-disk hash table(s) used for specialization decls.
358+ struct LazySpecializationInfoLookupTable ;
359+
357360} // namespace reader
358361
359362} // namespace serialization
@@ -632,20 +635,29 @@ class ASTReader
632635 llvm::DenseMap<const DeclContext *,
633636 serialization::reader::DeclContextLookupTable> Lookups;
634637
638+ // / Map from decls to specialized decls.
639+ llvm::DenseMap<const Decl *,
640+ serialization::reader::LazySpecializationInfoLookupTable>
641+ SpecializationsLookups;
642+
635643 // Updates for visible decls can occur for other contexts than just the
636644 // TU, and when we read those update records, the actual context may not
637645 // be available yet, so have this pending map using the ID as a key. It
638- // will be realized when the context is actually loaded.
639- struct PendingVisibleUpdate {
646+ // will be realized when the data is actually loaded.
647+ struct UpdateData {
640648 ModuleFile *Mod;
641649 const unsigned char *Data;
642650 };
643- using DeclContextVisibleUpdates = SmallVector<PendingVisibleUpdate , 1 >;
651+ using DeclContextVisibleUpdates = SmallVector<UpdateData , 1 >;
644652
645653 // / Updates to the visible declarations of declaration contexts that
646654 // / haven't been loaded yet.
647655 llvm::DenseMap<GlobalDeclID, DeclContextVisibleUpdates> PendingVisibleUpdates;
648656
657+ using SpecializationsUpdate = SmallVector<UpdateData, 1 >;
658+ llvm::DenseMap<GlobalDeclID, SpecializationsUpdate>
659+ PendingSpecializationsUpdates;
660+
649661 // / The set of C++ or Objective-C classes that have forward
650662 // / declarations that have not yet been linked to their definitions.
651663 llvm::SmallPtrSet<Decl *, 4 > PendingDefinitions;
@@ -678,6 +690,11 @@ class ASTReader
678690 llvm::BitstreamCursor &Cursor,
679691 uint64_t Offset, GlobalDeclID ID);
680692
693+ bool ReadSpecializations (ModuleFile &M, llvm::BitstreamCursor &Cursor,
694+ uint64_t Offset, Decl *D);
695+ void AddSpecializations (const Decl *D, const unsigned char *Data,
696+ ModuleFile &M);
697+
681698 // / A vector containing identifiers that have already been
682699 // / loaded.
683700 // /
@@ -1419,6 +1436,11 @@ class ASTReader
14191436 const serialization::reader::DeclContextLookupTable *
14201437 getLoadedLookupTables (DeclContext *Primary) const ;
14211438
1439+ // / Get the loaded specializations lookup tables for \p D,
1440+ // / if any.
1441+ serialization::reader::LazySpecializationInfoLookupTable *
1442+ getLoadedSpecializationsLookupTables (const Decl *D);
1443+
14221444private:
14231445 struct ImportedModule {
14241446 ModuleFile *Mod;
@@ -2076,6 +2098,12 @@ class ASTReader
20762098 unsigned BlockID,
20772099 uint64_t *StartOfBlockOffset = nullptr );
20782100
2101+ void LoadExternalSpecializations (const Decl *D, bool OnlyPartial) override ;
2102+
2103+ void
2104+ LoadExternalSpecializations (const Decl *D,
2105+ ArrayRef<TemplateArgument> TemplateArgs) override ;
2106+
20792107 // / Finds all the visible declarations with a given name.
20802108 // / The current implementation of this method just loads the entire
20812109 // / lookup table as unmaterialized references.
0 commit comments