summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-03-30 18:07:27 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-03-30 18:07:27 +0000
commitff6a1fc1f3e1d62b1d802ed03931409988b29817 (patch)
treeb1630d6d0066f3ef120316214d228d610578ad94 /clang/lib/CodeGen
parent67d94ab0f8dfb25a0d00dd4348b3c02ea284aee3 (diff)
downloadbcm5719-llvm-ff6a1fc1f3e1d62b1d802ed03931409988b29817.tar.gz
bcm5719-llvm-ff6a1fc1f3e1d62b1d802ed03931409988b29817.zip
Don't produce a vtable if we are just instantiating a method and the
class has no key function. Fix PR6738. llvm-svn: 99900
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGVtable.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGVtable.cpp b/clang/lib/CodeGen/CGVtable.cpp
index 841281cdc42..bae588ab9b8 100644
--- a/clang/lib/CodeGen/CGVtable.cpp
+++ b/clang/lib/CodeGen/CGVtable.cpp
@@ -3138,19 +3138,28 @@ void CodeGenVTables::EmitVTableRelatedData(GlobalDecl GD) {
// Get the key function.
const CXXMethodDecl *KeyFunction = CGM.getContext().getKeyFunction(RD);
+ TemplateSpecializationKind RDKind = RD->getTemplateSpecializationKind();
+ TemplateSpecializationKind MDKind = MD->getTemplateSpecializationKind();
+
if (KeyFunction) {
// We don't have the right key function.
if (KeyFunction->getCanonicalDecl() != MD->getCanonicalDecl())
return;
+ } else {
+ // 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) &&
+ MDKind == TSK_ExplicitInstantiationDefinition)
+ return;
}
if (Vtables.count(RD))
return;
- TemplateSpecializationKind kind = RD->getTemplateSpecializationKind();
- if (kind == TSK_ImplicitInstantiation)
+ if (RDKind == TSK_ImplicitInstantiation)
CGM.DeferredVtables.push_back(RD);
else
GenerateClassData(CGM.getVtableLinkage(RD), RD);
}
-
OpenPOWER on IntegriCloud