[cfe-commits] r100266 - in /cfe/trunk: lib/CodeGen/CGVtable.cpp test/CodeGenCXX/vtable-linkage.cpp
Rafael Espindola
rafael.espindola at gmail.com
Fri Apr 2 21:26:42 PDT 2010
Author: rafael
Date: Fri Apr 2 23:26:42 2010
New Revision: 100266
URL: http://llvm.org/viewvc/llvm-project?rev=100266&view=rev
Log:
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
Modified:
cfe/trunk/lib/CodeGen/CGVtable.cpp
cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp
Modified: cfe/trunk/lib/CodeGen/CGVtable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVtable.cpp?rev=100266&r1=100265&r2=100266&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVtable.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVtable.cpp Fri Apr 2 23:26:42 2010
@@ -3146,11 +3146,16 @@
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;
}
Modified: cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp?rev=100266&r1=100265&r2=100266&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp Fri Apr 2 23:26:42 2010
@@ -128,10 +128,8 @@
// 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
More information about the cfe-commits
mailing list