diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 84a2a59ee230..f9e57bc7064c 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -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 diff --git a/clang/test/CodeGenCXX/visibility-inlines-hidden.cpp b/clang/test/CodeGenCXX/visibility-inlines-hidden.cpp index f7fabed8c10a..d660b1b41051 100644 --- a/clang/test/CodeGenCXX/visibility-inlines-hidden.cpp +++ b/clang/test/CodeGenCXX/visibility-inlines-hidden.cpp @@ -97,3 +97,14 @@ namespace test2 { // CHECK: define available_externally void @_ZN5test22ns3fooINS_1BINS_1AEEEEEvv() } + +namespace PR11642 { + template + class Foo { + public: + T foo(T x) { return x; } + }; + extern template class Foo; + template class Foo; + // CHECK: define weak_odr i32 @_ZN7PR116423FooIiE3fooEi +}