@@ -4959,38 +4959,12 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
4959
4959
Stream.EmitRecord (METADATA_OLD_FORMAT, Record);
4960
4960
}
4961
4961
4962
- // Create a lexical update block containing all of the declarations in the
4963
- // translation unit that do not come from other AST files.
4964
4962
const TranslationUnitDecl *TU = Context.getTranslationUnitDecl ();
4965
- SmallVector<uint32_t , 128 > NewGlobalKindDeclPairs;
4966
- for (const auto *D : TU->noload_decls ()) {
4967
- if (!D->isFromASTFile ()) {
4968
- NewGlobalKindDeclPairs.push_back (D->getKind ());
4969
- NewGlobalKindDeclPairs.push_back (GetDeclRef (D));
4970
- }
4971
- }
4972
-
4973
- auto Abv = std::make_shared<BitCodeAbbrev>();
4974
- Abv->Add (llvm::BitCodeAbbrevOp (TU_UPDATE_LEXICAL));
4975
- Abv->Add (llvm::BitCodeAbbrevOp (llvm::BitCodeAbbrevOp::Blob));
4976
- unsigned TuUpdateLexicalAbbrev = Stream.EmitAbbrev (std::move (Abv));
4977
- {
4978
- RecordData::value_type Record[] = {TU_UPDATE_LEXICAL};
4979
- Stream.EmitRecordWithBlob (TuUpdateLexicalAbbrev, Record,
4980
- bytes (NewGlobalKindDeclPairs));
4981
- }
4982
4963
4983
- // And a visible updates block for the translation unit.
4984
- Abv = std::make_shared<BitCodeAbbrev>();
4985
- Abv->Add (llvm::BitCodeAbbrevOp (UPDATE_VISIBLE));
4986
- Abv->Add (llvm::BitCodeAbbrevOp (llvm::BitCodeAbbrevOp::VBR, 6 ));
4987
- Abv->Add (llvm::BitCodeAbbrevOp (llvm::BitCodeAbbrevOp::Blob));
4988
- UpdateVisibleAbbrev = Stream.EmitAbbrev (std::move (Abv));
4989
- WriteDeclContextVisibleUpdate (TU);
4990
-
4991
- // If we have any extern "C" names, write out a visible update for them.
4992
- if (Context.ExternCContext )
4993
- WriteDeclContextVisibleUpdate (Context.ExternCContext );
4964
+ // Force all top level declarations to be emitted.
4965
+ for (const auto *D : TU->noload_decls ())
4966
+ if (!D->isFromASTFile ())
4967
+ GetDeclRef (D);
4994
4968
4995
4969
// If the translation unit has an anonymous namespace, and we don't already
4996
4970
// have an update block for it, write it as an update block.
@@ -5131,6 +5105,14 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
5131
5105
for (auto *D : SemaRef.DeclsToCheckForDeferredDiags )
5132
5106
DeclsToCheckForDeferredDiags.push_back (GetDeclRef (D));
5133
5107
5108
+ {
5109
+ auto Abv = std::make_shared<BitCodeAbbrev>();
5110
+ Abv->Add (llvm::BitCodeAbbrevOp (UPDATE_VISIBLE));
5111
+ Abv->Add (llvm::BitCodeAbbrevOp (llvm::BitCodeAbbrevOp::VBR, 6 ));
5112
+ Abv->Add (llvm::BitCodeAbbrevOp (llvm::BitCodeAbbrevOp::Blob));
5113
+ UpdateVisibleAbbrev = Stream.EmitAbbrev (std::move (Abv));
5114
+ }
5115
+
5134
5116
RecordData DeclUpdatesOffsetsRecord;
5135
5117
5136
5118
// Keep writing types, declarations, and declaration update records
@@ -5158,6 +5140,35 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
5158
5140
WriteTypeDeclOffsets ();
5159
5141
if (!DeclUpdatesOffsetsRecord.empty ())
5160
5142
Stream.EmitRecord (DECL_UPDATE_OFFSETS, DeclUpdatesOffsetsRecord);
5143
+
5144
+ // Create a lexical update block containing all of the declarations in the
5145
+ // translation unit that do not come from other AST files.
5146
+ {
5147
+ SmallVector<uint32_t , 128 > NewGlobalKindDeclPairs;
5148
+ for (const auto *D : TU->noload_decls ()) {
5149
+ if (!D->isFromASTFile ()) {
5150
+ NewGlobalKindDeclPairs.push_back (D->getKind ());
5151
+ NewGlobalKindDeclPairs.push_back (GetDeclRef (D));
5152
+ }
5153
+ }
5154
+
5155
+ auto Abv = std::make_shared<BitCodeAbbrev>();
5156
+ Abv->Add (llvm::BitCodeAbbrevOp (TU_UPDATE_LEXICAL));
5157
+ Abv->Add (llvm::BitCodeAbbrevOp (llvm::BitCodeAbbrevOp::Blob));
5158
+ unsigned TuUpdateLexicalAbbrev = Stream.EmitAbbrev (std::move (Abv));
5159
+
5160
+ RecordData::value_type Record[] = {TU_UPDATE_LEXICAL};
5161
+ Stream.EmitRecordWithBlob (TuUpdateLexicalAbbrev, Record,
5162
+ bytes (NewGlobalKindDeclPairs));
5163
+ }
5164
+
5165
+ // And a visible updates block for the translation unit.
5166
+ WriteDeclContextVisibleUpdate (TU);
5167
+
5168
+ // If we have any extern "C" names, write out a visible update for them.
5169
+ if (Context.ExternCContext )
5170
+ WriteDeclContextVisibleUpdate (Context.ExternCContext );
5171
+
5161
5172
WriteFileDeclIDsMap ();
5162
5173
WriteSourceManagerBlock (Context.getSourceManager (), PP);
5163
5174
WriteComments ();
0 commit comments