diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-10-01 01:18:02 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-10-01 01:18:02 +0000 |
commit | 3747ee72e1751a4996711b9ae5e14f2ca5d4516f (patch) | |
tree | 8e5376c0ec0b32885000cef9e6549ab1c6536bbe | |
parent | 05adedcb5e199e377e35f576288caf5ceed40136 (diff) |
If we get a TU_CONTEXT update from a chained PCH file before we
actually have an ASTContext, delay the processing of that
update. Patch by Sebastian Redl! Fixes <rdar://problem/8499034>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115263 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index d7636079a4..7b4264d51c 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -1768,7 +1768,8 @@ ASTReader::ReadASTBlock(PerFileData &F) { reinterpret_cast<const DeclID *>(BlobStart), BlobLen / sizeof(DeclID) }; - DeclContextOffsets[Context->getTranslationUnitDecl()].push_back(Info); + DeclContextOffsets[Context ? Context->getTranslationUnitDecl() : 0] + .push_back(Info); break; } @@ -1778,7 +1779,7 @@ ASTReader::ReadASTBlock(PerFileData &F) { (const unsigned char *)BlobStart + Record[1], (const unsigned char *)BlobStart, ASTDeclContextNameLookupTrait(*this)); - if (ID == 1) { // Is it the TU? + if (ID == 1 && Context) { // Is it the TU? DeclContextInfo Info = { Table, /* No lexical inforamtion */ 0, 0 }; @@ -2229,6 +2230,17 @@ void ASTReader::InitializeContext(ASTContext &Ctx) { PP->getHeaderSearchInfo().SetExternalLookup(this); PP->setExternalSource(this); + // If we have an update block for the TU waiting, we have to add it before + // deserializing the decl. + DeclContextOffsetsMap::iterator DCU = DeclContextOffsets.find(0); + if (DCU != DeclContextOffsets.end()) { + // Insertion could invalidate map, so grab vector. + DeclContextInfos T; + T.swap(DCU->second); + DeclContextOffsets.erase(DCU); + DeclContextOffsets[Ctx.getTranslationUnitDecl()].swap(T); + } + // Load the translation unit declaration GetTranslationUnitDecl(); |