Author: rafael
Date: Thu Jul 12 20:19:08 2012
New Revision: 160157

URL: http://llvm.org/viewvc/llvm-project?rev=160157&view=rev
Log:
Fix a bug in my previous commit. The problem is not that we were not using the
canonical decl for the template, but that we were not merging attributes for
templates at all!

Modified:
    cfe/trunk/lib/AST/Decl.cpp
    cfe/trunk/lib/Sema/SemaTemplate.cpp
    cfe/trunk/test/CodeGenCXX/visibility.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=160157&r1=160156&r2=160157&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Thu Jul 12 20:19:08 2012
@@ -702,10 +702,8 @@
   // specialization of a class template, check for visibility
   // on the pattern.
   if (const ClassTemplateSpecializationDecl *spec
-      = dyn_cast<ClassTemplateSpecializationDecl>(this)) {
-    ClassTemplateDecl *TD = spec->getSpecializedTemplate()->getCanonicalDecl();
-    return getVisibilityOf(TD->getTemplatedDecl());
-  }
+        = dyn_cast<ClassTemplateSpecializationDecl>(this))
+    return getVisibilityOf(spec->getSpecializedTemplate()->getTemplatedDecl());
 
   // If this is a member class of a specialization of a class template
   // and the corresponding decl has explicit visibility, use that.

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=160157&r1=160156&r2=160157&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Jul 12 20:19:08 2012
@@ -1134,6 +1134,9 @@
     NewTemplate->setInvalidDecl();
     NewClass->setInvalidDecl();
   }
+  if (PrevClassTemplate)
+    mergeDeclAttributes(NewClass, PrevClassTemplate->getTemplatedDecl());
+
   return NewTemplate;
 }
 

Modified: cfe/trunk/test/CodeGenCXX/visibility.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/visibility.cpp?rev=160157&r1=160156&r2=160157&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/visibility.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/visibility.cpp Thu Jul 12 20:19:08 2012
@@ -1031,3 +1031,16 @@
   // CHECK: declare hidden void @_ZN6test553fooIiE3barEv
   // CHECK-HIDDEN: declare hidden void @_ZN6test553fooIiE3barEv
 }
+
+namespace test56 {
+  template <class T> struct foo;
+  template <class T>
+  struct __attribute__((visibility("hidden"))) foo {
+    static void bar();
+  };
+  void foobar() {
+    foo<int>::bar();
+  }
+  // CHECK: declare hidden void @_ZN6test563fooIiE3barEv
+  // CHECK-HIDDEN: declare hidden void @_ZN6test563fooIiE3barEv
+}


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to