Consider the visibility of template template arguments. GCC doesn't, but it also

fails to consider the linkage, which we were already considering.

llvm-svn: 161070
This commit is contained in:
Rafael Espindola 2012-07-31 19:02:02 +00:00
parent 3a810eda91
commit fb4263f156
2 changed files with 22 additions and 0 deletions

View File

@ -710,6 +710,10 @@ llvm::Optional<Visibility> NamedDecl::getExplicitVisibility() const {
if (llvm::Optional<Visibility> V = getVisibilityOf(this))
return V;
// The visibility of a template is stored in the templated decl.
if (const TemplateDecl *TD = dyn_cast<TemplateDecl>(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.

View File

@ -1094,3 +1094,21 @@ namespace test59 {
// CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test594testIXadL_ZNS_1fEvEEXadL_ZNS_1gEvEEEEvv
}
}
namespace test60 {
template<int i>
class __attribute__((visibility("hidden"))) a {};
template<int i>
class __attribute__((visibility("default"))) b {};
template<template<int> class x, template<int> class y>
void test() {}
void use() {
test<a, b>();
// CHECK: define linkonce_odr hidden void @_ZN6test604testINS_1aENS_1bEEEvv
// CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test604testINS_1aENS_1bEEEvv
test<b, a>();
// CHECK: define linkonce_odr hidden void @_ZN6test604testINS_1bENS_1aEEEvv
// CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test604testINS_1bENS_1aEEEvv
}
}