]> granicus.if.org Git - clang/commitdiff
Fix the visibility of methods of explicit template instantiation definition
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 27 Dec 2011 21:15:28 +0000 (21:15 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 27 Dec 2011 21:15:28 +0000 (21:15 +0000)
when using -fvisibility-inlines-hidden. This matches gcc's behavior and
documentation.

Fixes PR11642.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147295 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Decl.cpp
test/CodeGenCXX/visibility-inlines-hidden.cpp

index 84a2a59ee23005ebb5621a621d5333870ed02280..f9e57bc7064c0759a4705c01d9c11d27368b858f 100644 (file)
@@ -568,6 +568,7 @@ static LinkageInfo getLVForClassMember(const NamedDecl *D, LVFlags F) {
     // 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
index f7fabed8c10a7c47b4ecedd552f33594cd7409dc..d660b1b410518a3fe23fcdce3e26e16c7da2dd96 100644 (file)
@@ -97,3 +97,14 @@ namespace test2 {
 
   // 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
+}