@@ -340,6 +340,9 @@ class ASTIdentifierLookupTrait;
340
340
// / The on-disk hash table(s) used for DeclContext name lookup.
341
341
struct DeclContextLookupTable ;
342
342
343
+ // / The on-disk hash table(s) used for specialization decls.
344
+ struct LazySpecializationInfoLookupTable ;
345
+
343
346
} // namespace reader
344
347
345
348
} // namespace serialization
@@ -603,21 +606,41 @@ class ASTReader
603
606
llvm::DenseMap<const DeclContext *,
604
607
serialization::reader::DeclContextLookupTable> Lookups;
605
608
609
+ using SpecLookupTableTy =
610
+ llvm::DenseMap<const Decl *,
611
+ serialization::reader::LazySpecializationInfoLookupTable>;
612
+ // / Map from decls to specialized decls.
613
+ SpecLookupTableTy SpecializationsLookups;
614
+ // / Split partial specialization from specialization to speed up lookups.
615
+ SpecLookupTableTy PartialSpecializationsLookups;
616
+
617
+ bool LoadExternalSpecializationsImpl (SpecLookupTableTy &SpecLookups,
618
+ const Decl *D);
619
+ bool LoadExternalSpecializationsImpl (SpecLookupTableTy &SpecLookups,
620
+ const Decl *D,
621
+ ArrayRef<TemplateArgument> TemplateArgs);
622
+
606
623
// Updates for visible decls can occur for other contexts than just the
607
624
// TU, and when we read those update records, the actual context may not
608
625
// be available yet, so have this pending map using the ID as a key. It
609
- // will be realized when the context is actually loaded.
610
- struct PendingVisibleUpdate {
626
+ // will be realized when the data is actually loaded.
627
+ struct UpdateData {
611
628
ModuleFile *Mod;
612
629
const unsigned char *Data;
613
630
};
614
- using DeclContextVisibleUpdates = SmallVector<PendingVisibleUpdate , 1 >;
631
+ using DeclContextVisibleUpdates = SmallVector<UpdateData , 1 >;
615
632
616
633
// / Updates to the visible declarations of declaration contexts that
617
634
// / haven't been loaded yet.
618
635
llvm::DenseMap<serialization::DeclID, DeclContextVisibleUpdates>
619
636
PendingVisibleUpdates;
620
637
638
+ using SpecializationsUpdate = SmallVector<UpdateData, 1 >;
639
+ using SpecializationsUpdateMap =
640
+ llvm::DenseMap<serialization::GlobalDeclID, SpecializationsUpdate>;
641
+ SpecializationsUpdateMap PendingSpecializationsUpdates;
642
+ SpecializationsUpdateMap PendingPartialSpecializationsUpdates;
643
+
621
644
// / The set of C++ or Objective-C classes that have forward
622
645
// / declarations that have not yet been linked to their definitions.
623
646
llvm::SmallPtrSet<Decl *, 4 > PendingDefinitions;
@@ -644,6 +667,11 @@ class ASTReader
644
667
llvm::BitstreamCursor &Cursor,
645
668
uint64_t Offset, serialization::DeclID ID);
646
669
670
+ bool ReadSpecializations (ModuleFile &M, llvm::BitstreamCursor &Cursor,
671
+ uint64_t Offset, Decl *D, bool IsPartial);
672
+ void AddSpecializations (const Decl *D, const unsigned char *Data,
673
+ ModuleFile &M, bool IsPartial);
674
+
647
675
// / A vector containing identifiers that have already been
648
676
// / loaded.
649
677
// /
@@ -1350,6 +1378,14 @@ class ASTReader
1350
1378
const serialization::reader::DeclContextLookupTable *
1351
1379
getLoadedLookupTables (DeclContext *Primary) const ;
1352
1380
1381
+ // / Get the loaded specializations lookup tables for \p D,
1382
+ // / if any.
1383
+ serialization::reader::LazySpecializationInfoLookupTable *
1384
+ getLoadedSpecializationsLookupTables (const Decl *D, bool IsPartial);
1385
+
1386
+ // / If we have any unloaded specialization for \p D
1387
+ bool haveUnloadedSpecializations (const Decl *D) const ;
1388
+
1353
1389
private:
1354
1390
struct ImportedModule {
1355
1391
ModuleFile *Mod;
@@ -1989,6 +2025,12 @@ class ASTReader
1989
2025
unsigned BlockID,
1990
2026
uint64_t *StartOfBlockOffset = nullptr );
1991
2027
2028
+ bool LoadExternalSpecializations (const Decl *D, bool OnlyPartial) override ;
2029
+
2030
+ bool
2031
+ LoadExternalSpecializations (const Decl *D,
2032
+ ArrayRef<TemplateArgument> TemplateArgs) override ;
2033
+
1992
2034
// / Finds all the visible declarations with a given name.
1993
2035
// / The current implementation of this method just loads the entire
1994
2036
// / lookup table as unmaterialized references.
0 commit comments