Clang Project

clang_source_code/test/CodeGenCXX/mangle-subst.cpp
1// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
2
3struct X {};
4
5// CHECK-LABEL: define void @_Z1f1XS_(
6void f(X, X) { }
7
8// CHECK-LABEL: define void @_Z1fR1XS0_(
9void f(X&, X&) { }
10
11// CHECK-LABEL: define void @_Z1fRK1XS1_(
12void f(const X&, const X&) { }
13
14typedef void T();
15struct S {};
16
17// CHECK-LABEL: define void @_Z1fPFvvEM1SFvvE(
18void f(T*, T (S::*)) {}
19
20namespace A {
21  struct A { };
22  struct B { };
23};
24
25// CHECK-LABEL: define void @_Z1fN1A1AENS_1BE(
26void f(A::A a, A::B b) { }
27
28struct C {
29  struct D { };
30};
31
32// CHECK-LABEL: define void @_Z1fN1C1DERS_PS_S1_(
33void f(C::D, C&, C*, C&) { }
34
35template<typename T>
36struct V {
37  typedef int U;
38};
39
40template <typename T> void f1(typename V<T>::U, V<T>) { }
41
42// CHECK: @_Z2f1IiEvN1VIT_E1UES2_
43template void f1<int>(int, V<int>);
44
45template <typename T> void f2(V<T>, typename V<T>::U) { }
46
47// CHECK: @_Z2f2IiEv1VIT_ENS2_1UE
48template void f2<int>(V<int>, int);
49
50namespace NS {
51template <typename T> struct S1 {};
52template<typename T> void ft3(S1<T>, S1<char>) {  }
53
54// CHECK: @_ZN2NS3ft3IiEEvNS_2S1IT_EENS1_IcEE
55template void ft3<int>(S1<int>, S1<char>);
56}
57
58// PR5196
59// CHECK: @_Z1fPKcS0_
60void f(const char*, const char*) {}
61
62namespace NS {
63  class C;
64}
65
66namespace NS {
67  // CHECK: @_ZN2NS1fERNS_1CE
68  void f(C&) { } 
69}
70
71namespace Test1 {
72
73struct A { };
74struct B { };
75
76// CHECK: @_ZN5Test11fEMNS_1BEFvvENS_1AES3_
77void f(void (B::*)(), A, A) { }
78
79// CHECK: @_ZN5Test11fEMNS_1BEFvvENS_1AES3_MS0_FvS3_EMS3_FvvE
80void f(void (B::*)(), A, A, void (B::*)(A), void (A::*)()) { }
81
82}
83
84namespace ManglePrefix {
85template <typename>
86struct X {
87  template <typename>
88  struct Y {
89    typedef int type;
90    typedef int type2;
91  };
92};
93template <typename T>
94typename X<T>::template Y<T>::type f(typename X<T>::template Y<T>::type2) { return 0; }
95
96// CHECK: @_ZN12ManglePrefix1fIiEENS_1XIT_E1YIS2_E4typeENS5_5type2E
97template int f<int>(int);
98}
99