blob: 912b555acf00c4ba6ba3e90f57649f5bbb73936d [file] [log] [blame]
Hans Wennborg442e4f72013-12-13 22:43:52 +00001// RUN: %clang_cc1 -std=c++11 %s -cxx-abi itanium -emit-llvm -o - | FileCheck %s
Anders Carlsson2fb08242009-09-08 18:24:21 +00002
Rafael Espindolab7f60e32011-01-10 22:34:03 +00003// CHECK: private unnamed_addr constant [15 x i8] c"externFunction\00"
4// CHECK: private unnamed_addr constant [26 x i8] c"void NS::externFunction()\00"
Douglas Gregor11a434a2012-04-10 20:14:15 +00005// CHECK: private unnamed_addr constant [49 x i8] c"void functionTemplateExplicitSpecialization(int)\00"
6
7// CHECK: private unnamed_addr constant [95 x i8] c"void SpecializedClassTemplate<char>::memberFunctionTemplate(T, U) const [T = char, U = double]\00"
8// CHECK: private unnamed_addr constant [85 x i8] c"void SpecializedClassTemplate<int>::memberFunctionTemplate(int, U) const [U = float]\00"
9// CHECK: private unnamed_addr constant [57 x i8] c"void NonTypeTemplateParam<42>::size() const [Count = 42]\00"
10// CHECK: private unnamed_addr constant [122 x i8] c"static void ClassWithTemplateTemplateParam<char, NS::ClassTemplate>::staticMember() [T = char, Param = NS::ClassTemplate]\00"
11// CHECK: private unnamed_addr constant [106 x i8] c"void OuterClass<int *>::MiddleClass::InnerClass<float>::memberFunction(T, U) const [T = int *, U = float]\00"
Wei Panc354d212013-09-16 13:57:27 +000012// CHECK: private unnamed_addr constant [51 x i8] c"void functionTemplateWithCapturedStmt(T) [T = int]\00"
13// CHECK: private unnamed_addr constant [76 x i8] c"auto functionTemplateWithLambda(int)::<anonymous class>::operator()() const\00"
Douglas Gregor11a434a2012-04-10 20:14:15 +000014// CHECK: private unnamed_addr constant [65 x i8] c"void functionTemplateWithUnnamedTemplateParameter(T) [T = float]\00"
15
16// CHECK: private unnamed_addr constant [60 x i8] c"void functionTemplateExplicitSpecialization(T) [T = double]\00"
17// CHECK: private unnamed_addr constant [52 x i8] c"T *functionTemplateWithCompoundTypes(T *) [T = int]\00"
18// CHECK: private unnamed_addr constant [54 x i8] c"T functionTemplateWithTemplateReturnType() [T = char]\00"
19// CHECK: private unnamed_addr constant [57 x i8] c"void functionTemplateWithoutParameterList() [T = double]\00"
20// CHECK: private unnamed_addr constant [62 x i8] c"void functionTemplateWithTwoParams(T, U) [T = int, U = float]\00"
Anders Carlsson2fb08242009-09-08 18:24:21 +000021
Rafael Espindolab7f60e32011-01-10 22:34:03 +000022// CHECK: private unnamed_addr constant [22 x i8] c"classTemplateFunction\00"
Douglas Gregor11a434a2012-04-10 20:14:15 +000023// CHECK: private unnamed_addr constant [77 x i8] c"void NS::ClassTemplate<NS::Base *>::classTemplateFunction() [T = NS::Base *]\00"
24// CHECK: private unnamed_addr constant [63 x i8] c"void NS::ClassTemplate<int>::classTemplateFunction() [T = int]\00"
Anders Carlsson2fb08242009-09-08 18:24:21 +000025
Rafael Espindolab7f60e32011-01-10 22:34:03 +000026// CHECK: private unnamed_addr constant [18 x i8] c"functionTemplate1\00"
Douglas Gregor11a434a2012-04-10 20:14:15 +000027// CHECK: private unnamed_addr constant [53 x i8] c"void NS::Base::functionTemplate1(T) [T = NS::Base *]\00"
28// CHECK: private unnamed_addr constant [46 x i8] c"void NS::Base::functionTemplate1(T) [T = int]\00"
Anders Carlsson2fb08242009-09-08 18:24:21 +000029
Rafael Espindolab7f60e32011-01-10 22:34:03 +000030// CHECK: private unnamed_addr constant [23 x i8] c"anonymousUnionFunction\00"
31// CHECK: private unnamed_addr constant [83 x i8] c"void NS::ContainerForAnonymousRecords::<anonymous union>::anonymousUnionFunction()\00"
Sam Weinig07d211e2009-12-24 23:15:03 +000032
Rafael Espindolab7f60e32011-01-10 22:34:03 +000033// CHECK: private unnamed_addr constant [24 x i8] c"anonymousStructFunction\00"
34// CHECK: private unnamed_addr constant [85 x i8] c"void NS::ContainerForAnonymousRecords::<anonymous struct>::anonymousStructFunction()\00"
Sam Weinig07d211e2009-12-24 23:15:03 +000035
Rafael Espindolab7f60e32011-01-10 22:34:03 +000036// CHECK: private unnamed_addr constant [23 x i8] c"anonymousClassFunction\00"
37// CHECK: private unnamed_addr constant [83 x i8] c"void NS::ContainerForAnonymousRecords::<anonymous class>::anonymousClassFunction()\00"
Sam Weinig07d211e2009-12-24 23:15:03 +000038
Rafael Espindolab7f60e32011-01-10 22:34:03 +000039// CHECK: private unnamed_addr constant [12 x i8] c"~Destructor\00"
40// CHECK: private unnamed_addr constant [30 x i8] c"NS::Destructor::~Destructor()\00"
Anders Carlsson2fb08242009-09-08 18:24:21 +000041
Rafael Espindolab7f60e32011-01-10 22:34:03 +000042// CHECK: private unnamed_addr constant [12 x i8] c"Constructor\00"
43// CHECK: private unnamed_addr constant [41 x i8] c"NS::Constructor::Constructor(NS::Base *)\00"
44// CHECK: private unnamed_addr constant [34 x i8] c"NS::Constructor::Constructor(int)\00"
45// CHECK: private unnamed_addr constant [31 x i8] c"NS::Constructor::Constructor()\00"
Anders Carlsson2fb08242009-09-08 18:24:21 +000046
Rafael Espindolab7f60e32011-01-10 22:34:03 +000047// CHECK: private unnamed_addr constant [16 x i8] c"virtualFunction\00"
48// CHECK: private unnamed_addr constant [44 x i8] c"virtual void NS::Derived::virtualFunction()\00"
Anders Carlsson2fb08242009-09-08 18:24:21 +000049
Douglas Gregor11a434a2012-04-10 20:14:15 +000050// CHECK: private unnamed_addr constant [21 x i8] c"refQualifiedFunction\00"
51// CHECK: private unnamed_addr constant [41 x i8] c"void NS::Base::refQualifiedFunction() &&\00"
52// CHECK: private unnamed_addr constant [40 x i8] c"void NS::Base::refQualifiedFunction() &\00"
53
Rafael Espindolab7f60e32011-01-10 22:34:03 +000054// CHECK: private unnamed_addr constant [22 x i8] c"constVolatileFunction\00"
55// CHECK: private unnamed_addr constant [54 x i8] c"void NS::Base::constVolatileFunction() const volatile\00"
Sam Weinig4e83bd22009-12-27 01:38:20 +000056
Rafael Espindolab7f60e32011-01-10 22:34:03 +000057// CHECK: private unnamed_addr constant [17 x i8] c"volatileFunction\00"
58// CHECK: private unnamed_addr constant [43 x i8] c"void NS::Base::volatileFunction() volatile\00"
Sam Weinig4e83bd22009-12-27 01:38:20 +000059
Rafael Espindolab7f60e32011-01-10 22:34:03 +000060// CHECK: private unnamed_addr constant [14 x i8] c"constFunction\00"
61// CHECK: private unnamed_addr constant [37 x i8] c"void NS::Base::constFunction() const\00"
Sam Weinig4e83bd22009-12-27 01:38:20 +000062
Rafael Espindolab7f60e32011-01-10 22:34:03 +000063// CHECK: private unnamed_addr constant [26 x i8] c"functionReturingTemplate2\00"
64// CHECK: private unnamed_addr constant [64 x i8] c"ClassTemplate<NS::Base *> NS::Base::functionReturingTemplate2()\00"
Anders Carlsson2fb08242009-09-08 18:24:21 +000065
Rafael Espindolab7f60e32011-01-10 22:34:03 +000066// CHECK: private unnamed_addr constant [26 x i8] c"functionReturingTemplate1\00"
67// CHECK: private unnamed_addr constant [57 x i8] c"ClassTemplate<int> NS::Base::functionReturingTemplate1()\00"
Anders Carlsson2fb08242009-09-08 18:24:21 +000068
Rafael Espindolab7f60e32011-01-10 22:34:03 +000069// CHECK: private unnamed_addr constant [23 x i8] c"withTemplateParameter2\00"
70// CHECK: private unnamed_addr constant [65 x i8] c"void NS::Base::withTemplateParameter2(ClassTemplate<NS::Base *>)\00"
Anders Carlsson2fb08242009-09-08 18:24:21 +000071
Rafael Espindolab7f60e32011-01-10 22:34:03 +000072// CHECK: private unnamed_addr constant [23 x i8] c"withTemplateParameter1\00"
73// CHECK: private unnamed_addr constant [58 x i8] c"void NS::Base::withTemplateParameter1(ClassTemplate<int>)\00"
Anders Carlsson2fb08242009-09-08 18:24:21 +000074
Rafael Espindolab7f60e32011-01-10 22:34:03 +000075// CHECK: private unnamed_addr constant [23 x i8] c"functionReturningClass\00"
76// CHECK: private unnamed_addr constant [45 x i8] c"NS::Base *NS::Base::functionReturningClass()\00"
Anders Carlsson2fb08242009-09-08 18:24:21 +000077
Rafael Espindolab7f60e32011-01-10 22:34:03 +000078// CHECK: private unnamed_addr constant [23 x i8] c"functionWithParameters\00"
79// CHECK: private unnamed_addr constant [64 x i8] c"void NS::Base::functionWithParameters(int, float *, NS::Base *)\00"
Anders Carlsson2fb08242009-09-08 18:24:21 +000080
Rafael Espindolab7f60e32011-01-10 22:34:03 +000081// CHECK: private unnamed_addr constant [17 x i8] c"variadicFunction\00"
82// CHECK: private unnamed_addr constant [42 x i8] c"void NS::Base::variadicFunction(int, ...)\00"
Anders Carlsson2fb08242009-09-08 18:24:21 +000083
Rafael Espindolab7f60e32011-01-10 22:34:03 +000084// CHECK: private unnamed_addr constant [41 x i8] c"virtual void NS::Base::virtualFunction()\00"
Anders Carlsson2fb08242009-09-08 18:24:21 +000085
Rafael Espindolab7f60e32011-01-10 22:34:03 +000086// CHECK: private unnamed_addr constant [15 x i8] c"inlineFunction\00"
87// CHECK: private unnamed_addr constant [32 x i8] c"void NS::Base::inlineFunction()\00"
Anders Carlsson2fb08242009-09-08 18:24:21 +000088
Rafael Espindolab7f60e32011-01-10 22:34:03 +000089// CHECK: private unnamed_addr constant [15 x i8] c"staticFunction\00"
90// CHECK: private unnamed_addr constant [39 x i8] c"static void NS::Base::staticFunction()\00"
Anders Carlsson2fb08242009-09-08 18:24:21 +000091
Rafael Espindolab7f60e32011-01-10 22:34:03 +000092// CHECK: private unnamed_addr constant [26 x i8] c"topLevelNamespaceFunction\00"
93// CHECK: private unnamed_addr constant [59 x i8] c"void ClassInTopLevelNamespace::topLevelNamespaceFunction()\00"
Sam Weinig07d211e2009-12-24 23:15:03 +000094
Rafael Espindolab7f60e32011-01-10 22:34:03 +000095// CHECK: private unnamed_addr constant [27 x i8] c"anonymousNamespaceFunction\00"
96// CHECK: private unnamed_addr constant [84 x i8] c"void <anonymous namespace>::ClassInAnonymousNamespace::anonymousNamespaceFunction()\00"
Sam Weinig07d211e2009-12-24 23:15:03 +000097
Rafael Espindolab7f60e32011-01-10 22:34:03 +000098// CHECK: private unnamed_addr constant [19 x i8] c"localClassFunction\00"
99// CHECK: private unnamed_addr constant [59 x i8] c"void NS::localClass(int)::LocalClass::localClassFunction()\00"
Sam Weinigb999f682009-12-28 03:19:38 +0000100
Douglas Gregor11a434a2012-04-10 20:14:15 +0000101
102
Mike Stumpf8c1f0d2009-10-08 23:05:06 +0000103int printf(const char * _Format, ...);
Anders Carlsson2fb08242009-09-08 18:24:21 +0000104
Sam Weinig07d211e2009-12-24 23:15:03 +0000105class ClassInTopLevelNamespace {
106public:
107 void topLevelNamespaceFunction() {
108 printf("__func__ %s\n", __func__);
109 printf("__FUNCTION__ %s\n", __FUNCTION__);
110 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
111 }
112};
113
114namespace {
115
116 class ClassInAnonymousNamespace {
117 public:
118 void anonymousNamespaceFunction() {
119 printf("__func__ %s\n", __func__);
120 printf("__FUNCTION__ %s\n", __FUNCTION__);
121 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
122 }
123 };
124
125} // end anonymous namespace
126
Anders Carlsson2fb08242009-09-08 18:24:21 +0000127namespace NS {
128
129template<typename T>
130class ClassTemplate {
131public:
132 void classTemplateFunction() {
133 printf("__func__ %s\n", __func__);
134 printf("__FUNCTION__ %s\n", __FUNCTION__);
135 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
136 }
137};
138
139class Base {
140public:
Sam Weinig4e83bd22009-12-27 01:38:20 +0000141 static void staticFunction() {
Anders Carlsson2fb08242009-09-08 18:24:21 +0000142 printf("__func__ %s\n", __func__);
143 printf("__FUNCTION__ %s\n", __FUNCTION__);
144 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
145 }
146
Argyrios Kyrtzidis53e3d6d2012-12-14 19:44:11 +0000147 inline void (inlineFunction)() {
Anders Carlsson2fb08242009-09-08 18:24:21 +0000148 printf("__func__ %s\n", __func__);
149 printf("__FUNCTION__ %s\n", __FUNCTION__);
150 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
151 }
152
153 virtual void virtualFunction() {
154 printf("__func__ %s\n", __func__);
155 printf("__FUNCTION__ %s\n", __FUNCTION__);
156 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
157 }
158
159 void functionWithParameters(int, float*, Base* base) {
160 printf("__func__ %s\n", __func__);
161 printf("__FUNCTION__ %s\n", __FUNCTION__);
162 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
163 }
164
165 Base *functionReturningClass() {
166 printf("__func__ %s\n", __func__);
167 printf("__FUNCTION__ %s\n", __FUNCTION__);
168 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
169 return 0;
170 }
171
172 void variadicFunction(int, ...) {
173 printf("__func__ %s\n", __func__);
174 printf("__FUNCTION__ %s\n", __FUNCTION__);
175 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
176 }
177
178 void withTemplateParameter1(ClassTemplate<int>) {
179 printf("__func__ %s\n", __func__);
180 printf("__FUNCTION__ %s\n", __FUNCTION__);
181 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
182 }
183
184 void withTemplateParameter2(ClassTemplate<Base *>) {
185 printf("__func__ %s\n", __func__);
186 printf("__FUNCTION__ %s\n", __FUNCTION__);
187 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
188 }
189
190 ClassTemplate<int> functionReturingTemplate1() {
191 printf("__func__ %s\n", __func__);
192 printf("__FUNCTION__ %s\n", __FUNCTION__);
193 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
194 return ClassTemplate<int>();
195 }
196
197 ClassTemplate<Base *> functionReturingTemplate2() {
198 printf("__func__ %s\n", __func__);
199 printf("__FUNCTION__ %s\n", __FUNCTION__);
200 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
201 return ClassTemplate<Base *>();
202 }
203
204 template<typename T>
205 void functionTemplate1(T t) {
206 printf("__func__ %s\n", __func__);
207 printf("__FUNCTION__ %s\n", __FUNCTION__);
208 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
209 }
Sam Weinig4e83bd22009-12-27 01:38:20 +0000210
211 void constFunction() const {
212 printf("__func__ %s\n", __func__);
213 printf("__FUNCTION__ %s\n", __FUNCTION__);
214 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
215 }
216
217 void volatileFunction() volatile {
218 printf("__func__ %s\n", __func__);
219 printf("__FUNCTION__ %s\n", __FUNCTION__);
220 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
221 }
222
223 void constVolatileFunction() const volatile {
224 printf("__func__ %s\n", __func__);
225 printf("__FUNCTION__ %s\n", __FUNCTION__);
226 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
227 }
Douglas Gregor11a434a2012-04-10 20:14:15 +0000228
229 void refQualifiedFunction() & {
230 printf("__func__ %s\n", __func__);
231 printf("__FUNCTION__ %s\n", __FUNCTION__);
232 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
233 }
234
235 void refQualifiedFunction() && {
236 printf("__func__ %s\n", __func__);
237 printf("__FUNCTION__ %s\n", __FUNCTION__);
238 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
239 }
Anders Carlsson2fb08242009-09-08 18:24:21 +0000240};
241
242class Derived : public Base {
243public:
Douglas Gregor11a434a2012-04-10 20:14:15 +0000244 // Virtual function without being explicitly written.
Anders Carlsson2fb08242009-09-08 18:24:21 +0000245 void virtualFunction() {
246 printf("__func__ %s\n", __func__);
247 printf("__FUNCTION__ %s\n", __FUNCTION__);
248 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
249 }
250};
251
252class Constructor {
253public:
254 Constructor() {
255 printf("__func__ %s\n", __func__);
256 printf("__FUNCTION__ %s\n", __FUNCTION__);
257 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
258 }
259
260 Constructor(int) {
261 printf("__func__ %s\n", __func__);
262 printf("__FUNCTION__ %s\n", __FUNCTION__);
263 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
264 }
265
266 Constructor(Base *) {
267 printf("__func__ %s\n", __func__);
268 printf("__FUNCTION__ %s\n", __FUNCTION__);
269 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
270 }
Anders Carlsson2fb08242009-09-08 18:24:21 +0000271};
272
273class Destructor {
274public:
275 ~Destructor() {
276 printf("__func__ %s\n", __func__);
277 printf("__FUNCTION__ %s\n", __FUNCTION__);
278 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
279 }
280};
281
Sam Weinig07d211e2009-12-24 23:15:03 +0000282class ContainerForAnonymousRecords {
283public:
284 class {
285 public:
286 void anonymousClassFunction() {
287 printf("__func__ %s\n", __func__);
288 printf("__FUNCTION__ %s\n", __FUNCTION__);
289 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
290 }
291 } anonymousClass;
292
293 struct {
294 void anonymousStructFunction() {
295 printf("__func__ %s\n", __func__);
296 printf("__FUNCTION__ %s\n", __FUNCTION__);
297 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
298 }
299 } anonymousStruct;
300
301 union {
302 void anonymousUnionFunction() {
303 printf("__func__ %s\n", __func__);
304 printf("__FUNCTION__ %s\n", __FUNCTION__);
305 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
306 }
307 } anonymousUnion;
308};
309
Sam Weinigb999f682009-12-28 03:19:38 +0000310void localClass(int) {
311 class LocalClass {
312 public:
313 void localClassFunction() {
314 printf("__func__ %s\n", __func__);
315 printf("__FUNCTION__ %s\n", __FUNCTION__);
316 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
317 }
318 };
319 LocalClass lc;
320 lc.localClassFunction();
321}
322
Anders Carlsson2fb08242009-09-08 18:24:21 +0000323extern void externFunction() {
324 printf("__func__ %s\n", __func__);
325 printf("__FUNCTION__ %s\n", __FUNCTION__);
326 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
327}
328
Sam Weinig07d211e2009-12-24 23:15:03 +0000329} // end NS namespace
Anders Carlsson2fb08242009-09-08 18:24:21 +0000330
Douglas Gregor11a434a2012-04-10 20:14:15 +0000331// additional tests for __PRETTY_FUNCTION__
332template <typename T, typename U>
333void functionTemplateWithTwoParams(T, U)
334{
335 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
336}
337
338template <typename T>
339void functionTemplateWithoutParameterList()
340{
341 T t = T();
342
343 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
344}
345
346template <typename T>
347T functionTemplateWithTemplateReturnType()
348{
349 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
350
351 return T();
352}
353
354template <typename T>
355T * functionTemplateWithCompoundTypes(T a[])
356{
357 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
358
359 return 0;
360}
361
362template <typename T>
363void functionTemplateExplicitSpecialization(T t)
364{
365 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
366}
367
368template <>
369void functionTemplateExplicitSpecialization<int>(int i)
370{
371 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
372}
373
374template <typename, typename T>
375void functionTemplateWithUnnamedTemplateParameter(T t)
376{
377 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
378}
379
380template <typename T>
Wei Panc354d212013-09-16 13:57:27 +0000381void functionTemplateWithLambda(T t)
382{
383 []() {
384 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
385 } ();
386}
387
388template <typename T>
389void functionTemplateWithCapturedStmt(T t)
390{
391 #pragma clang __debug captured
392 {
393 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
394 }
395}
396
397template <typename T>
Douglas Gregor11a434a2012-04-10 20:14:15 +0000398class OuterClass
399{
400public:
401 class MiddleClass
402 {
403 public:
404 template <typename U>
405 class InnerClass
406 {
407 public:
408 void memberFunction(T x, U y) const
409 {
410 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
411 }
412 };
413 };
414};
415
416template <typename T, template <typename> class Param = NS::ClassTemplate>
417class ClassWithTemplateTemplateParam
418{
419public:
420 static void staticMember()
421 {
422 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
423 }
424};
425
426template <int Count>
427class NonTypeTemplateParam
428{
429public:
430 void size() const
431 {
432 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
433 }
434};
435
436template <typename T>
437class SpecializedClassTemplate
438{
439public:
440 template <typename U>
441 void memberFunctionTemplate(T t, U u) const
442 {
443 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
444 }
445};
446
447template <>
448class SpecializedClassTemplate<int>
449{
450public:
451 template <typename U>
452 void memberFunctionTemplate(int i, U u) const
453 {
454 printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
455 }
456};
457
Anders Carlsson2fb08242009-09-08 18:24:21 +0000458int main() {
Sam Weinig07d211e2009-12-24 23:15:03 +0000459 ClassInAnonymousNamespace anonymousNamespace;
460 anonymousNamespace.anonymousNamespaceFunction();
Anders Carlsson2fb08242009-09-08 18:24:21 +0000461
Sam Weinig07d211e2009-12-24 23:15:03 +0000462 ClassInTopLevelNamespace topLevelNamespace;
463 topLevelNamespace.topLevelNamespaceFunction();
464
Sam Weinig4e83bd22009-12-27 01:38:20 +0000465 NS::Base::staticFunction();
Sam Weinig07d211e2009-12-24 23:15:03 +0000466
Anders Carlsson2fb08242009-09-08 18:24:21 +0000467 NS::Base b;
468 b.inlineFunction();
469 b.virtualFunction();
470 b.variadicFunction(0);
471 b.functionWithParameters(0, 0, 0);
472 b.functionReturningClass();
473
474 b.withTemplateParameter1(NS::ClassTemplate<int>());
475 b.withTemplateParameter2(NS::ClassTemplate<NS::Base *>());
476 b.functionReturingTemplate1();
477 b.functionReturingTemplate2();
478 b.functionTemplate1<int>(0);
479 b.functionTemplate1<NS::Base *>(0);
Sam Weinig4e83bd22009-12-27 01:38:20 +0000480 b.constFunction();
481 b.volatileFunction();
482 b.constVolatileFunction();
Douglas Gregor11a434a2012-04-10 20:14:15 +0000483 b.refQualifiedFunction();
484 NS::Base().refQualifiedFunction();
Sam Weinig4e83bd22009-12-27 01:38:20 +0000485
Anders Carlsson2fb08242009-09-08 18:24:21 +0000486 NS::Derived d;
487 d.virtualFunction();
488
489 NS::ClassTemplate<int> t1;
490 t1.classTemplateFunction();
491 NS::ClassTemplate<NS::Base *> t2;
492 t2.classTemplateFunction();
493
494 NS::Constructor c1;
495 NS::Constructor c2(0);
496 NS::Constructor c3((NS::Base *)0);
497
498 {
499 NS::Destructor destructor;
500 }
Sam Weinig07d211e2009-12-24 23:15:03 +0000501
502 NS::ContainerForAnonymousRecords anonymous;
503 anonymous.anonymousClass.anonymousClassFunction();
504 anonymous.anonymousStruct.anonymousStructFunction();
505 anonymous.anonymousUnion.anonymousUnionFunction();
506
Sam Weinigb999f682009-12-28 03:19:38 +0000507 NS::localClass(0);
508
Anders Carlsson2fb08242009-09-08 18:24:21 +0000509 NS::externFunction();
Sam Weinig07d211e2009-12-24 23:15:03 +0000510
Douglas Gregor11a434a2012-04-10 20:14:15 +0000511 // additional tests for __PRETTY_FUNCTION__
512
513 functionTemplateWithTwoParams(0, 0.0f);
514 functionTemplateWithoutParameterList<double>();
515 functionTemplateWithTemplateReturnType<char>();
516 int array[] = { 1, 2, 3 };
517 functionTemplateWithCompoundTypes(array);
518 functionTemplateExplicitSpecialization(0);
519 functionTemplateExplicitSpecialization(0.0);
520 functionTemplateWithUnnamedTemplateParameter<int, float>(0.0f);
521
Wei Panc354d212013-09-16 13:57:27 +0000522 functionTemplateWithLambda<int>(0);
523 functionTemplateWithCapturedStmt<int>(0);
524
Douglas Gregor11a434a2012-04-10 20:14:15 +0000525 OuterClass<int *>::MiddleClass::InnerClass<float> omi;
526 omi.memberFunction(0, 0.0f);
527
528 ClassWithTemplateTemplateParam<char>::staticMember();
529
530 NonTypeTemplateParam<42> ntt;
531 ntt.size();
532
533 SpecializedClassTemplate<int> sct1;
534 sct1.memberFunctionTemplate(0, 0.0f);
535 SpecializedClassTemplate<char> sct2;
536 sct2.memberFunctionTemplate('0', 0.0);
537
Anders Carlsson2fb08242009-09-08 18:24:21 +0000538 return 0;
539}