• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Test this without pch.
2 // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include %S/cxx-templates.h -verify %s -ast-dump -o -
3 // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include %S/cxx-templates.h %s -emit-llvm -o - | FileCheck %s
4 
5 // Test with pch.
6 // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -x c++-header -emit-pch -o %t %S/cxx-templates.h
7 // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include-pch %t -verify %s -ast-dump  -o -
8 // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include-pch %t %s -emit-llvm -o - | FileCheck %s
9 
10 // CHECK: define weak_odr void @_ZN2S4IiE1mEv
11 // CHECK: define linkonce_odr void @_ZN2S3IiE1mEv
12 
13 struct A {
14   typedef int type;
15   static void my_f();
16   template <typename T>
my_templfA17   static T my_templf(T x) { return x; }
18 };
19 
test(const int (& a6)[17])20 void test(const int (&a6)[17]) {
21   int x = templ_f<int, 5>(3);
22 
23   S<char, float>::templ();
24   S<int, char>::partial();
25   S<int, float>::explicit_special();
26 
27   Dep<A>::Ty ty;
28   Dep<A> a;
29   a.f();
30 
31   S3<int> s3;
32   s3.m();
33 
34   TS5 ts(0);
35 
36   S6<const int[17]>::t2 b6 = a6;
37 }
38 
39 template struct S4<int>;
40 
41 S7<int[5]> s7_5;
42 
43 namespace ZeroLengthExplicitTemplateArgs {
44   template void f<X>(X*);
45 }
46 
47 // This used to overwrite memory and crash.
48 namespace Test1 {
49   struct StringHasher {
createHashTest1::StringHasher50     template<typename T, char Converter(T)> static inline unsigned createHash(const T*, unsigned) {
51       return 0;
52     }
53   };
54 
55   struct CaseFoldingHash {
foldCaseTest1::CaseFoldingHash56     static inline char foldCase(char) {
57       return 0;
58     }
59 
hashTest1::CaseFoldingHash60     static unsigned hash(const char* data, unsigned length) {
61       return StringHasher::createHash<char, foldCase>(data, length);
62     }
63   };
64 }
65