r204392 - Refactor to move decl update emission into the decl emission loop.
Richard Smith
richard-llvm at metafoo.co.uk
Thu Mar 20 13:07:19 PDT 2014
Author: rsmith
Date: Thu Mar 20 15:07:19 2014
New Revision: 204392
URL: http://llvm.org/viewvc/llvm-project?rev=204392&view=rev
Log:
Refactor to move decl update emission into the decl emission loop.
Modified:
cfe/trunk/lib/Serialization/ASTWriter.cpp
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=204392&r1=204391&r2=204392&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Thu Mar 20 15:07:19 2014
@@ -4166,23 +4166,25 @@ void ASTWriter::WriteASTCore(Sema &SemaR
RecordData DeclUpdatesOffsetsRecord;
- // Keep writing types and declarations until all types and
- // declarations have been written.
+ // Keep writing types, declarations, and declaration update records
+ // until we've emitted all of them.
Stream.EnterSubblock(DECLTYPES_BLOCK_ID, NUM_ALLOWED_ABBREVS_SIZE);
WriteDeclsBlockAbbrevs();
for (DeclsToRewriteTy::iterator I = DeclsToRewrite.begin(),
E = DeclsToRewrite.end();
I != E; ++I)
DeclTypesToEmit.push(const_cast<Decl*>(*I));
- while (!DeclTypesToEmit.empty()) {
- DeclOrType DOT = DeclTypesToEmit.front();
- DeclTypesToEmit.pop();
- if (DOT.isType())
- WriteType(DOT.getType());
- else
- WriteDecl(Context, DOT.getDecl());
- }
- WriteDeclUpdatesBlocks(DeclUpdatesOffsetsRecord);
+ do {
+ WriteDeclUpdatesBlocks(DeclUpdatesOffsetsRecord);
+ while (!DeclTypesToEmit.empty()) {
+ DeclOrType DOT = DeclTypesToEmit.front();
+ DeclTypesToEmit.pop();
+ if (DOT.isType())
+ WriteType(DOT.getType());
+ else
+ WriteDecl(Context, DOT.getDecl());
+ }
+ } while (!DeclUpdates.empty());
Stream.ExitBlock();
if (!DeclUpdatesOffsetsRecord.empty())
@@ -4353,10 +4355,12 @@ void ASTWriter::WriteDeclUpdatesBlocks(R
if (DeclUpdates.empty())
return;
- for (DeclUpdateMap::iterator
- I = DeclUpdates.begin(), E = DeclUpdates.end(); I != E; ++I) {
- const Decl *D = I->first;
- UpdateRecord &URec = I->second;
+ DeclUpdateMap LocalUpdates;
+ LocalUpdates.swap(DeclUpdates);
+
+ for (auto &Update : LocalUpdates) {
+ const Decl *D = Update.first;
+ UpdateRecord &URec = Update.second;
if (isRewritten(D))
continue; // The decl will be written completely,no need to store updates.
More information about the cfe-commits
mailing list