summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGVTables.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-10-11 03:25:57 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-10-11 03:25:57 +0000
commit0c34b138dfc34f0434b9630a92fed7d30a76e2b3 (patch)
treea472f0dbbf08e141b2f663c12eebc25f05fcfaa2 /clang/lib/CodeGen/CGVTables.cpp
parentf0e31c8b9cd2352eb190cde3166393e590f02002 (diff)
downloadbcm5719-llvm-0c34b138dfc34f0434b9630a92fed7d30a76e2b3.tar.gz
bcm5719-llvm-0c34b138dfc34f0434b9630a92fed7d30a76e2b3.zip
Make sure the VTables for template instantiations are emitted even if the key function doesn't have a body.
llvm-svn: 116186
Diffstat (limited to 'clang/lib/CodeGen/CGVTables.cpp')
-rw-r--r--clang/lib/CodeGen/CGVTables.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index bed4670f7f9..e1ed98cdf5a 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -2336,6 +2336,27 @@ void CodeGenVTables::ComputeMethodVTableIndices(const CXXRecordDecl *RD) {
NumVirtualFunctionPointers[RD] = CurrentIndex;
}
+bool CodeGenVTables::ShouldEmitVTableInThisTU(const CXXRecordDecl *RD) {
+ assert(RD->isDynamicClass() && "Non dynamic classes have no VTable.");
+
+ TemplateSpecializationKind TSK = RD->getTemplateSpecializationKind();
+ if (TSK == TSK_ExplicitInstantiationDeclaration)
+ return false;
+
+ const CXXMethodDecl *KeyFunction = CGM.getContext().getKeyFunction(RD);
+ if (!KeyFunction)
+ return true;
+
+ // Itanium C++ ABI, 5.2.6 Instantiated Templates:
+ // An instantiation of a class template requires:
+ // - In the object where instantiated, the virtual table...
+ if (TSK == TSK_ImplicitInstantiation ||
+ TSK == TSK_ExplicitInstantiationDefinition)
+ return true;
+
+ return KeyFunction->hasBody();
+}
+
uint64_t CodeGenVTables::getNumVirtualFunctionPointers(const CXXRecordDecl *RD) {
llvm::DenseMap<const CXXRecordDecl *, uint64_t>::iterator I =
NumVirtualFunctionPointers.find(RD);
@@ -2703,9 +2724,7 @@ void CodeGenVTables::ComputeVTableRelatedInformation(const CXXRecordDecl *RD,
// We may need to generate a definition for this vtable.
if (RequireVTable && !Entry.getInt()) {
- if (!isKeyFunctionInAnotherTU(CGM.getContext(), RD) &&
- RD->getTemplateSpecializationKind()
- != TSK_ExplicitInstantiationDeclaration)
+ if (ShouldEmitVTableInThisTU(RD))
CGM.DeferredVTables.push_back(RD);
Entry.setInt(true);
OpenPOWER on IntegriCloud