]> granicus.if.org Git - clang/commitdiff
Function template version of the previous patch.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 21 May 2012 20:31:27 +0000 (20:31 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 21 May 2012 20:31:27 +0000 (20:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157207 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Decl.cpp
test/CodeGenCXX/visibility.cpp

index 8bc9eb396e3499ad7f3013a689c0e72067ddf1a6..62cc62ae39e0b3f6ebe104f81e2c21dce0c1b290 100644 (file)
@@ -158,8 +158,9 @@ getLVForTemplateArgumentList(const TemplateArgumentList &TArgs,
   return getLVForTemplateArgumentList(TArgs.data(), TArgs.size(), OnlyTemplate);
 }
 
-static bool shouldConsiderTemplateLV(const FunctionDecl *fn) {
-  return !fn->hasAttr<VisibilityAttr>();
+static bool shouldConsiderTemplateLV(const FunctionDecl *fn,
+                               const FunctionTemplateSpecializationInfo *spec) {
+  return !fn->hasAttr<VisibilityAttr>() || 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)
index be4348ee93f999bd3b4e770bca8a655ff7bdcd48..587030854d1aad96bf83a2ee6d008212ba1fea68 100644 (file)
@@ -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 <class P>
+  void bar() {
+  }
+  template <>
+  DEFAULT void bar<foo>() {
+  }
+  // CHECK: define hidden void @_ZN6test433barINS_3fooEEEvv
+  // CHECK-HIDDEN: define hidden void @_ZN6test433barINS_3fooEEEvv
+}