diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-15 16:58:34 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-15 16:58:34 +0000 |
commit | 2171bf1caba4d4b9eeb6a91efac4300b41f38b07 (patch) | |
tree | 98cfad2375715b064a068eb3cf8a527a1e88946e /lib/Serialization/ASTReader.cpp | |
parent | 3419d7cd2e4a4dcd2a88381deb5d83eb946a2b93 (diff) |
Completely re-implement (de-)serialization of redeclaration
chains, again. The prior implementation was very linked-list oriented, and
the list-splicing logic was both fairly convoluted (when loading from
multiple modules) and failed to preserve a reasonable ordering for the
redeclaration chains.
This new implementation uses a simpler strategy, where we store the
ordered redeclaration chains in an array-like structure (indexed based
on the first declaration), and use that ordering to add individual
deserialized declarations to the end of the existing chain. That way,
the chain mimics the ordering from its modules, and a bug somewhere is
far less likely to result in a broken linked list.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148222 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTReader.cpp')
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 2417845ff7..7fc5a1d777 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -2396,15 +2396,20 @@ ASTReader::ReadASTBlock(ModuleFile &F) { } break; } - + case LOCAL_REDECLARATIONS: { - if (F.LocalNumRedeclarationsInfos != 0) { - Error("duplicate LOCAL_REDECLARATIONS record in AST file"); + F.RedeclarationChains.swap(Record); + break; + } + + case LOCAL_REDECLARATIONS_MAP: { + if (F.LocalNumRedeclarationsInMap != 0) { + Error("duplicate LOCAL_REDECLARATIONS_MAP record in AST file"); return Failure; } - F.LocalNumRedeclarationsInfos = Record[0]; - F.RedeclarationsInfo = (const LocalRedeclarationsInfo *)BlobStart; + F.LocalNumRedeclarationsInMap = Record[0]; + F.RedeclarationsMap = (const LocalRedeclarationsInfo *)BlobStart; break; } @@ -6118,7 +6123,6 @@ void ASTReader::ClearSwitchCaseIDs() { void ASTReader::finishPendingActions() { while (!PendingIdentifierInfos.empty() || - !PendingPreviousDecls.empty() || !PendingDeclChains.empty() || !PendingChainedObjCCategories.empty()) { @@ -6130,13 +6134,6 @@ void ASTReader::finishPendingActions() { PendingIdentifierInfos.pop_front(); } - // Ready to load previous declarations of Decls that were delayed. - while (!PendingPreviousDecls.empty()) { - loadAndAttachPreviousDecl(PendingPreviousDecls.front().first, - PendingPreviousDecls.front().second); - PendingPreviousDecls.pop_front(); - } - // Load pending declaration chains. for (unsigned I = 0; I != PendingDeclChains.size(); ++I) { loadPendingDeclChain(PendingDeclChains[I]); |