@@ -501,6 +501,12 @@ class ASTReader
501501 // / = I + 1 has already been loaded.
502502 llvm::PagedVector<Decl *> DeclsLoaded;
503503
504+ using GlobalDeclMapType = ContinuousRangeMap<GlobalDeclID, ModuleFile *, 4 >;
505+
506+ // / Mapping from global declaration IDs to the module in which the
507+ // / declaration resides.
508+ GlobalDeclMapType GlobalDeclMap;
509+
504510 using FileOffset = std::pair<ModuleFile *, uint64_t >;
505511 using FileOffsetsTy = SmallVector<FileOffset, 2 >;
506512 using DeclUpdateOffsetsMap = llvm::DenseMap<GlobalDeclID, FileOffsetsTy>;
@@ -583,11 +589,10 @@ class ASTReader
583589
584590 struct FileDeclsInfo {
585591 ModuleFile *Mod = nullptr ;
586- ArrayRef<serialization:: unaligned_decl_id_t > Decls;
592+ ArrayRef<LocalDeclID > Decls;
587593
588594 FileDeclsInfo () = default ;
589- FileDeclsInfo (ModuleFile *Mod,
590- ArrayRef<serialization::unaligned_decl_id_t > Decls)
595+ FileDeclsInfo (ModuleFile *Mod, ArrayRef<LocalDeclID> Decls)
591596 : Mod(Mod), Decls(Decls) {}
592597 };
593598
@@ -596,7 +601,11 @@ class ASTReader
596601
597602 // / An array of lexical contents of a declaration context, as a sequence of
598603 // / Decl::Kind, DeclID pairs.
599- using LexicalContents = ArrayRef<serialization::unaligned_decl_id_t >;
604+ using unaligned_decl_id_t =
605+ llvm::support::detail::packed_endian_specific_integral<
606+ serialization::DeclID, llvm::endianness::native,
607+ llvm::support::unaligned>;
608+ using LexicalContents = ArrayRef<unaligned_decl_id_t >;
600609
601610 // / Map from a DeclContext to its lexical contents.
602611 llvm::DenseMap<const DeclContext*, std::pair<ModuleFile*, LexicalContents>>
@@ -1477,23 +1486,22 @@ class ASTReader
14771486 unsigned ClientLoadCapabilities);
14781487
14791488public:
1480- class ModuleDeclIterator
1481- : public llvm::iterator_adaptor_base<
1482- ModuleDeclIterator, const serialization::unaligned_decl_id_t *,
1483- std::random_access_iterator_tag, const Decl *, ptrdiff_t ,
1484- const Decl *, const Decl *> {
1489+ class ModuleDeclIterator : public llvm ::iterator_adaptor_base<
1490+ ModuleDeclIterator, const LocalDeclID *,
1491+ std::random_access_iterator_tag, const Decl *,
1492+ ptrdiff_t , const Decl *, const Decl *> {
14851493 ASTReader *Reader = nullptr ;
14861494 ModuleFile *Mod = nullptr ;
14871495
14881496 public:
14891497 ModuleDeclIterator () : iterator_adaptor_base(nullptr ) {}
14901498
14911499 ModuleDeclIterator (ASTReader *Reader, ModuleFile *Mod,
1492- const serialization:: unaligned_decl_id_t *Pos)
1500+ const LocalDeclID *Pos)
14931501 : iterator_adaptor_base(Pos), Reader(Reader), Mod(Mod) {}
14941502
14951503 value_type operator *() const {
1496- return Reader->GetDecl (Reader->getGlobalDeclID (*Mod, (LocalDeclID) *I));
1504+ return Reader->GetDecl (Reader->getGlobalDeclID (*Mod, *I));
14971505 }
14981506
14991507 value_type operator ->() const { return **this ; }
@@ -1533,9 +1541,6 @@ class ASTReader
15331541 StringRef Arg2 = StringRef(), StringRef Arg3 = StringRef()) const ;
15341542 void Error (llvm::Error &&Err) const ;
15351543
1536- // / Translate a \param GlobalDeclID to the index of DeclsLoaded array.
1537- unsigned translateGlobalDeclIDToIndex (GlobalDeclID ID) const ;
1538-
15391544public:
15401545 // / Load the AST file and validate its contents against the given
15411546 // / Preprocessor.
@@ -1907,8 +1912,7 @@ class ASTReader
19071912
19081913 // / Retrieve the module file that owns the given declaration, or NULL
19091914 // / if the declaration is not from a module file.
1910- ModuleFile *getOwningModuleFile (const Decl *D) const ;
1911- ModuleFile *getOwningModuleFile (GlobalDeclID ID) const ;
1915+ ModuleFile *getOwningModuleFile (const Decl *D);
19121916
19131917 // / Returns the source location for the decl \p ID.
19141918 SourceLocation getSourceLocationForDeclID (GlobalDeclID ID);
0 commit comments