diff options
author | John McCall <rjmccall@apple.com> | 2009-08-29 03:16:09 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2009-08-29 03:16:09 +0000 |
commit | 970d530a8452591d5ee5ccd58684e2f7250508a4 (patch) | |
tree | c90dc10c731b93c651b53d1cd671a3c2ad567365 /clang/lib/Sema/SemaTemplateInstantiate.cpp | |
parent | 6fd66d458812cd66441f7ae9da2310e50f4c4075 (diff) | |
download | bcm5719-llvm-970d530a8452591d5ee5ccd58684e2f7250508a4.tar.gz bcm5719-llvm-970d530a8452591d5ee5ccd58684e2f7250508a4.zip |
Ensure code generation for friend declarations in class templates.
llvm-svn: 80418
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiate.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 4cb5a276e64..521394b978a 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -37,7 +37,7 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D) { if (!Ctx) Ctx = D->getDeclContext(); - for (; !Ctx->isFileContext(); Ctx = Ctx->getParent()) { + while (!Ctx->isFileContext()) { // Add template arguments from a class template instantiation. if (ClassTemplateSpecializationDecl *Spec = dyn_cast<ClassTemplateSpecializationDecl>(Ctx)) { @@ -46,18 +46,26 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D) { break; Result.addOuterTemplateArguments(&Spec->getTemplateInstantiationArgs()); - continue; } // Add template arguments from a function template specialization. - if (FunctionDecl *Function = dyn_cast<FunctionDecl>(Ctx)) { + else if (FunctionDecl *Function = dyn_cast<FunctionDecl>(Ctx)) { // FIXME: Check whether this is an explicit specialization. if (const TemplateArgumentList *TemplateArgs = Function->getTemplateSpecializationArgs()) Result.addOuterTemplateArguments(TemplateArgs); - - continue; + + // If this is a friend declaration and it declares an entity at + // namespace scope, take arguments from its lexical parent + // instead of its semantic parent. + if (Function->getFriendObjectKind() && + Function->getDeclContext()->isFileContext()) { + Ctx = Function->getLexicalDeclContext(); + continue; + } } + + Ctx = Ctx->getParent(); } return Result; |