ftime-report-template-decl.cpp 3.2 KB

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