diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2010-08-25 08:27:02 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2010-08-25 08:27:02 +0000 |
commit | cfe41db403840e4b929db3e92f938f3da01bd772 (patch) | |
tree | 91378e92b5e607f9a378ae8dda4167349bc84078 /clang/test/CodeGenCXX/explicit-instantiation.cpp | |
parent | 6b1533a1a95ad558827a2691b06c499ccf0c2932 (diff) | |
download | bcm5719-llvm-cfe41db403840e4b929db3e92f938f3da01bd772.tar.gz bcm5719-llvm-cfe41db403840e4b929db3e92f938f3da01bd772.zip |
Support explicit instantiation of function templates and members of class
templates when only the declaration is in scope. This requires deferring the
instantiation to be lazy, and ensuring the definition is required for that
translation unit. We re-use the existing pending instantiation queue,
previously only used to track implicit instantiations which were required to be
lazy. Fixes PR7979.
A subsequent change will rename *PendingImplicitInstantiations to
*PendingInstatiations for clarity given its broader role.
llvm-svn: 112037
Diffstat (limited to 'clang/test/CodeGenCXX/explicit-instantiation.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/explicit-instantiation.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/explicit-instantiation.cpp b/clang/test/CodeGenCXX/explicit-instantiation.cpp index 24d1a673922..b82958568a8 100644 --- a/clang/test/CodeGenCXX/explicit-instantiation.cpp +++ b/clang/test/CodeGenCXX/explicit-instantiation.cpp @@ -1,5 +1,8 @@ // RUN: %clang_cc1 -emit-llvm -triple i686-pc-linux-gnu -o - %s | FileCheck %s +// This check logically is attached to 'template int S<int>::i;' below. +// CHECK: @_ZN1SIiE1iE = weak global i32 + template<typename T, typename U, typename Result> struct plus { Result operator()(const T& t, const U& u) const; @@ -12,3 +15,31 @@ Result plus<T, U, Result>::operator()(const T& t, const U& u) const { // CHECK: define weak_odr i32 @_ZNK4plusIillEclERKiRKl template struct plus<int, long, long>; + +// Check that we emit definitions from explicit instantiations even when they +// occur prior to the definition itself. +template <typename T> struct S { + void f(); + static void g(); + static int i; + struct S2 { + void h(); + }; +}; + +// CHECK: define weak_odr void @_ZN1SIiE1fEv +template void S<int>::f(); + +// CHECK: define weak_odr void @_ZN1SIiE1gEv +template void S<int>::g(); + +// See the check line at the top of the file. +template int S<int>::i; + +// CHECK: define weak_odr void @_ZN1SIiE2S21hEv +template void S<int>::S2::h(); + +template <typename T> void S<T>::f() {} +template <typename T> void S<T>::g() {} +template <typename T> int S<T>::i; +template <typename T> void S<T>::S2::h() {} |