From: Rafael Espindola Date: Tue, 31 Jul 2012 19:02:02 +0000 (+0000) Subject: Consider the visibility of template template arguments. GCC doesn't, but it also X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=98499013bd70ec584f4c01c45106ec3e8203f16c;p=clang Consider the visibility of template template arguments. GCC doesn't, but it also fails to consider the linkage, which we were already considering. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161070 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index c98853adec..d5b0be3ba4 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -710,6 +710,10 @@ llvm::Optional NamedDecl::getExplicitVisibility() const { if (llvm::Optional V = getVisibilityOf(this)) return V; + // The visibility of a template is stored in the templated decl. + if (const TemplateDecl *TD = dyn_cast(this)) + return getVisibilityOf(TD->getTemplatedDecl()); + // If there wasn't explicit visibility there, and this is a // specialization of a class template, check for visibility // on the pattern. diff --git a/test/CodeGenCXX/visibility.cpp b/test/CodeGenCXX/visibility.cpp index d2f58f968d..014503911a 100644 --- a/test/CodeGenCXX/visibility.cpp +++ b/test/CodeGenCXX/visibility.cpp @@ -1094,3 +1094,21 @@ namespace test59 { // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test594testIXadL_ZNS_1fEvEEXadL_ZNS_1gEvEEEEvv } } + +namespace test60 { + template + class __attribute__((visibility("hidden"))) a {}; + template + class __attribute__((visibility("default"))) b {}; + template class x, template class y> + void test() {} + void use() { + test(); + // CHECK: define linkonce_odr hidden void @_ZN6test604testINS_1aENS_1bEEEvv + // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test604testINS_1aENS_1bEEEvv + + test(); + // CHECK: define linkonce_odr hidden void @_ZN6test604testINS_1bENS_1aEEEvv + // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test604testINS_1bENS_1aEEEvv + } +}