From 1dbd474f2e097ba2a7dbb3db10414baebee9bd02 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 24 Mar 2010 22:43:31 +0000 Subject: 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 :-) llvm-svn: 99443 --- clang/test/CodeGenCXX/template-instantiation.cpp | 62 ++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 clang/test/CodeGenCXX/template-instantiation.cpp (limited to 'clang/test/CodeGenCXX/template-instantiation.cpp') diff --git a/clang/test/CodeGenCXX/template-instantiation.cpp b/clang/test/CodeGenCXX/template-instantiation.cpp new file mode 100644 index 00000000000..9e0593998bb --- /dev/null +++ b/clang/test/CodeGenCXX/template-instantiation.cpp @@ -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 + 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::xsgetn() { + } + extern template class stdio_sync_filebuf; +} + +namespace test1 { + struct basic_streambuf { + virtual ~basic_streambuf(); + }; + template + 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::xsgetn(); +} + +namespace test2 { + template + class C { + virtual ~C(); + void zedbar(double) { + } + template + void foobar(T2 foo) { + } + }; + extern template class C; + void g() { + // The extern template declaration should not prevent us from producing + // the implicit constructor (test at the top). + C a; + + // or foobar(test at the top). + a.foobar(0.0); + + // But it should prevent zebbar + // (test at the top). + a.zedbar(0.0); + } +} -- cgit v1.2.3