aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2012-07-12 20:05:04 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2012-07-12 20:05:04 +0000
commit23458208b25acd7d2dfa003b029299e30124fe5f (patch)
tree48169d8787293385986aa2e8460594cfbb016196
parent59d7cc9e4c376c12d4fa2c30337761dbec94e92d (diff)
Use the canonical template decl when trying to find if it has a visibility
attribute. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160139 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AST/Decl.cpp6
-rw-r--r--test/CodeGenCXX/visibility.cpp13
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 33826cbb46..2066a98984 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -702,8 +702,10 @@ llvm::Optional<Visibility> NamedDecl::getExplicitVisibility() const {
// specialization of a class template, check for visibility
// on the pattern.
if (const ClassTemplateSpecializationDecl *spec
- = dyn_cast<ClassTemplateSpecializationDecl>(this))
- return getVisibilityOf(spec->getSpecializedTemplate()->getTemplatedDecl());
+ = dyn_cast<ClassTemplateSpecializationDecl>(this)) {
+ ClassTemplateDecl *TD = spec->getSpecializedTemplate()->getCanonicalDecl();
+ return getVisibilityOf(TD->getTemplatedDecl());
+ }
// If this is a member class of a specialization of a class template
// and the corresponding decl has explicit visibility, use that.
diff --git a/test/CodeGenCXX/visibility.cpp b/test/CodeGenCXX/visibility.cpp
index 583293be52..94fb290ad1 100644
--- a/test/CodeGenCXX/visibility.cpp
+++ b/test/CodeGenCXX/visibility.cpp
@@ -1018,3 +1018,16 @@ namespace test54 {
// CHECK: declare hidden void @_ZN6test543fooINS_3zedEE3barEv
// CHECK-HIDDEN: declare hidden void @_ZN6test543fooINS_3zedEE3barEv
}
+
+namespace test55 {
+ template <class T>
+ struct __attribute__((visibility("hidden"))) foo {
+ static void bar();
+ };
+ template <class T> struct foo;
+ void foobar() {
+ foo<int>::bar();
+ }
+ // CHECK: declare hidden void @_ZN6test553fooIiE3barEv
+ // CHECK-HIDDEN: declare hidden void @_ZN6test553fooIiE3barEv
+}