[cfe-commits] r116391 - in /cfe/trunk: lib/AST/RecordLayoutBuilder.cpp test/CodeGenCXX/template-instantiation.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Tue Oct 12 19:39:41 PDT 2010
Author: akirtzidis
Date: Tue Oct 12 21:39:41 2010
New Revision: 116391
URL: http://llvm.org/viewvc/llvm-project?rev=116391&view=rev
Log:
Embrace C++ ABI 5.2.6 and consider that template instantiations don't have key functions (same as GCC).
Modified:
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=116391&r1=116390&r2=116391&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Tue Oct 12 21:39:41 2010
@@ -1562,6 +1562,13 @@
if (RD->isInAnonymousNamespace())
return 0;
+ // Template instantiations don't have key functions,see Itanium C++ ABI 5.2.6.
+ // Same behavior as GCC.
+ TemplateSpecializationKind TSK = RD->getTemplateSpecializationKind();
+ if (TSK == TSK_ImplicitInstantiation ||
+ TSK == TSK_ExplicitInstantiationDefinition)
+ return 0;
+
for (CXXRecordDecl::method_iterator I = RD->method_begin(),
E = RD->method_end(); I != E; ++I) {
const CXXMethodDecl *MD = *I;
Modified: cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/template-instantiation.cpp?rev=116391&r1=116390&r2=116391&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/template-instantiation.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/template-instantiation.cpp Tue Oct 12 21:39:41 2010
@@ -4,6 +4,9 @@
// CHECK-NOT: _ZTVN5test315basic_fstreamXXIcEE
// CHECK: @_ZTVN5test018stdio_sync_filebufIwEE = constant
+// CHECK-NOT: _ZTVN5test31SIiEE
+// CHECK-NOT: _ZTSN5test31SIiEE
+
// CHECK: define linkonce_odr void @_ZN5test21CIiEC1Ev(
// CHECK: define linkonce_odr void @_ZN5test21CIiE6foobarIdEEvT_(
// CHECK: define available_externally void @_ZN5test21CIiE6zedbarEd(
@@ -75,3 +78,17 @@
// (test at the top).
template void basic_fstreamXX<char>::is_open() const;
}
+
+namespace test3 {
+ template <typename T>
+ struct S {
+ virtual void m();
+ };
+
+ template<typename T>
+ void S<T>::m() { }
+
+ // Should not cause us to produce vtable because template instantiations
+ // don't have key functions.
+ template void S<int>::m();
+}
More information about the cfe-commits
mailing list