summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/mangle-abi-tag.cpp
blob: 5d84096d24cd8eb47d3e591bdaf1ecb4ddbeb308 (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
// RUN: %clang_cc1 %s -emit-llvm -triple %itanium_abi_triple -std=c++11 -o - | FileCheck %s
// RUN: %clang_cc1 %s -emit-llvm -triple i686-linux-gnu -std=c++11 -o - | FileCheck %s
// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-linux-gnu -std=c++11 -o - | FileCheck %s
// RUN: %clang_cc1 %s -emit-llvm -triple powerpc64le-unknown-linux-gnu -std=c++11 -o - | FileCheck %s

struct __attribute__((abi_tag("A", "B"))) A { };

struct B: A { };

template<class T>

struct C {
};

struct D { A* p; };

template<class T>
struct __attribute__((abi_tag("C", "D"))) E {
};

struct __attribute__((abi_tag("A", "B"))) F { };

A a1;
// CHECK-DAG: @_Z2a1B1AB1B =

__attribute__((abi_tag("C", "D")))
A a2;
// CHECK-DAG: @_Z2a2B1AB1BB1CB1D =

B a3;
// CHECK-DAG: @a3 =

C<A> a4;
// CHECK-DAG: @_Z2a4B1AB1B =

D a5;
// CHECK-DAG: @a5 =

E<int> a6;
// CHECK-DAG: @_Z2a6B1CB1D =

E<A> a7;
// CHECK-DAG: @_Z2a7B1AB1BB1CB1D =

template<>
struct E<float> {
  static float a8;
};
float E<float>::a8;
// CHECK-DAG: @_ZN1EB1CB1DIfE2a8E =

template<>
struct E<F> {
  static bool a9;
};
bool E<F>::a9;
// CHECK-DAG: @_ZN1EB1CB1DI1FB1AB1BE2a9E =

struct __attribute__((abi_tag("A", "B"))) A10 {
  virtual ~A10() {}
} a10;
// vtable
// CHECK-DAG: @_ZTV3A10B1AB1B =
// typeinfo
// CHECK-DAG: @_ZTI3A10B1AB1B =

struct __attribute__((abi_tag("A"))) B11 {
  static A10 b;
};
A10 B11::b;
// B11[abi:A]::b[abi:B]
// CHECK-DAG: @_ZN3B11B1A1bB1BE =

__attribute__ ((abi_tag("C", "D")))
void* f1() {
  return 0;
}
// CHECK-DAG: define {{.*}} @_Z2f1B1CB1Dv(

__attribute__ ((abi_tag("C", "D")))
A* f2() {
  return 0;
}
// CHECK-DAG: define {{.*}} @_Z2f2B1AB1BB1CB1Dv(

B* f3() {
  return 0;
}
// CHECK-DAG: define {{.*}} @_Z2f3v(

C<A>* f4() {
  return 0;
}
// CHECK-DAG: define {{.*}} @_Z2f4B1AB1Bv(

D* f5() {
  return 0;
}
// CHECK-DAG: define {{.*}} @_Z2f5v(

E<char>* f6() {
  return 0;
}
// CHECK-DAG: define {{.*}} @_Z2f6B1CB1Dv(

E<A>* f7() {
  return 0;
}
// CHECK-DAG: define {{.*}} @_Z2f7B1AB1BB1CB1Dv(

void f8(E<A>*) {
}
// CHECK-DAG: define {{.*}} @_Z2f8P1EB1CB1DI1AB1AB1BE(

inline namespace Names1 __attribute__((__abi_tag__)) {
    class C1 {};
}
C1 f9() { return C1(); }
// CHECK-DAG: @_Z2f9B6Names1v(

inline namespace Names2 __attribute__((__abi_tag__("Tag1", "Tag2"))) {
    class C2 {};
}
C2 f10() { return C2(); }
// CHECK-DAG: @_Z3f10B4Tag1B4Tag2v(

void __attribute__((abi_tag("A"))) f11(A) {}
// f11[abi:A](A[abi:A][abi:B])
// CHECK-DAG: define {{.*}} @_Z3f11B1A1AB1AB1B(

A f12(A) { return A(); }
// f12(A[abi:A][abi:B])
// CHECK-DAG: define {{.*}} @_Z3f121AB1AB1B(

inline void f13() {
  struct L {
    static E<int>* foo() {
      static A10 a;
      return 0;
    }
  };
  L::foo();
}
void f13_test() {
  f13();
}
// f13()::L::foo[abi:C][abi:D]()
// CHECK-DAG: define linkonce_odr {{(dso_local )?}}%struct.E* @_ZZ3f13vEN1L3fooB1CB1DEv(

// f13()::L::foo[abi:C][abi:D]()::a[abi:A][abi:B]
// CHECK-DAG: @_ZZZ3f13vEN1L3fooB1CB1DEvE1aB1AB1B =

// guard variable for f13()::L::foo[abi:C][abi:D]()::a[abi:A][abi:B]
// CHECK-DAG: @_ZGVZZ3f13vEN1L3fooB1CB1DEvE1aB1AB1B =

struct __attribute__((abi_tag("TAG"))) A14 {
  A14 f14();
};
A14 A14::f14() {
  return A14();
}
// A14[abi:TAG]::f14()
// CHECK-DAG: define {{.+}} @_ZN3A14B3TAG3f14Ev(

template<class T>
T f15() {
  return T();
}
void f15_test() {
  f15<A14>();
}
// A14[abi:TAG] f15<A14[abi:TAG]>()
// CHECK-DAG: define linkonce_odr {{.+}} @_Z3f15I3A14B3TAGET_v(

template<class T>
A14 f16() {
  return A14();
}
void f16_test() {
  f16<int>();
}
// A14[abi:TAG] f16<int>()
// CHECK-DAG: define linkonce_odr {{.+}} @_Z3f16IiE3A14B3TAGv(

template<class T>
struct __attribute__((abi_tag("TAG"))) A17 {
  A17 operator+(const A17& a) {
    return a;
  }
};
void f17_test() {
  A17<int> a, b;
  a + b;
}
// A17[abi:TAG]<int>::operator+(A17[abi:TAG]<int> const&)
// CHECK-DAG: define linkonce_odr {{.+}} @_ZN3A17B3TAGIiEplERKS0_(

struct A18 {
  operator A() { return A(); }
};
void f18_test() {
  A a = A18();
}
// A18::operator A[abi:A][abi:B]() but GCC adds the same tags twice!
// CHECK-DAG: define linkonce_odr {{.+}} @_ZN3A18cv1AB1AB1BEv(

namespace N19 {
  class A {};
  class __attribute__((abi_tag("B"))) B {};
  class D {};
  class F {};

  template<typename T, B F(T, D)>
  class C {};

  B foo(A, D);
}
void f19_test(N19::C<N19::A,  &N19::foo>, N19::F, N19::D) {
}
// f19_test(N19::C<N19::A, &N19::foo[abi:B]>, N19::F, N19::D)
// CHECK-DAG: define {{(dso_local )?}}void @_Z8f19_testN3N191CINS_1AEXadL_ZNS_3fooB1BES1_NS_1DEEEEENS_1FES2_(

namespace pr30440 {

template<class F> void g(F);
template<class ...A> auto h(A ...a)->decltype (g (0, g < a > (a) ...)) {
}
// CHECK-DAG: define {{.*}} @_ZN7pr304401hIJEEEDTcl1gLi0Espcl1gIL_ZZNS_1hEDpT_E1aEEfp_EEES2_(

void pr30440_test () {
  h();
}

}