From 20831e21ae00ee10e9d9d906f565a66f9fe1d2d1 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 25 May 2012 15:51:26 +0000 Subject: [PATCH] Consider the linkage for member class templates even when we have to ignore the visibility. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157475 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/Decl.cpp | 20 ++++++++++++++------ test/CodeGenCXX/visibility.cpp | 17 +++++++++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 979971c7c3..e8d7093a3f 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -546,14 +546,22 @@ static LinkageInfo getLVForClassMember(const NamedDecl *D, bool OnlyTemplate) { } else if (const CXXRecordDecl *RD = dyn_cast(D)) { if (const ClassTemplateSpecializationDecl *spec = dyn_cast(RD)) { + // Merge template argument/parameter information for member + // class template specializations. + const TemplateArgumentList &TemplateArgs = spec->getTemplateArgs(); + LinkageInfo ArgsLV = getLVForTemplateArgumentList(TemplateArgs, + OnlyTemplate); + TemplateParameterList *TemplateParams = + spec->getSpecializedTemplate()->getTemplateParameters(); + LinkageInfo ParamsLV = getLVForTemplateParameterList(TemplateParams); if (shouldConsiderTemplateVis(spec)) { - // Merge template argument/parameter information for member - // class template specializations. - LV.mergeWithMin(getLVForTemplateArgumentList(spec->getTemplateArgs(), - OnlyTemplate)); + LV.mergeWithMin(ArgsLV); if (!OnlyTemplate) - LV.merge(getLVForTemplateParameterList( - spec->getSpecializedTemplate()->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 d889684314..17ba33dabe 100644 --- a/test/CodeGenCXX/visibility.cpp +++ b/test/CodeGenCXX/visibility.cpp @@ -832,3 +832,20 @@ namespace test44 { // CHECK: define internal void @_ZN6test443fooINS_12_GLOBAL__N_13barEEC1Ev // CHECK-HIDDEN: define internal void @_ZN6test443fooINS_12_GLOBAL__N_13barEEC1Ev } + +namespace test45 { + template + struct foo { + template + struct bar { + bar() {}; + }; + }; + namespace { + struct zed; + } + template struct DEFAULT foo::bar; + foo::bar x; + // CHECK: define internal void @_ZN6test453fooIiE3barINS_12_GLOBAL__N_13zedEEC1Ev + // CHECK-HIDDEN: define internal void @_ZN6test453fooIiE3barINS_12_GLOBAL__N_13zedEEC1Ev +} -- 2.40.0