diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2010-04-03 04:26:42 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2010-04-03 04:26:42 +0000 |
| commit | 8e7ca8e0b1863647b2c862b676fcf446a000ae99 (patch) | |
| tree | cff781b4d888b532623266750e27b325203a949a /clang | |
| parent | fc8c3b7547d6f92a0e1d19ba102d8df342b15b64 (diff) | |
| download | bcm5719-llvm-8e7ca8e0b1863647b2c862b676fcf446a000ae99.tar.gz bcm5719-llvm-8e7ca8e0b1863647b2c862b676fcf446a000ae99.zip | |
Don't produce a vtable for a class if we have an explicit template instantiation declaration and no key function. We will produce the vtable at the explicit template instantiation.
Fixes PR6748
llvm-svn: 100266
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/CodeGen/CGVtable.cpp | 9 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/vtable-linkage.cpp | 6 |
2 files changed, 9 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGVtable.cpp b/clang/lib/CodeGen/CGVtable.cpp index 2d1c73440bb..fc6d1a8e370 100644 --- a/clang/lib/CodeGen/CGVtable.cpp +++ b/clang/lib/CodeGen/CGVtable.cpp @@ -3146,11 +3146,16 @@ void CodeGenVTables::EmitVTableRelatedData(GlobalDecl GD) { if (KeyFunction->getCanonicalDecl() != MD->getCanonicalDecl()) return; } else { + // If we have no key funcion and this is a explicit instantiation declaration, + // we will produce a vtable at the explicit instantiation. We don't need one + // here. + if (RDKind == clang::TSK_ExplicitInstantiationDeclaration) + return; + // If this is an explicit instantiation of a method, we don't need a vtable. // Since we have no key function, we will emit the vtable when we see // a use, and just defining a function is not an use. - if ((RDKind == TSK_ImplicitInstantiation || - RDKind == TSK_ExplicitInstantiationDeclaration) && + if (RDKind == TSK_ImplicitInstantiation && MDKind == TSK_ExplicitInstantiationDefinition) return; } diff --git a/clang/test/CodeGenCXX/vtable-linkage.cpp b/clang/test/CodeGenCXX/vtable-linkage.cpp index a4ea2a19c23..c75efe228df 100644 --- a/clang/test/CodeGenCXX/vtable-linkage.cpp +++ b/clang/test/CodeGenCXX/vtable-linkage.cpp @@ -128,10 +128,8 @@ void use_F(F<char> &fc) { // CHECK: @_ZTI1FIlE = weak_odr constant // F<int> is an explicit template instantiation declaration without a -// key function, so its vtable should have weak_odr linkage. -// CHECK: @_ZTV1FIiE = weak_odr constant -// CHECK: @_ZTS1FIiE = weak_odr constant -// CHECK: @_ZTI1FIiE = weak_odr constant +// key function, so its vtable should have external linkage. +// CHECK: @_ZTV1FIiE = external constant // E<int> is an explicit template instantiation declaration. It has a // key function that is not instantiated, so we should only reference |

