From 96dcb8d4bb88f723696dccd9aa513cd4d0e7a028 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 21 May 2012 20:31:27 +0000 Subject: [PATCH] Function template version of the previous patch. llvm-svn: 157207 --- clang/lib/AST/Decl.cpp | 9 +++++---- clang/test/CodeGenCXX/visibility.cpp | 13 +++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 8bc9eb396e34..62cc62ae39e0 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -158,8 +158,9 @@ getLVForTemplateArgumentList(const TemplateArgumentList &TArgs, return getLVForTemplateArgumentList(TArgs.data(), TArgs.size(), OnlyTemplate); } -static bool shouldConsiderTemplateLV(const FunctionDecl *fn) { - return !fn->hasAttr(); +static bool shouldConsiderTemplateLV(const FunctionDecl *fn, + const FunctionTemplateSpecializationInfo *spec) { + return !fn->hasAttr() || spec->isExplicitSpecialization(); } static bool shouldConsiderTemplateLV(const ClassTemplateSpecializationDecl *d) { @@ -374,7 +375,7 @@ static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D, // this is an explicit specialization with a visibility attribute. if (FunctionTemplateSpecializationInfo *specInfo = Function->getTemplateSpecializationInfo()) { - if (shouldConsiderTemplateLV(Function)) { + if (shouldConsiderTemplateLV(Function, specInfo)) { LV.merge(getLVForDecl(specInfo->getTemplate(), true)); const TemplateArgumentList &templateArgs = *specInfo->TemplateArguments; @@ -525,7 +526,7 @@ static LinkageInfo getLVForClassMember(const NamedDecl *D, bool OnlyTemplate) { // the template parameters and arguments. if (FunctionTemplateSpecializationInfo *spec = MD->getTemplateSpecializationInfo()) { - if (shouldConsiderTemplateLV(MD)) { + if (shouldConsiderTemplateLV(MD, spec)) { LV.mergeWithMin(getLVForTemplateArgumentList(*spec->TemplateArguments, OnlyTemplate)); if (!OnlyTemplate) diff --git a/clang/test/CodeGenCXX/visibility.cpp b/clang/test/CodeGenCXX/visibility.cpp index be4348ee93f9..587030854d1a 100644 --- a/clang/test/CodeGenCXX/visibility.cpp +++ b/clang/test/CodeGenCXX/visibility.cpp @@ -805,3 +805,16 @@ namespace test42 { // CHECK: define hidden void @_ZN6test423barINS_3fooEE3zedEv // CHECK-HIDDEN: define hidden void @_ZN6test423barINS_3fooEE3zedEv } + +namespace test43 { + struct HIDDEN foo { + }; + template + void bar() { + } + template <> + DEFAULT void bar() { + } + // CHECK: define hidden void @_ZN6test433barINS_3fooEEEvv + // CHECK-HIDDEN: define hidden void @_ZN6test433barINS_3fooEEEvv +}