1 // RUN: clang-cc -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
6 // CHECK: @unmangled_variable = global
7 // CHECK: @_ZN1N1iE = global
8 // CHECK: @_ZZN1N1fEiiE1b = internal global
9 // CHECK: @_ZZN1N1gEvE1a = internal global
10 // CHECK: @_ZGVZN1N1gEvE1a = internal global
12 // CHECK: define zeroext i1 @_ZplRK1YRA100_P1X
13 bool operator+(const Y&, X* (&xs)[100]) { return false; }
15 // CHECK: define void @_Z1f1s
16 typedef struct { int a; } s;
19 // CHECK: define void @_Z1f1e
20 typedef enum { foo } e;
23 // CHECK: define void @_Z1f1u
24 typedef union { int a; } u;
27 // CHECK: define void @_Z1f1x
28 typedef struct { int a; } x,y;
31 // CHECK: define void @_Z1fv
34 // CHECK: define void @_ZN1N1fEv
35 namespace N { void f() { } }
37 // CHECK: define void @_ZN1N1N1fEv
38 namespace N { namespace N { void f() { } } }
40 // CHECK: define void @unmangled_function
41 extern "C" { namespace N { void unmangled_function() { } } }
43 extern "C" { namespace N { int unmangled_variable = 10; } }
45 namespace N { int i; }
47 namespace N { int f(int, int) { static int b; return b; } }
49 namespace N { int h(); void g() { static int a = h(); } }
51 // CHECK: define void @_Z1fno
52 void f(__int128_t, __uint128_t) { }
54 template <typename T> struct S1 {};
56 // CHECK: define void @_Z1f2S1IiE
59 // CHECK: define void @_Z1f2S1IdE
62 template <int N> struct S2 {};
63 // CHECK: define void @_Z1f2S2ILi100EE
66 // CHECK: define void @_Z1f2S2ILin100EE
69 template <bool B> struct S3 {};
71 // CHECK: define void @_Z1f2S3ILb1EE
74 // CHECK: define void @_Z1f2S3ILb0EE
77 // CHECK: define void @_Z2f22S3ILb1EE
82 // CHECK: define void @_Z1fM1SKFvvE
83 void f(void (S::*)() const) {}
85 // CHECK: define void @_Z1fM1SFvvE
86 void f(void (S::*)()) {}
88 // CHECK: define void @_Z1fi
91 template<typename T, typename U> void ft1(U u, T t) { }
93 template<typename T> void ft2(T t, void (*)(T), void (*)(T)) { }
95 template<typename T, typename U = S1<T> > struct S4 { };
96 template<typename T> void ft3(S4<T>*) { }
99 template<typename T> void ft1(T) { }
103 // CHECK: @_Z3ft1IidEvT0_T_
104 ft1<int, double>(1, 0);
106 // CHECK: @_Z3ft2IcEvT_PFvS0_ES2_
109 // CHECK: @_Z3ft3IiEvP2S4IT_2S1IS1_EE
112 // CHECK: @_ZN2NS3ft1IiEEvT_
117 template<int I> struct S5 { };
119 template<int I> void ft4(S5<I>) { }
121 // CHECK: @_Z3ft4ILi10EEv2S5IXT_EE
124 // CHECK: @_Z3ft4ILi20EEv2S5IXT_EE
134 extern "C" { struct a { int b; }; }
144 const Debug& operator<< (unsigned a) const { }
147 // CHECK: @_ZNK5DebuglsEj
148 int main(void) { dbg << 32 ;}
151 template<typename T> struct S6 {
155 template<typename T> void ft5(typename S6<T>::B) { }
156 // CHECK: @_Z3ft5IiEvN2S6IT_E1BE
157 template void ft5<int>(int);
159 template<typename T> class A {};
162 template<typename T> bool operator==(const A<T>&, const A<T>&) { return true; }
165 // CHECK: @_ZN2NSeqIcEEbRK1AIT_ES5_
166 template bool NS::operator==(const ::A<char>&, const ::A<char>&);
169 template<typename T> bool operator==(const A<T>&, const A<T>&) { return true; }
172 // CHECK: @_ZSteqIcEbRK1AIT_ES4_
173 template bool std::operator==(const ::A<char>&, const ::A<char>&);
179 template <typename T> typename T::U ft6(const T&) { return 0; }
181 // CHECK: @_Z3ft6I1SENT_1UERKS1_
182 template int ft6<S>(const S&);
184 template<typename> struct __is_scalar {
185 enum { __value = 1 };
188 template<bool, typename> struct __enable_if { };
190 template<typename T> struct __enable_if<true, T> {
195 template<typename T> typename __enable_if<__is_scalar<T>::__value, void>::__type ft7() { }
197 // CHECK: @_Z3ft7IiEN11__enable_ifIXsr11__is_scalarIT_E7__valueEvE6__typeEv
198 template void ft7<int>();
199 // CHECK: @_Z3ft7IPvEN11__enable_ifIXsr11__is_scalarIT_E7__valueEvE6__typeEv
200 template void ft7<void*>();
208 void extern_f(void) { }
219 // CHECK: @_ZN2S7C1Ev
220 // CHECK: @_ZN2S7C2Ev
221 // CHECK: @"_ZN2S73$_0C1Ev"
225 template<typename T> typename __enable_if<(__is_scalar<T>::__value), void>::__type ft8() { }
226 // CHECK: @_Z3ft8IiEN11__enable_ifIXsr11__is_scalarIT_E7__valueEvE6__typeEv
227 template void ft8<int>();
228 // CHECK: @_Z3ft8IPvEN11__enable_ifIXsr11__is_scalarIT_E7__valueEvE6__typeEv
229 template void ft8<void*>();