diff options
author | Vassil Vassilev <v.g.vassilev@gmail.com> | 2016-03-16 11:17:04 +0000 |
---|---|---|
committer | Vassil Vassilev <v.g.vassilev@gmail.com> | 2016-03-16 11:17:04 +0000 |
commit | 632eac34281c922bb52d30762bdc7115aa925698 (patch) | |
tree | 70fc9e997018b8460a3667ac6b189d95564889d1 /clang/lib/Serialization/ASTWriter.cpp | |
parent | d3fe3aa57f1f2ddc51462f049c4f42d60823070b (diff) | |
download | bcm5719-llvm-632eac34281c922bb52d30762bdc7115aa925698.tar.gz bcm5719-llvm-632eac34281c922bb52d30762bdc7115aa925698.zip |
[modules] Fix adding a templated friend functions to a namespace from another module.
When clang adds argument dependent lookup candidates, it can perform template
instantiation. For example, it can instantiate a templated friend function and
register it in the enclosing namespace's lookup table.
Fixes https://llvm.org/bugs/show_bug.cgi?id=24954
Reviewed by Richard Smith.
llvm-svn: 263634
Diffstat (limited to 'clang/lib/Serialization/ASTWriter.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index ee475d3cc52..3e04bc5ad7d 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -5751,8 +5751,16 @@ static bool isImportedDeclContext(ASTReader *Chain, const Decl *D) { } void ASTWriter::AddedVisibleDecl(const DeclContext *DC, const Decl *D) { - // TU and namespaces are handled elsewhere. - if (isa<TranslationUnitDecl>(DC) || isa<NamespaceDecl>(DC)) + // TU is handled elsewhere. + if (isa<TranslationUnitDecl>(DC)) + return; + + // Namespaces are handled elsewhere, except for template instantiations of + // FunctionTemplateDecls in namespaces. We are interested in cases where the + // local instantiations are added to an imported context. Only happens when + // adding ADL lookup candidates, for example templated friends. + if (isa<NamespaceDecl>(DC) && D->getFriendObjectKind() == Decl::FOK_None && + !isa<FunctionTemplateDecl>(D)) return; // We're only interested in cases where a local declaration is added to an |