diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-02-07 03:37:08 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-02-07 03:37:08 +0000 |
commit | bbcd0f3ba215d5a8857b224e32b0330586a00dc6 (patch) | |
tree | 2308609a03b6cb5ad435da2773727698496a0777 /lib/Serialization | |
parent | 3646c68676c3c46a026b23d52188ef6e0d856178 (diff) |
Fix handling of module imports adding names to a DeclContext after qualified
name lookup has been performed in that context (this probably only happens in
C++).
1) Whenever we add names to a context, set a flag on it, and if we perform
lookup and discover that the context has had a lookup table built but has the
flag set, update all entries in the lookup table with additional names from
the external source.
2) When marking a DeclContext as having external visible decls, mark the
context in which lookup is performed, not the one we are adding. These won't
be the same if we're adding another copy of a pre-existing namespace.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174577 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization')
-rw-r--r-- | lib/Serialization/ASTReaderDecl.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index 469b3938ee..c2ace30782 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -2122,12 +2122,18 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) { // If this declaration is also a declaration context, get the // offsets for its tables of lexical and visible declarations. if (DeclContext *DC = dyn_cast<DeclContext>(D)) { + // FIXME: This should really be + // DeclContext *LookupDC = DC->getPrimaryContext(); + // but that can walk the redeclaration chain, which might not work yet. + DeclContext *LookupDC = DC; + if (isa<NamespaceDecl>(DC)) + LookupDC = DC->getPrimaryContext(); std::pair<uint64_t, uint64_t> Offsets = Reader.VisitDeclContext(DC); if (Offsets.first || Offsets.second) { if (Offsets.first != 0) DC->setHasExternalLexicalStorage(true); if (Offsets.second != 0) - DC->setHasExternalVisibleStorage(true); + LookupDC->setHasExternalVisibleStorage(true); if (ReadDeclContextStorage(*Loc.F, DeclsCursor, Offsets, Loc.F->DeclContextInfos[DC])) return 0; @@ -2139,7 +2145,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) { if (I != PendingVisibleUpdates.end()) { // There are updates. This means the context has external visible // storage, even if the original stored version didn't. - DC->setHasExternalVisibleStorage(true); + LookupDC->setHasExternalVisibleStorage(true); DeclContextVisibleUpdates &U = I->second; for (DeclContextVisibleUpdates::iterator UI = U.begin(), UE = U.end(); UI != UE; ++UI) { @@ -2150,8 +2156,9 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) { PendingVisibleUpdates.erase(I); } - if (!DC->hasExternalVisibleStorage() && DC->hasExternalLexicalStorage()) - DC->setMustBuildLookupTable(); + if (!LookupDC->hasExternalVisibleStorage() && + DC->hasExternalLexicalStorage()) + LookupDC->setMustBuildLookupTable(); } assert(Idx == Record.size()); |