summaryrefslogtreecommitdiff
path: root/lib/Serialization/ASTWriter.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-03-20 20:07:19 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-03-20 20:07:19 +0000
commitaeef5e23df0b28af557b01e4e8e2bac1f210eed2 (patch)
tree6c00e86ccf87a6893d66328a3d44ddfaf3b6968c /lib/Serialization/ASTWriter.cpp
parent7f817a7d8d2062cb805cf720467bb3306dae2b3f (diff)
downloadclang-aeef5e23df0b28af557b01e4e8e2bac1f210eed2.tar.gz
clang-aeef5e23df0b28af557b01e4e8e2bac1f210eed2.tar.bz2
clang-aeef5e23df0b28af557b01e4e8e2bac1f210eed2.tar.xz
Refactor to move decl update emission into the decl emission loop.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204392 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTWriter.cpp')
-rw-r--r--lib/Serialization/ASTWriter.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp
index 2967fb3486..77228229b4 100644
--- a/lib/Serialization/ASTWriter.cpp
+++ b/lib/Serialization/ASTWriter.cpp
@@ -4166,23 +4166,25 @@ void ASTWriter::WriteASTCore(Sema &SemaRef,
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(RecordDataImpl &OffsetsRecord) {
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.