diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-03-20 20:07:19 +0000 | 
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-03-20 20:07:19 +0000 | 
| commit | 59442b4f3ad8dca79a68aef46069a5918b4e0880 (patch) | |
| tree | 9ab51e0017e018304ddd6baa8754c508139ac23a /clang/lib/Serialization | |
| parent | 9edbae0f161832f34e079cb3faab451adec2a35e (diff) | |
| download | bcm5719-llvm-59442b4f3ad8dca79a68aef46069a5918b4e0880.tar.gz bcm5719-llvm-59442b4f3ad8dca79a68aef46069a5918b4e0880.zip | |
Refactor to move decl update emission into the decl emission loop.
llvm-svn: 204392
Diffstat (limited to 'clang/lib/Serialization')
| -rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 34 | 
1 files changed, 19 insertions, 15 deletions
| diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 2967fb3486e..77228229b4d 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/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. | 

