@@ -10182,12 +10182,12 @@ void ASTReader::visitTopLevelModuleMaps(
10182
10182
}
10183
10183
10184
10184
void ASTReader::finishPendingActions () {
10185
- while (
10186
- !PendingIdentifierInfos. empty () || !PendingDeducedFunctionTypes.empty () ||
10187
- !PendingDeducedVarTypes.empty () || !PendingIncompleteDeclChains .empty () ||
10188
- !PendingDeclChains .empty () || !PendingMacroIDs .empty () ||
10189
- !PendingDeclContextInfos. empty () || !PendingUpdateRecords.empty () ||
10190
- !PendingObjCExtensionIvarRedeclarations.empty ()) {
10185
+ while (!PendingIdentifierInfos. empty () ||
10186
+ !PendingDeducedFunctionTypes.empty () ||
10187
+ !PendingDeducedVarTypes.empty () || !PendingDeclChains .empty () ||
10188
+ !PendingMacroIDs .empty () || !PendingDeclContextInfos .empty () ||
10189
+ !PendingUpdateRecords.empty () ||
10190
+ !PendingObjCExtensionIvarRedeclarations.empty ()) {
10191
10191
// If any identifiers with corresponding top-level declarations have
10192
10192
// been loaded, load those declarations now.
10193
10193
using TopLevelDeclsMap =
@@ -10235,13 +10235,6 @@ void ASTReader::finishPendingActions() {
10235
10235
}
10236
10236
PendingDeducedVarTypes.clear ();
10237
10237
10238
- // For each decl chain that we wanted to complete while deserializing, mark
10239
- // it as "still needs to be completed".
10240
- for (unsigned I = 0 ; I != PendingIncompleteDeclChains.size (); ++I) {
10241
- markIncompleteDeclChain (PendingIncompleteDeclChains[I]);
10242
- }
10243
- PendingIncompleteDeclChains.clear ();
10244
-
10245
10238
// Load pending declaration chains.
10246
10239
for (unsigned I = 0 ; I != PendingDeclChains.size (); ++I)
10247
10240
loadPendingDeclChain (PendingDeclChains[I].first ,
@@ -10479,6 +10472,43 @@ void ASTReader::finishPendingActions() {
10479
10472
for (auto *ND : PendingMergedDefinitionsToDeduplicate)
10480
10473
getContext ().deduplicateMergedDefinitonsFor (ND);
10481
10474
PendingMergedDefinitionsToDeduplicate.clear ();
10475
+
10476
+ // For each decl chain that we wanted to complete while deserializing, mark
10477
+ // it as "still needs to be completed".
10478
+ for (Decl *D : PendingIncompleteDeclChains)
10479
+ markIncompleteDeclChain (D);
10480
+ PendingIncompleteDeclChains.clear ();
10481
+
10482
+ assert (PendingIdentifierInfos.empty () &&
10483
+ " Should be empty at the end of finishPendingActions" );
10484
+ assert (PendingDeducedFunctionTypes.empty () &&
10485
+ " Should be empty at the end of finishPendingActions" );
10486
+ assert (PendingDeducedVarTypes.empty () &&
10487
+ " Should be empty at the end of finishPendingActions" );
10488
+ assert (PendingDeclChains.empty () &&
10489
+ " Should be empty at the end of finishPendingActions" );
10490
+ assert (PendingMacroIDs.empty () &&
10491
+ " Should be empty at the end of finishPendingActions" );
10492
+ assert (PendingDeclContextInfos.empty () &&
10493
+ " Should be empty at the end of finishPendingActions" );
10494
+ assert (PendingUpdateRecords.empty () &&
10495
+ " Should be empty at the end of finishPendingActions" );
10496
+ assert (PendingObjCExtensionIvarRedeclarations.empty () &&
10497
+ " Should be empty at the end of finishPendingActions" );
10498
+ assert (PendingFakeDefinitionData.empty () &&
10499
+ " Should be empty at the end of finishPendingActions" );
10500
+ assert (PendingDefinitions.empty () &&
10501
+ " Should be empty at the end of finishPendingActions" );
10502
+ assert (PendingWarningForDuplicatedDefsInModuleUnits.empty () &&
10503
+ " Should be empty at the end of finishPendingActions" );
10504
+ assert (PendingBodies.empty () &&
10505
+ " Should be empty at the end of finishPendingActions" );
10506
+ assert (PendingAddedClassMembers.empty () &&
10507
+ " Should be empty at the end of finishPendingActions" );
10508
+ assert (PendingMergedDefinitionsToDeduplicate.empty () &&
10509
+ " Should be empty at the end of finishPendingActions" );
10510
+ assert (PendingIncompleteDeclChains.empty () &&
10511
+ " Should be empty at the end of finishPendingActions" );
10482
10512
}
10483
10513
10484
10514
void ASTReader::diagnoseOdrViolations () {
@@ -10792,47 +10822,54 @@ void ASTReader::FinishedDeserializing() {
10792
10822
--NumCurrentElementsDeserializing;
10793
10823
10794
10824
if (NumCurrentElementsDeserializing == 0 ) {
10795
- // Propagate exception specification and deduced type updates along
10796
- // redeclaration chains.
10797
- //
10798
- // We do this now rather than in finishPendingActions because we want to
10799
- // be able to walk the complete redeclaration chains of the updated decls.
10800
- while (!PendingExceptionSpecUpdates.empty () ||
10801
- !PendingDeducedTypeUpdates.empty () ||
10802
- !PendingUndeducedFunctionDecls.empty ()) {
10803
- auto ESUpdates = std::move (PendingExceptionSpecUpdates);
10804
- PendingExceptionSpecUpdates.clear ();
10805
- for (auto Update : ESUpdates) {
10806
- ProcessingUpdatesRAIIObj ProcessingUpdates (*this );
10807
- auto *FPT = Update.second ->getType ()->castAs <FunctionProtoType>();
10808
- auto ESI = FPT->getExtProtoInfo ().ExceptionSpec ;
10809
- if (auto *Listener = getContext ().getASTMutationListener ())
10810
- Listener->ResolvedExceptionSpec (cast<FunctionDecl>(Update.second ));
10811
- for (auto *Redecl : Update.second ->redecls ())
10812
- getContext ().adjustExceptionSpec (cast<FunctionDecl>(Redecl), ESI);
10813
- }
10825
+ {
10826
+ // Guard variable to avoid recursively entering the process of passing
10827
+ // decls to consumer.
10828
+ SaveAndRestore GuardPassingDeclsToConsumer (CanPassDeclsToConsumer, false );
10814
10829
10815
- auto DTUpdates = std::move (PendingDeducedTypeUpdates);
10816
- PendingDeducedTypeUpdates.clear ();
10817
- for (auto Update : DTUpdates) {
10818
- ProcessingUpdatesRAIIObj ProcessingUpdates (*this );
10819
- // FIXME: If the return type is already deduced, check that it matches.
10820
- getContext ().adjustDeducedFunctionResultType (Update.first ,
10821
- Update.second );
10822
- }
10830
+ // Propagate exception specification and deduced type updates along
10831
+ // redeclaration chains.
10832
+ //
10833
+ // We do this now rather than in finishPendingActions because we want to
10834
+ // be able to walk the complete redeclaration chains of the updated decls.
10835
+ while (!PendingExceptionSpecUpdates.empty () ||
10836
+ !PendingDeducedTypeUpdates.empty () ||
10837
+ !PendingUndeducedFunctionDecls.empty ()) {
10838
+ auto ESUpdates = std::move (PendingExceptionSpecUpdates);
10839
+ PendingExceptionSpecUpdates.clear ();
10840
+ for (auto Update : ESUpdates) {
10841
+ ProcessingUpdatesRAIIObj ProcessingUpdates (*this );
10842
+ auto *FPT = Update.second ->getType ()->castAs <FunctionProtoType>();
10843
+ auto ESI = FPT->getExtProtoInfo ().ExceptionSpec ;
10844
+ if (auto *Listener = getContext ().getASTMutationListener ())
10845
+ Listener->ResolvedExceptionSpec (cast<FunctionDecl>(Update.second ));
10846
+ for (auto *Redecl : Update.second ->redecls ())
10847
+ getContext ().adjustExceptionSpec (cast<FunctionDecl>(Redecl), ESI);
10848
+ }
10823
10849
10824
- auto UDTUpdates = std::move (PendingUndeducedFunctionDecls);
10825
- PendingUndeducedFunctionDecls.clear ();
10826
- // We hope we can find the deduced type for the functions by iterating
10827
- // redeclarations in other modules.
10828
- for (FunctionDecl *UndeducedFD : UDTUpdates)
10829
- (void )UndeducedFD->getMostRecentDecl ();
10830
- }
10850
+ auto DTUpdates = std::move (PendingDeducedTypeUpdates);
10851
+ PendingDeducedTypeUpdates.clear ();
10852
+ for (auto Update : DTUpdates) {
10853
+ ProcessingUpdatesRAIIObj ProcessingUpdates (*this );
10854
+ // FIXME: If the return type is already deduced, check that it
10855
+ // matches.
10856
+ getContext ().adjustDeducedFunctionResultType (Update.first ,
10857
+ Update.second );
10858
+ }
10831
10859
10832
- if (ReadTimer)
10833
- ReadTimer->stopTimer ();
10860
+ auto UDTUpdates = std::move (PendingUndeducedFunctionDecls);
10861
+ PendingUndeducedFunctionDecls.clear ();
10862
+ // We hope we can find the deduced type for the functions by iterating
10863
+ // redeclarations in other modules.
10864
+ for (FunctionDecl *UndeducedFD : UDTUpdates)
10865
+ (void )UndeducedFD->getMostRecentDecl ();
10866
+ }
10867
+
10868
+ if (ReadTimer)
10869
+ ReadTimer->stopTimer ();
10834
10870
10835
- diagnoseOdrViolations ();
10871
+ diagnoseOdrViolations ();
10872
+ }
10836
10873
10837
10874
// We are not in recursive loading, so it's safe to pass the "interesting"
10838
10875
// decls to the consumer.
0 commit comments