1 // RUN: %clang_cc1 %s -emit-llvm -o - -ftime-report 2>&1 | FileCheck %s 2 // RUN: %clang_cc1 %s -emit-llvm -o - -fdelayed-template-parsing -DDELAYED_TEMPLATE_PARSING -ftime-report 2>&1 | FileCheck %s 3 4 // Template function declarations 5 template <typename T> 6 void foo(); 7 template <typename T, typename U> 8 void foo(); 9 10 // Template function definitions. 11 template <typename T> 12 void foo() {} 13 14 // Template class (forward) declarations 15 template <typename T> 16 struct A; 17 template <typename T, typename U> 18 struct b; 19 template <typename> 20 struct C; 21 template <typename, typename> 22 struct D; 23 24 // Forward declarations with default parameters? 25 template <typename T = int> 26 class X1; 27 template <typename = int> 28 class X2; 29 30 // Forward declarations w/template template parameters 31 template <template <typename> class T> 32 class TTP1; 33 template <template <typename> class> 34 class TTP2; 35 template <template <typename X, typename Y> class T> 36 class TTP5; 37 38 // Forward declarations with non-type params 39 template <int> 40 class NTP0; 41 template <int N> 42 class NTP1; 43 template <int N = 5> 44 class NTP2; 45 template <int = 10> 46 class NTP3; 47 template <unsigned int N = 12u> 48 class NTP4; 49 template <unsigned int = 12u> 50 class NTP5; 51 template <unsigned = 15u> 52 class NTP6; 53 template <typename T, T Obj> 54 class NTP7; 55 56 // Template class declarations 57 template <typename T> 58 struct A {}; 59 template <typename T, typename U> 60 struct B {}; 61 62 namespace PR6184 { 63 namespace N { 64 template <typename T> 65 void bar(typename T::x); 66 } 67 68 template <typename T> 69 void N::bar(typename T::x) {} 70 } 71 72 // This PR occurred only in template parsing mode. 73 namespace PR17637 { 74 template <int> 75 struct L { 76 template <typename T> 77 struct O { 78 template <typename U> 79 static void Fun(U); 80 }; 81 }; 82 83 template <int k> 84 template <typename T> 85 template <typename U> 86 void L<k>::O<T>::Fun(U) {} 87 88 void Instantiate() { L<0>::O<int>::Fun(0); } 89 } 90 91 namespace explicit_partial_specializations { 92 typedef char (&oneT)[1]; 93 typedef char (&twoT)[2]; 94 typedef char (&threeT)[3]; 95 typedef char (&fourT)[4]; 96 typedef char (&fiveT)[5]; 97 typedef char (&sixT)[6]; 98 99 char one[1]; 100 char two[2]; 101 char three[3]; 102 char four[4]; 103 char five[5]; 104 char six[6]; 105 106 template <bool b> 107 struct bool_ { typedef int type; }; 108 template <> 109 struct bool_<false> {}; 110 111 #define XCAT(x, y) x##y 112 #define CAT(x, y) XCAT(x, y) 113 #define sassert(_b_) bool_<(_b_)>::type CAT(var, __LINE__); 114 115 template <int> 116 struct L { 117 template <typename T> 118 struct O { 119 template <typename U> 120 static oneT Fun(U); 121 }; 122 }; 123 template <int k> 124 template <typename T> 125 template <typename U> 126 oneT L<k>::O<T>::Fun(U) { return one; } 127 128 template <> 129 template <> 130 template <typename U> 131 oneT L<0>::O<char>::Fun(U) { return one; } 132 133 void Instantiate() { 134 sassert(sizeof(L<0>::O<int>::Fun(0)) == sizeof(one)); 135 sassert(sizeof(L<0>::O<char>::Fun(0)) == sizeof(one)); 136 } 137 } 138 139 template <class> 140 struct Foo { 141 template <class _Other> 142 using rebind_alloc = _Other; 143 }; 144 template <class _Alloc> 145 struct _Wrap_alloc { 146 template <class _Other> 147 using rebind_alloc = typename Foo<_Alloc>::template rebind_alloc<_Other>; 148 template <class> 149 using rebind = _Wrap_alloc; 150 }; 151 _Wrap_alloc<int>::rebind<int> w; 152 153 // CHECK: Miscellaneous Ungrouped Timers 154 // CHECK-DAG: LLVM IR Generation Time 155 // CHECK-DAG: Code Generation Time 156 // CHECK: Total 157 // CHECK: Clang front-end time report 158 // CHECK: Clang front-end timer 159 // CHECK: Total 160