diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-04-26 23:40:43 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-04-26 23:40:43 +0000 |
commit | d49941b726815de509ff770227856f8d2a33992a (patch) | |
tree | 43bcd11096ea1bc1d9afa2ea5591b79fd567fd22 /clang/lib/Serialization/ASTWriter.cpp | |
parent | c2bf63d29da43fa765189ec7b250bcb451b5934b (diff) | |
download | bcm5719-llvm-d49941b726815de509ff770227856f8d2a33992a.tar.gz bcm5719-llvm-d49941b726815de509ff770227856f8d2a33992a.zip |
PR27513: When determining which declaration to put into an exported lookup
table for a module / PCH, never map from a normal declaration of a class to an
injected-class-name declaration (or vice versa). Those declarations live in
distinct lookup tables and should not be confused.
We really shouldn't be using a CXXRecordDecl to represent an
injected-class-name in the first place; I've filed PR27532 so we don't forget.
llvm-svn: 267632
Diffstat (limited to 'clang/lib/Serialization/ASTWriter.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index e99beb360d1..073ed674741 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -3107,11 +3107,20 @@ static NamedDecl *getDeclForLocalLookup(const LangOptions &LangOpts, if (Decl *Redecl = D->getPreviousDecl()) { // For Redeclarable decls, a prior declaration might be local. for (; Redecl; Redecl = Redecl->getPreviousDecl()) { - if (!Redecl->isFromASTFile()) + // If we find a local decl, we're done. + if (!Redecl->isFromASTFile()) { + // Exception: in very rare cases (for injected-class-names), not all + // redeclarations are in the same semantic context. Skip ones in a + // different context. They don't go in this lookup table at all. + if (!Redecl->getDeclContext()->getRedeclContext()->Equals( + D->getDeclContext()->getRedeclContext())) + continue; return cast<NamedDecl>(Redecl); + } + // If we find a decl from a (chained-)PCH stop since we won't find a // local one. - if (D->getOwningModuleID() == 0) + if (Redecl->getOwningModuleID() == 0) break; } } else if (Decl *First = D->getCanonicalDecl()) { |