@@ -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,40 @@ class ASTReader
632635 llvm::DenseMap<const DeclContext *,
633636 serialization::reader::DeclContextLookupTable> Lookups;
634637
638+ using SpecLookupTableTy =
639+ llvm::DenseMap<const Decl *,
640+ serialization::reader::LazySpecializationInfoLookupTable>;
641+ // / Map from decls to specialized decls.
642+ SpecLookupTableTy SpecializationsLookups;
643+ // / Split partial specialization from specialization to speed up lookups.
644+ SpecLookupTableTy PartialSpecializationsLookups;
645+
646+ bool LoadExternalSpecializationsImpl (SpecLookupTableTy &SpecLookups,
647+ const Decl *D);
648+ bool LoadExternalSpecializationsImpl (SpecLookupTableTy &SpecLookups,
649+ const Decl *D,
650+ ArrayRef<TemplateArgument> TemplateArgs);
651+
635652 // Updates for visible decls can occur for other contexts than just the
636653 // TU, and when we read those update records, the actual context may not
637654 // 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 {
655+ // will be realized when the data is actually loaded.
656+ struct UpdateData {
640657 ModuleFile *Mod;
641658 const unsigned char *Data;
642659 };
643- using DeclContextVisibleUpdates = SmallVector<PendingVisibleUpdate , 1 >;
660+ using DeclContextVisibleUpdates = SmallVector<UpdateData , 1 >;
644661
645662 // / Updates to the visible declarations of declaration contexts that
646663 // / haven't been loaded yet.
647664 llvm::DenseMap<GlobalDeclID, DeclContextVisibleUpdates> PendingVisibleUpdates;
648665
666+ using SpecializationsUpdate = SmallVector<UpdateData, 1 >;
667+ using SpecializationsUpdateMap =
668+ llvm::DenseMap<GlobalDeclID, SpecializationsUpdate>;
669+ SpecializationsUpdateMap PendingSpecializationsUpdates;
670+ SpecializationsUpdateMap PendingPartialSpecializationsUpdates;
671+
649672 // / The set of C++ or Objective-C classes that have forward
650673 // / declarations that have not yet been linked to their definitions.
651674 llvm::SmallPtrSet<Decl *, 4 > PendingDefinitions;
@@ -678,6 +701,11 @@ class ASTReader
678701 llvm::BitstreamCursor &Cursor,
679702 uint64_t Offset, GlobalDeclID ID);
680703
704+ bool ReadSpecializations (ModuleFile &M, llvm::BitstreamCursor &Cursor,
705+ uint64_t Offset, Decl *D, bool IsPartial);
706+ void AddSpecializations (const Decl *D, const unsigned char *Data,
707+ ModuleFile &M, bool IsPartial);
708+
681709 // / A vector containing identifiers that have already been
682710 // / loaded.
683711 // /
@@ -1419,6 +1447,14 @@ class ASTReader
14191447 const serialization::reader::DeclContextLookupTable *
14201448 getLoadedLookupTables (DeclContext *Primary) const ;
14211449
1450+ // / Get the loaded specializations lookup tables for \p D,
1451+ // / if any.
1452+ serialization::reader::LazySpecializationInfoLookupTable *
1453+ getLoadedSpecializationsLookupTables (const Decl *D, bool IsPartial);
1454+
1455+ // / If we have any unloaded specialization for \p D
1456+ bool haveUnloadedSpecializations (const Decl *D) const ;
1457+
14221458private:
14231459 struct ImportedModule {
14241460 ModuleFile *Mod;
@@ -2076,6 +2112,12 @@ class ASTReader
20762112 unsigned BlockID,
20772113 uint64_t *StartOfBlockOffset = nullptr );
20782114
2115+ bool LoadExternalSpecializations (const Decl *D, bool OnlyPartial) override ;
2116+
2117+ bool
2118+ LoadExternalSpecializations (const Decl *D,
2119+ ArrayRef<TemplateArgument> TemplateArgs) override ;
2120+
20792121 // / Finds all the visible declarations with a given name.
20802122 // / The current implementation of this method just loads the entire
20812123 // / lookup table as unmaterialized references.
0 commit comments