diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-03-23 02:30:01 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-03-23 02:30:01 +0000 |
commit | c264d35adcddd2fdafb5d002eb8bc639879078e1 (patch) | |
tree | 2ca6d7b74332c7266b61f4d2a55ccc196b271337 /clang/lib/Serialization/ASTWriterDecl.cpp | |
parent | d3415c2440d9790d95e8f9f663b22ee0481c9696 (diff) | |
download | bcm5719-llvm-c264d35adcddd2fdafb5d002eb8bc639879078e1.tar.gz bcm5719-llvm-c264d35adcddd2fdafb5d002eb8bc639879078e1.zip |
If a template instantation introduces a name into a namespace, we need to write
out a visible update record for that namespace even if it was never declared in
this module.
llvm-svn: 204554
Diffstat (limited to 'clang/lib/Serialization/ASTWriterDecl.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTWriterDecl.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index d83b3ede38e..3aeb89559e7 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/lib/Serialization/ASTWriterDecl.cpp @@ -176,6 +176,18 @@ void ASTDeclWriter::VisitDecl(Decl *D) { Record.push_back(D->getAccess()); Record.push_back(D->isModulePrivate()); Record.push_back(Writer.inferSubmoduleIDFromLocation(D->getLocation())); + + // If this declaration injected a name into a context different from its + // lexical context, and that context is an imported namespace, we need to + // update its visible declarations to include this name. + // + // This happens when we instantiate a class with a friend declaration or a + // function with a local extern declaration, for instance. + if (D->isOutOfLine()) { + auto *NS = dyn_cast<NamespaceDecl>(D->getDeclContext()->getRedeclContext()); + if (NS && NS->isFromASTFile()) + Writer.AddUpdatedDeclContext(NS); + } } void ASTDeclWriter::VisitTranslationUnitDecl(TranslationUnitDecl *D) { |