xref: /llvm-project/clang/test/utils/update_cc_test_checks/Inputs/explicit-template-instantiation.cpp (revision 57c81917d3a596f925f1c072ad04425b66bbd80e)
1 // RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
2 
3 template <typename T>
4 struct Foo {
5 private:
6   T x;
7 
8 public:
FooFoo9   Foo(T x) : x(x) {}
~FooFoo10   ~Foo() {}
11 
getFoo12   T get() { return x; }
setFoo13   void set(T _x) { x = _x; }
14 };
15 
16 template <typename T>
17 struct Bar {
18 private:
19   struct Foo<T> foo;
20 
21 public:
BarBar22   Bar(T x) : foo(x) {}
~BarBar23   ~Bar() {}
24 
getBar25   T get() { return foo.get(); }
setBar26   void set(T _x) { foo.set(_x); }
27 };
28 
29 template <typename T>
30 struct Baz : Foo<T> {
31 public:
BazBaz32   Baz(T x) : Foo<T>(x) {}
~BazBaz33   ~Baz() {}
34 };
35 
36 // These two specializations should generate lines for all of Foo's methods.
37 
38 template struct Foo<char>;
39 
40 template struct Foo<short>;
41 
42 // This should not generate lines for the implicit specialization of Foo, but
43 // should generate lines for the explicit specialization of Bar.
44 
45 template struct Bar<int>;
46 
47 // This should not generate lines for the implicit specialization of Foo, but
48 // should generate lines for the explicit specialization of Baz.
49 
50 template struct Baz<long>;
51