[serialization] Anything we write can queue up more things to write.

Flatten several nested loops that tried to take care of this into a single
outer loop-until-really-done loop.

No test case; this is a preventative measure, not a response to an actual bug.

Swift SVN r26823
This commit is contained in:
Jordan Rose
2015-04-01 21:18:48 +00:00
parent e9074c4cb8
commit 19470bce90

View File

@@ -3059,25 +3059,29 @@ void Serializer::writeAllDeclsAndTypes() {
registerDeclTypeAbbr<NAME##DeclAttrLayout>();
#include "swift/AST/Attr.def"
while (!DeclsAndTypesToWrite.empty()) {
auto next = DeclsAndTypesToWrite.front();
DeclsAndTypesToWrite.pop();
do {
// Each of these loops can trigger the others to execute again, so repeat
// until /all/ of the pending lists are empty.
while (!DeclsAndTypesToWrite.empty()) {
auto next = DeclsAndTypesToWrite.front();
DeclsAndTypesToWrite.pop();
if (next.isDecl())
writeDecl(next.getDecl());
else
writeType(next.getType());
if (next.isDecl())
writeDecl(next.getDecl());
else
writeType(next.getType());
}
while (!LocalDeclContextsToWrite.empty()) {
auto next = LocalDeclContextsToWrite.front();
LocalDeclContextsToWrite.pop();
writeLocalDeclContext(next);
}
while (!DeclContextsToWrite.empty()) {
auto next = DeclContextsToWrite.front();
DeclContextsToWrite.pop();
writeDeclContext(next);
while (!LocalDeclContextsToWrite.empty()) {
auto next = LocalDeclContextsToWrite.front();
LocalDeclContextsToWrite.pop();
writeLocalDeclContext(next);
}
}
while (!NormalConformancesToWrite.empty()) {
@@ -3085,7 +3089,10 @@ void Serializer::writeAllDeclsAndTypes() {
NormalConformancesToWrite.pop();
writeNormalConformance(next);
}
}
} while (!DeclsAndTypesToWrite.empty() ||
!LocalDeclContextsToWrite.empty() ||
!DeclContextsToWrite.empty() ||
!NormalConformancesToWrite.empty());
}
void Serializer::writeAllIdentifiers() {