diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2012-05-25 17:22:33 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2012-05-25 17:22:33 +0000 |
commit | 41be8cd0593f2e08e41eed218e1b91f419e829a1 (patch) | |
tree | ba417dc730dd4f49404abd1f28cad14f5a9e505b | |
parent | 2813420dd3be04fc0c44074c3f1af1aada83ad99 (diff) |
Don't ignore linkage when ignoring visibility in the instantiation of a
method template.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157486 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/Decl.cpp | 16 | ||||
-rw-r--r-- | test/CodeGenCXX/visibility.cpp | 17 |
2 files changed, 29 insertions, 4 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 405c2b328f..0ca36cbb14 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -535,12 +535,20 @@ static LinkageInfo getLVForClassMember(const NamedDecl *D, bool OnlyTemplate) { // the template parameters and arguments. if (FunctionTemplateSpecializationInfo *spec = MD->getTemplateSpecializationInfo()) { + const TemplateArgumentList &TemplateArgs = *spec->TemplateArguments; + LinkageInfo ArgsLV = getLVForTemplateArgumentList(TemplateArgs, + OnlyTemplate); + TemplateParameterList *TemplateParams = + spec->getTemplate()->getTemplateParameters(); + LinkageInfo ParamsLV = getLVForTemplateParameterList(TemplateParams); if (shouldConsiderTemplateVis(MD, spec)) { - LV.mergeWithMin(getLVForTemplateArgumentList(*spec->TemplateArguments, - OnlyTemplate)); + LV.mergeWithMin(ArgsLV); if (!OnlyTemplate) - LV.merge(getLVForTemplateParameterList( - spec->getTemplate()->getTemplateParameters())); + LV.merge(ParamsLV); + } else { + LV.mergeLinkage(ArgsLV); + if (!OnlyTemplate) + LV.mergeLinkage(ParamsLV); } } diff --git a/test/CodeGenCXX/visibility.cpp b/test/CodeGenCXX/visibility.cpp index 20359a441d..d302214df4 100644 --- a/test/CodeGenCXX/visibility.cpp +++ b/test/CodeGenCXX/visibility.cpp @@ -864,3 +864,20 @@ namespace test46 { // CHECK: define internal void @_ZN6test463fooINS_12_GLOBAL__N_13barEEEvv // CHECK-HIDDEN: define internal void @_ZN6test463fooINS_12_GLOBAL__N_13barEEEvv } + +namespace test47 { + struct foo { + template <typename T> + static void bar() { + } + }; + namespace { + struct zed; + } + template __attribute__((visibility("default"))) void foo::bar<zed>(); + void baz() { + foo::bar<zed>(); + } + // CHECK: define internal void @_ZN6test473foo3barINS_12_GLOBAL__N_13zedEEEvv + // CHECK-HIDDEN: define internal void @_ZN6test473foo3barINS_12_GLOBAL__N_13zedEEEvv +} |