@@ -1306,9 +1306,8 @@ bool ASTReader::ReadLexicalDeclContextStorage(ModuleFile &M,
13061306 auto &Lex = LexicalDecls[DC];
13071307 if (!Lex.first ) {
13081308 Lex = std::make_pair (
1309- &M, llvm::ArrayRef (
1310- reinterpret_cast <const unaligned_decl_id_t *>(Blob.data ()),
1311- Blob.size () / sizeof (DeclID)));
1309+ &M, llvm::ArrayRef (reinterpret_cast <const uint32_t *>(Blob.data ()),
1310+ Blob.size () / sizeof (uint32_t )));
13121311 }
13131312 DC->setHasExternalLexicalStorage (true );
13141313 return false ;
@@ -3422,8 +3421,8 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
34223421 case TU_UPDATE_LEXICAL: {
34233422 DeclContext *TU = ContextObj->getTranslationUnitDecl ();
34243423 LexicalContents Contents (
3425- reinterpret_cast <const unaligned_decl_id_t *>(Blob.data ()),
3426- static_cast <unsigned int >(Blob.size () / sizeof (DeclID )));
3424+ reinterpret_cast <const uint32_t *>(Blob.data ()),
3425+ static_cast <unsigned int >(Blob.size () / sizeof (uint32_t )));
34273426 TULexicalDecls.push_back (std::make_pair (&F, Contents));
34283427 TU->setHasExternalLexicalStorage (true );
34293428 break ;
@@ -3696,7 +3695,7 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
36963695 break ;
36973696
36983697 case VTABLE_USES:
3699- if (Record.size () % 3 != 0 )
3698+ if (Record.size () % (DeclIDSerialiazedSize + 1 + 1 ) != 0 )
37003699 return llvm::createStringError (std::errc::illegal_byte_sequence,
37013700 " Invalid VTABLE_USES record" );
37023701
@@ -3714,8 +3713,7 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
37143713 break ;
37153714
37163715 case PENDING_IMPLICIT_INSTANTIATIONS:
3717-
3718- if (Record.size () % 2 != 0 )
3716+ if (Record.size () % (DeclIDSerialiazedSize + 1 ) != 0 )
37193717 return llvm::createStringError (
37203718 std::errc::illegal_byte_sequence,
37213719 " Invalid PENDING_IMPLICIT_INSTANTIATIONS block" );
@@ -3728,7 +3726,7 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
37283726 break ;
37293727
37303728 case SEMA_DECL_REFS:
3731- if (Record.size () != 3 )
3729+ if (Record.size () != 3 * serialization::DeclIDSerialiazedSize )
37323730 return llvm::createStringError (std::errc::illegal_byte_sequence,
37333731 " Invalid SEMA_DECL_REFS block" );
37343732 for (unsigned I = 0 , N = Record.size (); I != N; /* in loop*/ )
@@ -3786,7 +3784,7 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
37863784 }
37873785
37883786 case DECL_UPDATE_OFFSETS:
3789- if (Record.size () % 2 != 0 )
3787+ if (Record.size () % (DeclIDSerialiazedSize + 1 ) != 0 )
37903788 return llvm::createStringError (
37913789 std::errc::illegal_byte_sequence,
37923790 " invalid DECL_UPDATE_OFFSETS block in AST file" );
@@ -3803,7 +3801,7 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
38033801 break ;
38043802
38053803 case DELAYED_NAMESPACE_LEXICAL_VISIBLE_RECORD: {
3806- if (Record.size () % 3 != 0 )
3804+ if (Record.size () % (DeclIDSerialiazedSize + 2 ) != 0 )
38073805 return llvm::createStringError (
38083806 std::errc::illegal_byte_sequence,
38093807 " invalid DELAYED_NAMESPACE_LEXICAL_VISIBLE_RECORD block in AST "
@@ -3898,7 +3896,7 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
38983896 break ;
38993897
39003898 case UNDEFINED_BUT_USED:
3901- if (Record.size () % 2 != 0 )
3899+ if (Record.size () % (DeclIDSerialiazedSize + 1 ) != 0 )
39023900 return llvm::createStringError (std::errc::illegal_byte_sequence,
39033901 " invalid undefined-but-used record" );
39043902 for (unsigned I = 0 , N = Record.size (); I != N; /* in loop */ ) {
@@ -7893,7 +7891,10 @@ GlobalDeclID ASTReader::ReadDeclID(ModuleFile &F, const RecordDataImpl &Record,
78937891 return GlobalDeclID (0 );
78947892 }
78957893
7896- return getGlobalDeclID (F, LocalDeclID::get (*this , F, Record[Idx++]));
7894+ uint32_t ModuleFileIndex = Record[Idx++];
7895+ uint32_t LocalDeclIndex = Record[Idx++];
7896+ return getGlobalDeclID (
7897+ F, LocalDeclID::get (*this , F, ModuleFileIndex, LocalDeclIndex));
78977898}
78987899
78997900// / Resolve the offset of a statement into a statement.
@@ -7922,25 +7923,26 @@ void ASTReader::FindExternalLexicalDecls(
79227923 SmallVectorImpl<Decl *> &Decls) {
79237924 bool PredefsVisited[NUM_PREDEF_DECL_IDS] = {};
79247925
7925- auto Visit = [&] (ModuleFile *M, LexicalContents LexicalDecls) {
7926- assert (LexicalDecls.size () % 2 == 0 && " expected an even number of entries" );
7927- for (int I = 0 , N = LexicalDecls.size (); I != N; I += 2 ) {
7926+ auto Visit = [&](ModuleFile *M, LexicalContents LexicalDecls) {
7927+ assert (LexicalDecls.size () % 3 == 0 && " incorrect number of entries" );
7928+ for (int I = 0 , N = LexicalDecls.size (); I != N; I += 3 ) {
79287929 auto K = (Decl::Kind)+LexicalDecls[I];
79297930 if (!IsKindWeWant (K))
79307931 continue ;
79317932
7932- auto ID = (DeclID) + LexicalDecls[I + 1 ];
7933+ LocalDeclID ID =
7934+ LocalDeclID::get (*this , *M, LexicalDecls[I + 1 ], LexicalDecls[I + 2 ]);
79337935
79347936 // Don't add predefined declarations to the lexical context more
79357937 // than once.
79367938 if (ID < NUM_PREDEF_DECL_IDS) {
7937- if (PredefsVisited[ID])
7939+ if (PredefsVisited[ID. getRawValue () ])
79387940 continue ;
79397941
7940- PredefsVisited[ID] = true ;
7942+ PredefsVisited[ID. getRawValue () ] = true ;
79417943 }
79427944
7943- if (Decl *D = GetLocalDecl (*M, LocalDeclID::get (* this , *M, ID) )) {
7945+ if (Decl *D = GetLocalDecl (*M, ID )) {
79447946 assert (D->getKind () == K && " wrong kind for lexical decl" );
79457947 if (!DC->isDeclInLexicalTraversal (D))
79467948 Decls.push_back (D);
@@ -8837,7 +8839,7 @@ void ASTReader::ReadLateParsedTemplates(
88378839 &LPTMap) {
88388840 for (auto &LPT : LateParsedTemplates) {
88398841 ModuleFile *FMod = LPT.first ;
8840- RecordDataImpl &LateParsed = LPT.second ;
8842+ RecordData &LateParsed = LPT.second ;
88418843 for (unsigned Idx = 0 , N = LateParsed.size (); Idx < N;
88428844 /* In loop */ ) {
88438845 FunctionDecl *FD = ReadDeclAs<FunctionDecl>(*FMod, LateParsed, Idx);
0 commit comments