diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2012-05-25 16:41:35 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2012-05-25 16:41:35 +0000 |
commit | 340941dc16c83752975d713910fa1c42f95595ca (patch) | |
tree | 1400222322e7690910d8eebb5949fa05bb244607 | |
parent | aa58397b3ce17ec4fed008150911111c7025fc91 (diff) | |
download | bcm5719-llvm-340941dc16c83752975d713910fa1c42f95595ca.tar.gz bcm5719-llvm-340941dc16c83752975d713910fa1c42f95595ca.zip |
Don't ignore linkage when ignoring visibility in the instantiation of a
function template.
llvm-svn: 157480
-rw-r--r-- | clang/lib/AST/Decl.cpp | 20 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/visibility.cpp | 15 |
2 files changed, 27 insertions, 8 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index e8d7093a3fe..405c2b328f9 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -158,7 +158,7 @@ getLVForTemplateArgumentList(const TemplateArgumentList &TArgs, return getLVForTemplateArgumentList(TArgs.data(), TArgs.size(), OnlyTemplate); } -static bool shouldConsiderTemplateLV(const FunctionDecl *fn, +static bool shouldConsiderTemplateVis(const FunctionDecl *fn, const FunctionTemplateSpecializationInfo *spec) { return !fn->hasAttr<VisibilityAttr>() || spec->isExplicitSpecialization(); } @@ -376,12 +376,16 @@ static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D, // this is an explicit specialization with a visibility attribute. if (FunctionTemplateSpecializationInfo *specInfo = Function->getTemplateSpecializationInfo()) { - if (shouldConsiderTemplateLV(Function, specInfo)) { - LV.merge(getLVForDecl(specInfo->getTemplate(), - true)); - const TemplateArgumentList &templateArgs = *specInfo->TemplateArguments; - LV.mergeWithMin(getLVForTemplateArgumentList(templateArgs, - OnlyTemplate)); + LinkageInfo TempLV = getLVForDecl(specInfo->getTemplate(), true); + const TemplateArgumentList &templateArgs = *specInfo->TemplateArguments; + LinkageInfo ArgsLV = getLVForTemplateArgumentList(templateArgs, + OnlyTemplate); + if (shouldConsiderTemplateVis(Function, specInfo)) { + LV.merge(TempLV); + LV.mergeWithMin(ArgsLV); + } else { + LV.mergeLinkage(TempLV); + LV.mergeLinkage(ArgsLV); } } @@ -531,7 +535,7 @@ static LinkageInfo getLVForClassMember(const NamedDecl *D, bool OnlyTemplate) { // the template parameters and arguments. if (FunctionTemplateSpecializationInfo *spec = MD->getTemplateSpecializationInfo()) { - if (shouldConsiderTemplateLV(MD, spec)) { + if (shouldConsiderTemplateVis(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 17ba33dabe8..20359a441dd 100644 --- a/clang/test/CodeGenCXX/visibility.cpp +++ b/clang/test/CodeGenCXX/visibility.cpp @@ -849,3 +849,18 @@ namespace test45 { // CHECK: define internal void @_ZN6test453fooIiE3barINS_12_GLOBAL__N_13zedEEC1Ev // CHECK-HIDDEN: define internal void @_ZN6test453fooIiE3barINS_12_GLOBAL__N_13zedEEC1Ev } + +namespace test46 { + template <typename T> + void foo() { + } + namespace { + struct bar; + } + template DEFAULT void foo<bar>(); + void zed() { + foo<bar>(); + } + // CHECK: define internal void @_ZN6test463fooINS_12_GLOBAL__N_13barEEEvv + // CHECK-HIDDEN: define internal void @_ZN6test463fooINS_12_GLOBAL__N_13barEEEvv +} |