@@ -504,6 +504,12 @@ class ASTReader
504504 // / = I + 1 has already been loaded.
505505 llvm::PagedVector<Decl *> DeclsLoaded;
506506
507+ using GlobalDeclMapType = ContinuousRangeMap<GlobalDeclID, ModuleFile *, 4 >;
508+
509+ // / Mapping from global declaration IDs to the module in which the
510+ // / declaration resides.
511+ GlobalDeclMapType GlobalDeclMap;
512+
507513 using FileOffset = std::pair<ModuleFile *, uint64_t >;
508514 using FileOffsetsTy = SmallVector<FileOffset, 2 >;
509515 using DeclUpdateOffsetsMap = llvm::DenseMap<GlobalDeclID, FileOffsetsTy>;
@@ -586,11 +592,10 @@ class ASTReader
586592
587593 struct FileDeclsInfo {
588594 ModuleFile *Mod = nullptr ;
589- ArrayRef<serialization:: unaligned_decl_id_t > Decls;
595+ ArrayRef<LocalDeclID > Decls;
590596
591597 FileDeclsInfo () = default ;
592- FileDeclsInfo (ModuleFile *Mod,
593- ArrayRef<serialization::unaligned_decl_id_t > Decls)
598+ FileDeclsInfo (ModuleFile *Mod, ArrayRef<LocalDeclID> Decls)
594599 : Mod(Mod), Decls(Decls) {}
595600 };
596601
@@ -599,7 +604,11 @@ class ASTReader
599604
600605 // / An array of lexical contents of a declaration context, as a sequence of
601606 // / Decl::Kind, DeclID pairs.
602- using LexicalContents = ArrayRef<serialization::unaligned_decl_id_t >;
607+ using unaligned_decl_id_t =
608+ llvm::support::detail::packed_endian_specific_integral<
609+ serialization::DeclID, llvm::endianness::native,
610+ llvm::support::unaligned>;
611+ using LexicalContents = ArrayRef<unaligned_decl_id_t >;
603612
604613 // / Map from a DeclContext to its lexical contents.
605614 llvm::DenseMap<const DeclContext*, std::pair<ModuleFile*, LexicalContents>>
@@ -1480,23 +1489,22 @@ class ASTReader
14801489 unsigned ClientLoadCapabilities);
14811490
14821491public:
1483- class ModuleDeclIterator
1484- : public llvm::iterator_adaptor_base<
1485- ModuleDeclIterator, const serialization::unaligned_decl_id_t *,
1486- std::random_access_iterator_tag, const Decl *, ptrdiff_t ,
1487- const Decl *, const Decl *> {
1492+ class ModuleDeclIterator : public llvm ::iterator_adaptor_base<
1493+ ModuleDeclIterator, const LocalDeclID *,
1494+ std::random_access_iterator_tag, const Decl *,
1495+ ptrdiff_t , const Decl *, const Decl *> {
14881496 ASTReader *Reader = nullptr ;
14891497 ModuleFile *Mod = nullptr ;
14901498
14911499 public:
14921500 ModuleDeclIterator () : iterator_adaptor_base(nullptr ) {}
14931501
14941502 ModuleDeclIterator (ASTReader *Reader, ModuleFile *Mod,
1495- const serialization:: unaligned_decl_id_t *Pos)
1503+ const LocalDeclID *Pos)
14961504 : iterator_adaptor_base(Pos), Reader(Reader), Mod(Mod) {}
14971505
14981506 value_type operator *() const {
1499- return Reader->GetDecl (Reader->getGlobalDeclID (*Mod, (LocalDeclID) *I));
1507+ return Reader->GetDecl (Reader->getGlobalDeclID (*Mod, *I));
15001508 }
15011509
15021510 value_type operator ->() const { return **this ; }
@@ -1536,9 +1544,6 @@ class ASTReader
15361544 StringRef Arg2 = StringRef(), StringRef Arg3 = StringRef()) const ;
15371545 void Error (llvm::Error &&Err) const ;
15381546
1539- // / Translate a \param GlobalDeclID to the index of DeclsLoaded array.
1540- unsigned translateGlobalDeclIDToIndex (GlobalDeclID ID) const ;
1541-
15421547public:
15431548 // / Load the AST file and validate its contents against the given
15441549 // / Preprocessor.
@@ -1910,8 +1915,7 @@ class ASTReader
19101915
19111916 // / Retrieve the module file that owns the given declaration, or NULL
19121917 // / if the declaration is not from a module file.
1913- ModuleFile *getOwningModuleFile (const Decl *D) const ;
1914- ModuleFile *getOwningModuleFile (GlobalDeclID ID) const ;
1918+ ModuleFile *getOwningModuleFile (const Decl *D);
19151919
19161920 // / Returns the source location for the decl \p ID.
19171921 SourceLocation getSourceLocationForDeclID (GlobalDeclID ID);
0 commit comments