]> granicus.if.org Git - clang/commitdiff
Consider the visibility of template template arguments. GCC doesn't, but it also
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 31 Jul 2012 19:02:02 +0000 (19:02 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 31 Jul 2012 19:02:02 +0000 (19:02 +0000)
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

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

index c98853adec57422c4748cd3f9b7bdc680db40b68..d5b0be3ba4b110637c7c4dafa387dfdb84e7ebb6 100644 (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.
index d2f58f968d380d1eedddd859e28fc0ce4304264b..014503911a49853a6bc39a6fd4bb976a41c910f7 100644 (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
+  }
+}