]> granicus.if.org Git - clang/commitdiff
Embrace C++ ABI 5.2.6 and consider that template instantiations don't have key functi...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 13 Oct 2010 02:39:41 +0000 (02:39 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 13 Oct 2010 02:39:41 +0000 (02:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116391 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/RecordLayoutBuilder.cpp
test/CodeGenCXX/template-instantiation.cpp

index 0a095886ff9d84e8861e383871ef02478dc19526..c5465a5dca9882861f22f1a6646e28c2a451a202 100644 (file)
@@ -1562,6 +1562,13 @@ RecordLayoutBuilder::ComputeKeyFunction(const CXXRecordDecl *RD) {
   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;
index cb6c812316412b74bc2e145c238b5d2cba25c259..47ff16b8a62428f8b454de6f63c25b87ab23a063 100644 (file)
@@ -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 @@ namespace test3 {
   // (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();
+}