summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/mangle.cpp
blob: 01dcf8b2305afa86671c5f27ec14117e565c8c0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -fblocks -std=c++0x | FileCheck %s
struct X { };
struct Y { };

// CHECK: @unmangled_variable = global
// CHECK: @_ZN1N1iE = global
// CHECK: @_ZZN1N1fEiiE1b = internal global
// CHECK: @_ZZN1N1gEvE1a = internal global
// CHECK: @_ZGVZN1N1gEvE1a = internal global

//CHECK: @pr5966_i = external global
//CHECK: @_ZL8pr5966_i = internal global

// CHECK: define zeroext i1 @_ZplRK1YRA100_P1X
bool operator+(const Y&, X* (&xs)[100]) { return false; }

// CHECK: define void @_Z1f1s
typedef struct { int a; } s;
void f(s) { }

// CHECK: define void @_Z1f1e
typedef enum { foo } e;
void f(e) { }

// CHECK: define void @_Z1f1u
typedef union { int a; } u;
void f(u) { }

// CHECK: define void @_Z1f1x
typedef struct { int a; } x,y;
void f(y) { }

// CHECK: define void @_Z1fv
void f() { }

// CHECK: define void @_ZN1N1fEv
namespace N { void f() { } }

// CHECK: define void @_ZN1N1N1fEv
namespace N { namespace N { void f() { } } }

// CHECK: define void @unmangled_function
extern "C" { namespace N { void unmangled_function() { } } }

extern "C" { namespace N { int unmangled_variable = 10; } }

namespace N { int i; }

namespace N { int f(int, int) { static int b; return b; } }

namespace N { int h(); void g() { static int a = h(); } }

// CHECK: define void @_Z1fno
void f(__int128_t, __uint128_t) { } 

template <typename T> struct S1 {};

// CHECK: define void @_Z1f2S1IiE
void f(S1<int>) {}

// CHECK: define void @_Z1f2S1IdE
void f(S1<double>) {}

template <int N> struct S2 {};
// CHECK: define void @_Z1f2S2ILi100EE
void f(S2<100>) {}

// CHECK: define void @_Z1f2S2ILin100EE
void f(S2<-100>) {}

template <bool B> struct S3 {};

// CHECK: define void @_Z1f2S3ILb1EE
void f(S3<true>) {}

// CHECK: define void @_Z1f2S3ILb0EE
void f(S3<false>) {}

// CHECK: define void @_Z2f22S3ILb1EE
void f2(S3<100>) {}

struct S;

// CHECK: define void @_Z1fM1SKFvvE
void f(void (S::*)() const) {}

// CHECK: define void @_Z1fM1SFvvE
void f(void (S::*)()) {}

// CHECK: define void @_Z1fi
void f(const int) { }

template<typename T, typename U> void ft1(U u, T t) { }

template<typename T> void ft2(T t, void (*)(T), void (*)(T)) { }

template<typename T, typename U = S1<T> > struct S4 { };
template<typename T> void ft3(S4<T>*) {  }

namespace NS {
  template<typename T> void ft1(T) { }
}

void g1() {
  // CHECK: @_Z3ft1IidEvT0_T_
  ft1<int, double>(1, 0);
  
  // CHECK: @_Z3ft2IcEvT_PFvS0_ES2_
  ft2<char>(1, 0, 0);
  
  // CHECK: @_Z3ft3IiEvP2S4IT_2S1IS1_EE
  ft3<int>(0);
  
  // CHECK: @_ZN2NS3ft1IiEEvT_
  NS::ft1<int>(1);
}

// Expressions
template<int I> struct S5 { };

template<int I> void ft4(S5<I>) { }
void g2() {
  // CHECK: @_Z3ft4ILi10EEv2S5IXT_EE
  ft4(S5<10>());
  
  // CHECK: @_Z3ft4ILi20EEv2S5IXT_EE
  ft4(S5<20>());
}

extern "C++" {
  // CHECK: @_Z1hv
 void h() { } 
}

// PR5019
extern "C" { struct a { int b; }; }

// CHECK: @_Z1fP1a
int f(struct a *x) {
    return x->b;
}

// PR5017
extern "C" {
struct Debug {
  const Debug& operator<< (unsigned a) const { return *this; }
};
Debug dbg;
// CHECK: @_ZNK5DebuglsEj
int main(void) {  dbg << 32 ;}
}

template<typename T> struct S6 {
  typedef int B;
};

template<typename T> void ft5(typename S6<T>::B) { }
// CHECK: @_Z3ft5IiEvN2S6IT_E1BE
template void ft5<int>(int);

template<typename T> class A {};

namespace NS {
template<typename T> bool operator==(const A<T>&, const A<T>&) { return true; }
}

// CHECK: @_ZN2NSeqIcEEbRK1AIT_ES5_
template bool NS::operator==(const ::A<char>&, const ::A<char>&);

namespace std {
template<typename T> bool operator==(const A<T>&, const A<T>&) { return true; }
}

// CHECK: @_ZSteqIcEbRK1AIT_ES4_
template bool std::operator==(const ::A<char>&, const ::A<char>&);

struct S {
  typedef int U;
};

template <typename T> typename T::U ft6(const T&) { return 0; }

// CHECK: @_Z3ft6I1SENT_1UERKS1_
template int ft6<S>(const S&);

template<typename> struct __is_scalar_type {
  enum { __value = 1 };
};

template<bool, typename> struct __enable_if { };

template<typename T> struct __enable_if<true, T> {
  typedef T __type;
};

// PR5063
template<typename T> typename __enable_if<__is_scalar_type<T>::__value, void>::__type ft7() { }

// CHECK: @_Z3ft7IiEN11__enable_ifIXsr16__is_scalar_typeIT_E7__valueEvE6__typeEv
template void ft7<int>();
// CHECK: @_Z3ft7IPvEN11__enable_ifIXsr16__is_scalar_typeIT_E7__valueEvE6__typeEv
template void ft7<void*>();

// PR5144
extern "C" {
void extern_f(void);
};

// CHECK: @extern_f
void extern_f(void) { }

struct S7 {
  S7();
  
  struct S { S(); };
  struct {
    S s;
  } a;
};

// PR5139
// CHECK: @_ZN2S7C1Ev
// CHECK: @_ZN2S7C2Ev
// CHECK: @"_ZN2S73$_0C1Ev"
S7::S7() {}

// PR5063
template<typename T> typename __enable_if<(__is_scalar_type<T>::__value), void>::__type ft8() { }
// CHECK: @_Z3ft8IiEN11__enable_ifIXsr16__is_scalar_typeIT_E7__valueEvE6__typeEv
template void ft8<int>();
// CHECK: @_Z3ft8IPvEN11__enable_ifIXsr16__is_scalar_typeIT_E7__valueEvE6__typeEv
template void ft8<void*>();

// PR5796
namespace PR5796 {
template<typename> struct __is_scalar_type {
  enum { __value = 0 };
};

template<bool, typename> struct __enable_if {};
template<typename T> struct __enable_if<true, T> { typedef T __type; };
template<typename T>

// CHECK: define linkonce_odr void @_ZN6PR57968__fill_aIiEENS_11__enable_ifIXntsrNS_16__is_scalar_typeIT_EE7__valueEvE6__typeEv
typename __enable_if<!__is_scalar_type<T>::__value, void>::__type __fill_a() { };

void f() { __fill_a<int>(); }
}

namespace Expressions {
// Unary operators.

// CHECK: define weak_odr void @_ZN11Expressions2f1ILi1EEEvPAplngT_Li2E_i
template <int i> void f1(int (*)[(-i) + 2]) { };
template void f1<1>(int (*)[1]);

// CHECK: define weak_odr void @_ZN11Expressions2f2ILi1EEEvPApsT__i
template <int i> void f2(int (*)[+i]) { };
template void f2<1>(int (*)[1]);

// Binary operators.

// CHECK: define weak_odr void @_ZN11Expressions2f3ILi1EEEvPAplT_T__i
template <int i> void f3(int (*)[i+i]) { };
template void f3<1>(int (*)[2]);

// CHECK: define weak_odr void @_ZN11Expressions2f4ILi1EEEvPAplplLi2ET_T__i
template <int i> void f4(int (*)[2 + i+i]) { };
template void f4<1>(int (*)[4]);

// The ternary operator.
// CHECK: define weak_odr void @_ZN11Expressions2f4ILb1EEEvPAquT_Li1ELi2E_i
template <bool b> void f4(int (*)[b ? 1 : 2]) { };
template void f4<true>(int (*)[1]);
}

struct Ops {
  Ops& operator+(const Ops&);
  Ops& operator-(const Ops&);
  Ops& operator&(const Ops&);
  Ops& operator*(const Ops&);
  
  void *v;
};

// CHECK: define %struct.Ops* @_ZN3OpsplERKS_
Ops& Ops::operator+(const Ops&) { return *this; }
// CHECK: define %struct.Ops* @_ZN3OpsmiERKS_
Ops& Ops::operator-(const Ops&) { return *this; }
// CHECK: define %struct.Ops* @_ZN3OpsanERKS_
Ops& Ops::operator&(const Ops&) { return *this; }
// CHECK: define %struct.Ops* @_ZN3OpsmlERKS_
Ops& Ops::operator*(const Ops&) { return *this; }

// PR5861
namespace PR5861 {
template<bool> class P;
template<> class P<true> {};

template<template <bool> class, bool>
struct Policy { };

template<typename T, typename = Policy<P, true> > class Alloc
{
  T *allocate(int, const void*) { return 0; }
};

// CHECK: define weak_odr i8* @_ZN6PR58615AllocIcNS_6PolicyINS_1PELb1EEEE8allocateEiPKv
template class Alloc<char>;
}

// CHECK: define void @_Z1fU13block_pointerFiiiE
void f(int (^)(int, int)) { }

void pr5966_foo() {
  extern int pr5966_i;
  pr5966_i = 0;
}

static int pr5966_i;

void pr5966_bar() {
  pr5966_i = 0;
}

namespace test0 {
  int ovl(int x);
  char ovl(double x);

  template <class T> void f(T, char (&buffer)[sizeof(ovl(T()))]) {}

  void test0() {
    char buffer[1];
    f(0.0, buffer);
  }
  // CHECK: define void @_ZN5test05test0Ev()
  // CHECK: define linkonce_odr void @_ZN5test01fIdEEvT_RAszcl3ovlcvS1__EE_c(

  void test1() {
    char buffer[sizeof(int)];
    f(1, buffer);
  }
  // CHECK: define void @_ZN5test05test1Ev()
  // CHECK: define linkonce_odr void @_ZN5test01fIiEEvT_RAszcl3ovlcvS1__EE_c(

  template <class T> void g(char (&buffer)[sizeof(T() + 5.0f)]) {}
  void test2() {
    char buffer[sizeof(float)];
    g<float>(buffer);
  }
  // CHECK: define linkonce_odr void @_ZN5test01gIfEEvRAszplcvT__ELf40a00000E_c(

  template <class T> void h(char (&buffer)[sizeof(T() + 5.0)]) {}
  void test3() {
    char buffer[sizeof(double)];
    h<float>(buffer);
  }
  // CHECK: define linkonce_odr void @_ZN5test01hIfEEvRAszplcvT__ELd4014000000000000E_c(

  template <class T> void j(char (&buffer)[sizeof(T().buffer)]) {}
  struct A { double buffer[128]; };
  void test4() {
    char buffer[1024];
    j<A>(buffer);
  }
  // CHECK: define linkonce_odr void @_ZN5test01jINS_1AEEEvRAszdtcvT__E6buffer_c(
}

namespace test1 {
  template<typename T> struct X { };
  template<template<class> class Y, typename T> void f(Y<T>) { }
  // CHECK: define weak_odr void @_ZN5test11fINS_1XEiEEvT_IT0_E
  template void f(X<int>);
}

// CHECK: define internal void @_ZL27functionWithInternalLinkagev()
static void functionWithInternalLinkage() {  }
void g() { functionWithInternalLinkage(); }

namespace test2 {
  template <class T> decltype(((T*) 0)->member) read_member(T& obj) {
    return obj.member;
  }

  struct A { int member; } obj;
  int test() {
    return read_member(obj);
  }

  // CHECK: define linkonce_odr i32 @_ZN5test211read_memberINS_1AEEEDtptcvPT_Li0E6memberERS2_(
}

// rdar://problem/9280586
namespace test3 {
  struct AmbiguousBase { int ab; };
  struct Path1 : AmbiguousBase { float p; };
  struct Path2 : AmbiguousBase { double p; };
  struct Derived : Path1, Path2 { };

  // CHECK: define linkonce_odr i32 @_ZN5test38get_ab_1INS_7DerivedEEEDtptcvPT_Li0Esr5Path1E2abERS2_(
  template <class T> decltype(((T*) 0)->Path1::ab) get_ab_1(T &ref) { return ref.Path1::ab; }

  // CHECK: define linkonce_odr i32 @_ZN5test38get_ab_2INS_7DerivedEEEDtptcvPT_Li0Esr5Path2E2abERS2_(
  template <class T> decltype(((T*) 0)->Path2::ab) get_ab_2(T &ref) { return ref.Path2::ab; }

  // CHECK: define linkonce_odr float @_ZN5test37get_p_1INS_7DerivedEEEDtptcvPT_Li0Esr5Path1E1pERS2_(
  template <class T> decltype(((T*) 0)->Path1::p) get_p_1(T &ref) { return ref.Path1::p; }

  // CHECK: define linkonce_odr double @_ZN5test37get_p_2INS_7DerivedEEEDtptcvPT_Li0Esr5Path2E1pERS2_(
  template <class T> decltype(((T*) 0)->Path2::p) get_p_2(T &ref) { return ref.Path2::p; }

  Derived obj;
  void test() {
    get_ab_1(obj);
    get_ab_2(obj);
    get_p_1(obj);
    get_p_2(obj);
  }
}

// CHECK: define void @_ZN5test41gEPNS_3zedIXadL_ZNS_3foo3barEEEEE
namespace test4 {
  struct foo { int bar; };
  template <int (foo::*)>
  struct zed {};
  void g(zed<&foo::bar>*)
  {}
}
// CHECK: define void @_ZN5test51gEPNS_3zedIXadL_ZNS_3foo3barEEEEE
namespace test5 {
  struct foo { static int bar; };
  template <int *>
  struct zed {};
  void g(zed<&foo::bar>*)
  {}
}
// CHECK: define void @_ZN5test61gEPNS_3zedIXadL_ZNS_3foo3barEvEEEE
namespace test6 {
  struct foo { int bar(); };
  template <int (foo::*)()>
  struct zed {};
  void g(zed<&foo::bar>*)
  {}
}
// CHECK: define void @_ZN5test71gEPNS_3zedIXadL_ZNS_3foo3barEvEEEE
namespace test7 {
  struct foo { static int bar(); };
  template <int (*f)()>
  struct zed {};
  void g(zed<&foo::bar>*)
  {}
}
// CHECK: define weak_odr void @_ZN5test81AILZNS_1B5valueEEE3incEv
namespace test8 {
  template <int &counter> class A { void inc() { counter++; } };
  class B { public: static int value; };
  template class A<B::value>;
}
// CHECK: declare void @_ZN5test91fIiNS_3barEEEvRKNT0_3baz1XE
namespace test9 {
  template<class T>
  struct foo {
    typedef T X;
  };
  struct bar {
    typedef foo<int> baz;
  };
  template <class zaz, class zed>
  void f(const typename zed::baz::X&);
  void g() {
    f<int, bar>( 0);
  }
}

// <rdar://problem/7825453>
namespace test10 {
  template <char P1> struct S {};
  template <char P2> void f(struct S<false ? 'a' : P2> ) {}

  // CHECK: define weak_odr void @_ZN6test101fILc3EEEvNS_1SIXquLb0ELc97ET_EEE(
  template void f<(char) 3>(struct S<3>);
}

namespace test11 {
  // CHECK: @_ZN6test111fEz
  void f(...) { }

  struct A {
    void f(...);
  };
  
  // CHECK: @_ZN6test111A1fEz
  void A::f(...) { }
}

namespace test12 {

  // CHECK: _ZN6test121fENS_1AILt33000EEE
  template <unsigned short> struct A { };
  void f(A<33000>) { }
}

// PR7446
namespace test13 {
  template <template <class> class T> class A {};
  template <class U> class B {};

  template <template<class> class T> void foo(const A<T> &a) {}

  // CHECK: define weak_odr void @_ZN6test133fooINS_1BEEEvRKNS_1AIT_EE(
  template void foo(const A<B> &a);
}

namespace test14 {
  extern "C" {
    struct S {
      static int a(), x;
    };
    // CHECK: define i32 @_ZN6test141S1aEv
    // CHECK: load i32* @_ZN6test141S1xE
    int S::a() { return S::x; }
  }
}

// rdar://problem/8204122
namespace test15 {
  enum E { e = 3 };
  template <int I> struct S {};

  template <int I> void f(S<I + e>) {}

  // CHECK: define weak_odr void @_ZN6test151fILi7EEEvNS_1SIXplT_LNS_1EE3EEEE(
  template void f<7>(S<7 + e>);
}

// rdar://problem/8125400.  Don't crash.
namespace test16 {
  static union {};
  static union { union {}; };
  static union { struct {}; };
  static union { union { union {}; }; };
  static union { union { struct {}; }; };
  static union { struct { union {}; }; };
  static union { struct { struct {}; }; };
}

// rdar://problem/8302148
namespace test17 {
  template <int N> struct A {};

  struct B {
    static int foo(void);
  };

  template <class T> A<sizeof(T::foo())> func(void);

  // CHECK: define void @_ZN6test174testEv()
  // CHECK: call {{.*}} @_ZN6test174funcINS_1BEEENS_1AIXszclsrT_3fooEEEEv()
  void test() {
    func<B>();
  }
}

// PR7891
namespace test18 {
  struct A {
    int operator+();
    int operator-();
    int operator*();
    int operator&();
  };
  template <int (A::*)()> struct S {};

  template <typename T> void f(S<&T::operator+>) {}
  template void f<A>(S<&A::operator+>);

  template <typename T> void f(S<&T::operator- >) {}
  template void f<A>(S<&A::operator- >);

  template <typename T> void f(S<&T::operator*>) {}
  template void f<A>(S<&A::operator*>);

  template <typename T> void f(S<&T::operator&>) {}
  template void f<A>(S<&A::operator&>);

  // CHECK: define weak_odr void @_ZN6test181fINS_1AEEEvNS_1SIXadsrT_plEEE
  // CHECK: define weak_odr void @_ZN6test181fINS_1AEEEvNS_1SIXadsrT_miEEE
  // CHECK: define weak_odr void @_ZN6test181fINS_1AEEEvNS_1SIXadsrT_mlEEE
  // CHECK: define weak_odr void @_ZN6test181fINS_1AEEEvNS_1SIXadsrT_anEEE
}

// rdar://problem/8332117
namespace test19 {
  struct A {
    template <typename T> int f();
    int operator+();
    operator int();
    template <typename T> int operator-();
  };

  template <int (A::*)()> struct S {};

  template <typename T> void g (S<&T::template f<int> >) {}
  template <typename T> void g (S<&T::operator+ >) {}
  template <typename T> void g (S<&T::operator int>) {}
  template <typename T> void g (S<&T::template operator- <double> >) {}

  // CHECK: define weak_odr void @_ZN6test191gINS_1AEEEvNS_1SIXadsrT_1fIiEEEE(
  template void g<A>(S<&A::f<int> >);
  // CHECK: define weak_odr void @_ZN6test191gINS_1AEEEvNS_1SIXadsrT_plEEE(
  template void g<A>(S<&A::operator+>);
  // CHECK: define weak_odr void @_ZN6test191gINS_1AEEEvNS_1SIXadsrT_cviEEE(
  template void g<A>(S<&A::operator int>);
  // CHECK: define weak_odr void @_ZN6test191gINS_1AEEEvNS_1SIXadsrT_miIdEEEE(
  template void g<A>(S<&A::operator-<double> >);
}

namespace test20 {
  template <class T> T *f(const T&);
  template <class T> T *f(T*);

  // CHECK: define weak_odr void @_ZN6test205test0IiEEvDTcl1fIPT_ELi0EEE(
  template <class T> void test0(decltype(f<T*>(0))) {}
  template void test0<int>(decltype(f<int*>(0)));

  // CHECK: define weak_odr void @_ZN6test205test1IiEEvDTcl1fIEcvT__EEE(
  template <class T> void test1(decltype(f<>(T()))) {}
  template void test1<int>(decltype(f<>(int())));
}

// rdar:// 8620510
namespace test21 {
  // CHECK: define void @_ZN6test2112vla_arg_funcEiPA_i(
  void vla_arg_func(int X, int a[X][X]) {}
}

namespace test22 {
  // CHECK: define void @_ZN6test221fEDn(
  void f(decltype(nullptr)) { }
}

// rdar://problem/8913416
namespace test23 {
  typedef void * const vpc;

  // CHECK: define void @_ZN6test231fERA10_KPv(
  void f(vpc (&)[10]) {}

  typedef vpc vpca5[5];
  void f(vpca5 volatile (&)[10]) {}
  // CHECK: define void @_ZN6test231fERA10_A5_VKPv(
}

namespace test24 {
  void test0() {
    extern int foo();
    // CHECK: call i32 @_ZN6test243fooEv()
    foo();
  }

  static char foo() {}
  void test1() {
    // CHECK: call signext i8 @_ZN6test24L3fooEv()
    foo();
  }
}

// rdar://problem/8806641
namespace test25 {
  template <void (*fn)()> struct A {
    static void call() { fn(); }
  };
  void foo();
  void test() {
    // CHECK: call void @_ZN6test251AIXadL_ZNS_3fooEvEEE4callEv()
    A<foo>::call();
  }
}

namespace test26 {
  template <template <class> class T> void foo(decltype(T<float>::object) &object) {}

  template <class T> struct holder { static T object; };

  void test() {
    float f;

    // CHECK: call void @_ZN6test263fooINS_6holderEEEvRDtsrT_IfE6objectE(
    foo<holder>(f);
  }
}

namespace test27 {
  struct A {
    struct inner {
      float object;
    };

    float meth();
  };
  typedef A Alias;

  template <class T> void a(decltype(T::inner::object) &object) {}
  template <class T> void b(decltype(T().Alias::meth()) &object) {}

  void test() {
    float f;
    // CHECK: call void @_ZN6test271aINS_1AEEEvRDtsrNT_5innerE6objectE(
    a<A>(f);
    // CHECK: call void @_ZN6test271bINS_1AEEEvRDTcldtcvT__Esr5AliasE4methEE(
    b<A>(f);
  }
}
OpenPOWER on IntegriCloud