[cfe-commits] r147295 - in /cfe/trunk: lib/AST/Decl.cpp test/CodeGenCXX/visibility-inlines-hidden.cpp

Rafael Espindola rafael.espindola at gmail.com
Tue Dec 27 13:15:28 PST 2011


Author: rafael
Date: Tue Dec 27 15:15:28 2011
New Revision: 147295

URL: http://llvm.org/viewvc/llvm-project?rev=147295&view=rev
Log:
Fix the visibility of methods of explicit template instantiation definition
when using -fvisibility-inlines-hidden. This matches gcc's behavior and
documentation.

Fixes PR11642.

Modified:
    cfe/trunk/lib/AST/Decl.cpp
    cfe/trunk/test/CodeGenCXX/visibility-inlines-hidden.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=147295&r1=147294&r2=147295&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Dec 27 15:15:28 2011
@@ -568,6 +568,7 @@
     // about whether containing classes have visibility attributes,
     // and that's intentional.
     if (TSK != TSK_ExplicitInstantiationDeclaration &&
+        TSK != TSK_ExplicitInstantiationDefinition &&
         F.ConsiderGlobalVisibility &&
         MD->getASTContext().getLangOptions().InlineVisibilityHidden) {
       // InlineVisibilityHidden only applies to definitions, and

Modified: cfe/trunk/test/CodeGenCXX/visibility-inlines-hidden.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/visibility-inlines-hidden.cpp?rev=147295&r1=147294&r2=147295&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/visibility-inlines-hidden.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/visibility-inlines-hidden.cpp Tue Dec 27 15:15:28 2011
@@ -97,3 +97,14 @@
 
   // CHECK: define available_externally void @_ZN5test22ns3fooINS_1BINS_1AEEEEEvv()
 }
+
+namespace PR11642 {
+  template <typename T>
+  class Foo {
+  public:
+    T foo(T x) { return x; }
+  };
+  extern template class Foo<int>;
+  template class Foo<int>;
+  // CHECK: define weak_odr i32 @_ZN7PR116423FooIiE3fooEi
+}





More information about the cfe-commits mailing list