@@ -501,6 +501,12 @@ class ASTReader
501
501
// / = I + 1 has already been loaded.
502
502
llvm::PagedVector<Decl *> DeclsLoaded;
503
503
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
+
504
510
using FileOffset = std::pair<ModuleFile *, uint64_t >;
505
511
using FileOffsetsTy = SmallVector<FileOffset, 2 >;
506
512
using DeclUpdateOffsetsMap = llvm::DenseMap<GlobalDeclID, FileOffsetsTy>;
@@ -583,11 +589,10 @@ class ASTReader
583
589
584
590
struct FileDeclsInfo {
585
591
ModuleFile *Mod = nullptr ;
586
- ArrayRef<serialization:: unaligned_decl_id_t > Decls;
592
+ ArrayRef<LocalDeclID > Decls;
587
593
588
594
FileDeclsInfo () = default ;
589
- FileDeclsInfo (ModuleFile *Mod,
590
- ArrayRef<serialization::unaligned_decl_id_t > Decls)
595
+ FileDeclsInfo (ModuleFile *Mod, ArrayRef<LocalDeclID> Decls)
591
596
: Mod(Mod), Decls(Decls) {}
592
597
};
593
598
@@ -596,7 +601,11 @@ class ASTReader
596
601
597
602
// / An array of lexical contents of a declaration context, as a sequence of
598
603
// / 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 >;
600
609
601
610
// / Map from a DeclContext to its lexical contents.
602
611
llvm::DenseMap<const DeclContext*, std::pair<ModuleFile*, LexicalContents>>
@@ -1477,23 +1486,22 @@ class ASTReader
1477
1486
unsigned ClientLoadCapabilities);
1478
1487
1479
1488
public:
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 *> {
1485
1493
ASTReader *Reader = nullptr ;
1486
1494
ModuleFile *Mod = nullptr ;
1487
1495
1488
1496
public:
1489
1497
ModuleDeclIterator () : iterator_adaptor_base(nullptr ) {}
1490
1498
1491
1499
ModuleDeclIterator (ASTReader *Reader, ModuleFile *Mod,
1492
- const serialization:: unaligned_decl_id_t *Pos)
1500
+ const LocalDeclID *Pos)
1493
1501
: iterator_adaptor_base(Pos), Reader(Reader), Mod(Mod) {}
1494
1502
1495
1503
value_type operator *() const {
1496
- return Reader->GetDecl (Reader->getGlobalDeclID (*Mod, (LocalDeclID) *I));
1504
+ return Reader->GetDecl (Reader->getGlobalDeclID (*Mod, *I));
1497
1505
}
1498
1506
1499
1507
value_type operator ->() const { return **this ; }
@@ -1533,9 +1541,6 @@ class ASTReader
1533
1541
StringRef Arg2 = StringRef(), StringRef Arg3 = StringRef()) const ;
1534
1542
void Error (llvm::Error &&Err) const ;
1535
1543
1536
- // / Translate a \param GlobalDeclID to the index of DeclsLoaded array.
1537
- unsigned translateGlobalDeclIDToIndex (GlobalDeclID ID) const ;
1538
-
1539
1544
public:
1540
1545
// / Load the AST file and validate its contents against the given
1541
1546
// / Preprocessor.
@@ -1907,8 +1912,7 @@ class ASTReader
1907
1912
1908
1913
// / Retrieve the module file that owns the given declaration, or NULL
1909
1914
// / 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);
1912
1916
1913
1917
// / Returns the source location for the decl \p ID.
1914
1918
SourceLocation getSourceLocationForDeclID (GlobalDeclID ID);
0 commit comments