From c264d35adcddd2fdafb5d002eb8bc639879078e1 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sun, 23 Mar 2014 02:30:01 +0000 Subject: 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 --- clang/lib/Serialization/ASTWriterDecl.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'clang/lib/Serialization/ASTWriterDecl.cpp') 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(D->getDeclContext()->getRedeclContext()); + if (NS && NS->isFromASTFile()) + Writer.AddUpdatedDeclContext(NS); + } } void ASTDeclWriter::VisitTranslationUnitDecl(TranslationUnitDecl *D) { -- cgit v1.2.3