[cfe-commits] r99443 - in /cfe/trunk/test/CodeGenCXX: PR6677.cpp template-instantiation.cpp

Rafael Espindola rafael.espindola at gmail.com
Wed Mar 24 15:43:31 PDT 2010


Author: rafael
Date: Wed Mar 24 17:43:31 2010
New Revision: 99443

URL: http://llvm.org/viewvc/llvm-project?rev=99443&view=rev
Log:
Discussing with dgregor we decided that we should not force the emission of
implicit methods on explicit template instantiation definitions. As a
consequence, we should emit them at every use, even if we see a explicit
template instantiation declaration.

This is already the current behaviour, but it is good to test for that :-)


Added:
    cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
Removed:
    cfe/trunk/test/CodeGenCXX/PR6677.cpp

Removed: cfe/trunk/test/CodeGenCXX/PR6677.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR6677.cpp?rev=99442&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/PR6677.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/PR6677.cpp (removed)
@@ -1,33 +0,0 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
-
-// CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
-// CHECK: @_ZTVN5test018stdio_sync_filebufIwEE = constant
-
-namespace test0 {
-  struct  basic_streambuf   {
-    virtual       ~basic_streambuf();
-  };
-  template<typename _CharT >
-  struct stdio_sync_filebuf : public basic_streambuf {
-    virtual void      xsgetn();
-  };
-
-  // This specialization should cause the vtable to be emitted, even with
-  // the following extern template declaration.
-  template<> void stdio_sync_filebuf<wchar_t>::xsgetn()  {
-  }
-  extern template class stdio_sync_filebuf<wchar_t>;
-}
-
-namespace test1 {
-  struct  basic_streambuf   {
-    virtual       ~basic_streambuf();
-  };
-  template<typename _CharT >
-  struct stdio_sync_filebuf : public basic_streambuf {
-    virtual void      xsgetn();
-  };
-
-  // Just a declaration should not force the vtable to be emitted.
-  template<> void stdio_sync_filebuf<wchar_t>::xsgetn();
-}

Added: cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/template-instantiation.cpp?rev=99443&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/template-instantiation.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/template-instantiation.cpp Wed Mar 24 17:43:31 2010
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
+// CHECK: @_ZTVN5test018stdio_sync_filebufIwEE = constant
+
+// CHECK: define linkonce_odr void @_ZN5test21CIiEC1Ev(
+// CHECK: define linkonce_odr void @_ZN5test21CIiE6foobarIdEEvT_(
+// CHECK: define available_externally void @_ZN5test21CIiE6zedbarEd(
+
+namespace test0 {
+  struct  basic_streambuf   {
+    virtual       ~basic_streambuf();
+  };
+  template<typename _CharT >
+  struct stdio_sync_filebuf : public basic_streambuf {
+    virtual void      xsgetn();
+  };
+
+  // This specialization should cause the vtable to be emitted, even with
+  // the following extern template declaration.
+  template<> void stdio_sync_filebuf<wchar_t>::xsgetn()  {
+  }
+  extern template class stdio_sync_filebuf<wchar_t>;
+}
+
+namespace test1 {
+  struct  basic_streambuf   {
+    virtual       ~basic_streambuf();
+  };
+  template<typename _CharT >
+  struct stdio_sync_filebuf : public basic_streambuf {
+    virtual void      xsgetn();
+  };
+
+  // Just a declaration should not force the vtable to be emitted.
+  template<> void stdio_sync_filebuf<wchar_t>::xsgetn();
+}
+
+namespace test2 {
+  template<typename T1>
+  class C {
+    virtual ~C();
+    void zedbar(double) {
+    }
+    template<typename T2>
+    void foobar(T2 foo) {
+    }
+  };
+  extern template class C<int>;
+  void g() {
+    // The extern template declaration should not prevent us from producing
+    // the implicit constructor (test at the top).
+    C<int> a;
+
+    // or foobar(test at the top).
+    a.foobar(0.0);
+
+    // But it should prevent zebbar
+    // (test at the top).
+    a.zedbar(0.0);
+  }
+}





More information about the cfe-commits mailing list